1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
/* * @(#)JobStateReasons.java 1.10 06/04/07 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.print.attribute.standard; import java.util.Collection; import java.util.HashSet; import javax.print.attribute.Attribute; import javax.print.attribute.PrintJobAttribute; /** * Class JobStateReasons is a printing attribute class, a set of enumeration * values, that provides additional information about the job's current state, * i.e., information that augments the value of the job's {@link JobState * JobState} attribute. * <P> * Instances of {@link JobStateReason JobStateReason} do not appear in a Print * Job's attribute set directly. Rather, a JobStateReasons attribute appears in * the Print Job's attribute set. The JobStateReasons attribute contains zero, * one, or more than one {@link JobStateReason JobStateReason} objects which * pertain to the Print Job's status. The printer adds a {@link JobStateReason * JobStateReason} object to the Print Job's JobStateReasons attribute when the * corresponding condition becomes true of the Print Job, and the printer * removes the {@link JobStateReason JobStateReason} object again when the * corresponding condition becomes false, regardless of whether the Print Job's * overall {@link JobState JobState} also changed. * <P> * Class JobStateReasons inherits its implementation from class {@link * java.util.HashSet java.util.HashSet}. Unlike most printing attributes which * are immutable once constructed, class JobStateReasons is designed to be * mutable; you can add {@link JobStateReason JobStateReason} objects to an * existing JobStateReasons object and remove them again. However, like class * {@link java.util.HashSet java.util.HashSet}, class JobStateReasons is not * multiple thread safe. If a JobStateReasons object will be used by multiple * threads, be sure to synchronize its operations (e.g., using a synchronized * set view obtained from class {@link java.util.Collections * java.util.Collections}). * <P> * <B>IPP Compatibility:</B> The string value returned by each individual {@link * JobStateReason JobStateReason} object's <CODE>toString()</CODE> method gives * the IPP keyword value. The category name returned by <CODE>getName()</CODE> * gives the IPP attribute name. * <P> * * @author Alan Kaminsky */ public final class JobStateReasons extends HashSet<JobStateReason> implements PrintJobAttribute { private static final long serialVersionUID = 8849088261264331812L; /** * Construct a new, empty job state reasons attribute; the underlying hash * set has the default initial capacity and load factor. */ public JobStateReasons() { super(); } /** * Construct a new, empty job state reasons attribute; the underlying hash * set has the given initial capacity and the default load factor. * * @param initialCapacity Initial capacity. * @throws IllegalArgumentException if the initial capacity is less * than zero. */ public JobStateReasons(int initialCapacity) { super (initialCapacity); } /** * Construct a new, empty job state reasons attribute; the underlying hash * set has the given initial capacity and load factor. * * @param initialCapacity Initial capacity. * @param loadFactor Load factor. * @throws IllegalArgumentException if the initial capacity is less * than zero. */ public JobStateReasons(int initialCapacity, float loadFactor) { super (initialCapacity, loadFactor); } /** * Construct a new job state reasons attribute that contains the same * {@link JobStateReason JobStateReason} objects as the given collection. * The underlying hash set's initial capacity and load factor are as * specified in the superclass constructor {@link * java.util.HashSet#HashSet(java.util.Collection) * <CODE>HashSet(Collection)</CODE>}. * * @param collection Collection to copy. * * @exception NullPointerException * (unchecked exception) Thrown if <CODE>collection</CODE> is null or * if any element in <CODE>collection</CODE> is null. * @throws ClassCastException * (unchecked exception) Thrown if any element in * <CODE>collection</CODE> is not an instance of class {@link * JobStateReason JobStateReason}. */ public JobStateReasons(Collection<JobStateReason> collection) { super (collection); } /** * Adds the specified element to this job state reasons attribute if it is * not already present. The element to be added must be an instance of class * {@link JobStateReason JobStateReason}. If this job state reasons * attribute already contains the specified element, the call leaves this * job state reasons attribute unchanged and returns <tt>false</tt>. * * @param o Element to be added to this job state reasons attribute. * * @return <tt>true</tt> if this job state reasons attribute did not * already contain the specified element. * * @throws NullPointerException * (unchecked exception) Thrown if the specified element is null. * @throws ClassCastException * (unchecked exception) Thrown if the specified element is not an * instance of class {@link JobStateReason JobStateReason}. * @since 1.5 */ public boolean add(JobStateReason o) { if (o == null) { throw new NullPointerException(); } return super.add ((JobStateReason) o); } /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. * <P> * For class JobStateReasons, the category is class JobStateReasons itself. * * @return Printing attribute class (category), an instance of class * {@link java.lang.Class java.lang.Class}. */ public final Class<? extends Attribute> getCategory() { return JobStateReasons.class; } /** * Get the name of the category of which this attribute value is an * instance. * <P> * For class JobStateReasons, the category * name is <CODE>"job-state-reasons"</CODE>. * * @return Attribute category name. */ public final String getName() { return "job-state-reasons"; } }