< prev index next >

src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */

  25 package javax.print.attribute.standard;
  26 
  27 import java.util.Collection;
  28 import java.util.HashSet;
  29 
  30 import javax.print.attribute.Attribute;
  31 import javax.print.attribute.PrintJobAttribute;
  32 
  33 /**
  34  * Class JobStateReasons is a printing attribute class, a set of enumeration
  35  * values, that provides additional information about the job's current state,
  36  * i.e., information that augments the value of the job's {@link JobState
  37  * JobState} attribute.
  38  * <P>
  39  * Instances of {@link JobStateReason JobStateReason} do not appear in a Print
  40  * Job's attribute set directly. Rather, a JobStateReasons attribute appears in
  41  * the Print Job's attribute set. The JobStateReasons attribute contains zero,
  42  * one, or more than one {@link JobStateReason JobStateReason} objects which
  43  * pertain to the Print Job's status. The printer adds a {@link JobStateReason
  44  * JobStateReason} object to the Print Job's JobStateReasons attribute when the
  45  * corresponding condition becomes true of the Print Job, and the printer
  46  * removes the {@link JobStateReason JobStateReason} object again when the
  47  * corresponding condition becomes false, regardless of whether the Print Job's
  48  * overall {@link JobState JobState} also changed.
  49  * <P>
  50  * Class JobStateReasons inherits its implementation from class {@link
  51  * java.util.HashSet java.util.HashSet}. Unlike most printing attributes which
  52  * are immutable once constructed, class JobStateReasons is designed to be
  53  * mutable; you can add {@link JobStateReason JobStateReason} objects to an
  54  * existing JobStateReasons object and remove them again. However, like class
  55  * {@link java.util.HashSet java.util.HashSet}, class JobStateReasons is not
  56  * multiple thread safe. If a JobStateReasons object will be used by multiple
  57  * threads, be sure to synchronize its operations (e.g., using a synchronized
  58  * set view obtained from class {@link java.util.Collections
  59  * java.util.Collections}).
  60  * <P>
  61  * <B>IPP Compatibility:</B> The string value returned by each individual {@link
  62  * JobStateReason JobStateReason} object's {@code toString()} method gives
  63  * the IPP keyword value. The category name returned by {@code getName()}

  64  * gives the IPP attribute name.
  65  *
  66  * @author  Alan Kaminsky
  67  */
  68 public final class JobStateReasons
  69     extends HashSet<JobStateReason> implements PrintJobAttribute {
  70 



  71     private static final long serialVersionUID = 8849088261264331812L;
  72 
  73     /**
  74      * Construct a new, empty job state reasons attribute; the underlying hash
  75      * set has the default initial capacity and load factor.
  76      */
  77     public JobStateReasons() {
  78         super();
  79     }
  80 
  81     /**
  82      * Construct a new, empty job state reasons attribute; the underlying hash
  83      * set has the given initial capacity and the default load factor.
  84      *
  85      * @param  initialCapacity  Initial capacity.
  86      * @throws IllegalArgumentException if the initial capacity is less
  87      *     than zero.
  88      */
  89     public JobStateReasons(int initialCapacity) {
  90         super (initialCapacity);
  91     }
  92 
  93     /**
  94      * Construct a new, empty job state reasons attribute; the underlying hash
  95      * set has the given initial capacity and load factor.
  96      *
  97      * @param  initialCapacity  Initial capacity.
  98      * @param  loadFactor       Load factor.
  99      * @throws IllegalArgumentException if the initial capacity is less
 100      *     than zero.
 101      */
 102     public JobStateReasons(int initialCapacity, float loadFactor) {
 103         super (initialCapacity, loadFactor);
 104     }
 105 
 106     /**
 107      * Construct a new job state reasons attribute that contains the same
 108      * {@link JobStateReason JobStateReason} objects as the given collection.
 109      * The underlying hash set's initial capacity and load factor are as
 110      * specified in the superclass constructor {@link
 111      * java.util.HashSet#HashSet(java.util.Collection)
 112      * HashSet(Collection)}.
 113      *
 114      * @param  collection  Collection to copy.
 115      *
 116      * @exception  NullPointerException
 117      *     (unchecked exception) Thrown if {@code collection} is null or
 118      *     if any element in {@code collection} is null.
 119      * @throws  ClassCastException
 120      *     (unchecked exception) Thrown if any element in
 121      *     {@code collection} is not an instance of class {@link
 122      *     JobStateReason JobStateReason}.
 123      */
 124    public JobStateReasons(Collection<JobStateReason> collection) {
 125        super (collection);
 126    }
 127 
 128     /**
 129      * Adds the specified element to this job state reasons attribute if it is
 130      * not already present. The element to be added must be an instance of class
 131      * {@link JobStateReason JobStateReason}. If this job state reasons
 132      * attribute already contains the specified element, the call leaves this
 133      * job state reasons attribute unchanged and returns {@code false}.
 134      *
 135      * @param  o  Element to be added to this job state reasons attribute.
 136      *
 137      * @return  {@code true} if this job state reasons attribute did not
 138      *          already contain the specified element.
 139      *
 140      * @throws  NullPointerException
 141      *     (unchecked exception) Thrown if the specified element is null.
 142      * @throws  ClassCastException
 143      *     (unchecked exception) Thrown if the specified element is not an
 144      *     instance of class {@link JobStateReason JobStateReason}.
 145      * @since 1.5
 146      */
 147     public boolean add(JobStateReason o) {
 148         if (o == null) {
 149             throw new NullPointerException();
 150         }
 151         return super.add(o);
 152     }
 153 
 154     /**
 155      * Get the printing attribute class which is to be used as the "category"
 156      * for this printing attribute value.
 157      * <P>
 158      * For class JobStateReasons, the category is class JobStateReasons itself.

 159      *
 160      * @return  Printing attribute class (category), an instance of class
 161      *          {@link java.lang.Class java.lang.Class}.
 162      */
 163     public final Class<? extends Attribute> getCategory() {
 164         return JobStateReasons.class;
 165     }
 166 
 167     /**
 168      * Get the name of the category of which this attribute value is an
 169      * instance.
 170      * <P>
 171      * For class JobStateReasons, the category
 172      * name is {@code "job-state-reasons"}.
 173      *
 174      * @return  Attribute category name.
 175      */
 176     public final String getName() {
 177         return "job-state-reasons";
 178     }
 179 
 180 }
   1 /*
   2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.print.attribute.standard;
  27 
  28 import java.util.Collection;
  29 import java.util.HashSet;
  30 
  31 import javax.print.attribute.Attribute;
  32 import javax.print.attribute.PrintJobAttribute;
  33 
  34 /**
  35  * Class {@code JobStateReasons} is a printing attribute class, a set of
  36  * enumeration values, that provides additional information about the job's
  37  * current state, i.e., information that augments the value of the job's
  38  * {@link JobState JobState} attribute.
  39  * <p>
  40  * Instances of {@link JobStateReason JobStateReason} do not appear in a Print
  41  * Job's attribute set directly. Rather, a {@code JobStateReasons} attribute
  42  * appears in the Print Job's attribute set. The {@code JobStateReasons}
  43  * attribute contains zero, one, or more than one
  44  * {@link JobStateReason JobStateReason} objects which pertain to the Print
  45  * Job's status. The printer adds a {@link JobStateReason JobStateReason} object
  46  * to the Print Job's JobStateReasons attribute when the corresponding condition
  47  * becomes true of the Print Job, and the printer removes the
  48  * {@link JobStateReason JobStateReason} object again when the corresponding
  49  * condition becomes false, regardless of whether the Print Job's overall
  50  * {@link JobState JobState} also changed.
  51  * <p>
  52  * Class {@code JobStateReasons} inherits its implementation from class
  53  * {@link HashSet java.util.HashSet}. Unlike most printing attributes
  54  * which are immutable once constructed, class {@code JobStateReasons} is
  55  * designed to be mutable; you can add {@link JobStateReason JobStateReason}
  56  * objects to an existing {@code JobStateReasons} object and remove them again.
  57  * However, like class {@link HashSet java.util.HashSet}, class
  58  * {@code JobStateReasons} is not multiple thread safe. If a
  59  * {@code JobStateReasons} object will be used by multiple threads, be sure to
  60  * synchronize its operations (e.g., using a synchronized set view obtained
  61  * from class {@link java.util.Collections java.util.Collections}).
  62  * <p>
  63  * <b>IPP Compatibility:</b> The string value returned by each individual
  64  * {@link JobStateReason JobStateReason} object's {@code toString()} method
  65  * gives the IPP keyword value. The category name returned by {@code getName()}
  66  * gives the IPP attribute name.
  67  *
  68  * @author Alan Kaminsky
  69  */
  70 public final class JobStateReasons
  71     extends HashSet<JobStateReason> implements PrintJobAttribute {
  72 
  73     /**
  74      * Use serialVersionUID from JDK 1.4 for interoperability.
  75      */
  76     private static final long serialVersionUID = 8849088261264331812L;
  77 
  78     /**
  79      * Construct a new, empty job state reasons attribute; the underlying hash
  80      * set has the default initial capacity and load factor.
  81      */
  82     public JobStateReasons() {
  83         super();
  84     }
  85 
  86     /**
  87      * Construct a new, empty job state reasons attribute; the underlying hash
  88      * set has the given initial capacity and the default load factor.
  89      *
  90      * @param  initialCapacity initial capacity
  91      * @throws IllegalArgumentException if the initial capacity is negative

  92      */
  93     public JobStateReasons(int initialCapacity) {
  94         super (initialCapacity);
  95     }
  96 
  97     /**
  98      * Construct a new, empty job state reasons attribute; the underlying hash
  99      * set has the given initial capacity and load factor.
 100      *
 101      * @param  initialCapacity initial capacity
 102      * @param  loadFactor load factor
 103      * @throws IllegalArgumentException if the initial capacity is negative

 104      */
 105     public JobStateReasons(int initialCapacity, float loadFactor) {
 106         super (initialCapacity, loadFactor);
 107     }
 108 
 109     /**
 110      * Construct a new job state reasons attribute that contains the same
 111      * {@link JobStateReason JobStateReason} objects as the given collection.
 112      * The underlying hash set's initial capacity and load factor are as
 113      * specified in the superclass constructor
 114      * {@link HashSet#HashSet(Collection) HashSet(Collection)}.
 115      *
 116      * @param  collection collection to copy
 117      * @throws NullPointerException if {@code collection} is {@code null} or if
 118      *         any element in {@code collection} is {@code null}
 119      * @throws ClassCastException if any element in {@code collection} is not an
 120      *         instance of class {@link JobStateReason JobStateReason}





 121      */
 122     public JobStateReasons(Collection<JobStateReason> collection) {
 123         super (collection);
 124     }
 125 
 126     /**
 127      * Adds the specified element to this job state reasons attribute if it is
 128      * not already present. The element to be added must be an instance of class
 129      * {@link JobStateReason JobStateReason}. If this job state reasons
 130      * attribute already contains the specified element, the call leaves this
 131      * job state reasons attribute unchanged and returns {@code false}.
 132      *
 133      * @param  o element to be added to this job state reasons attribute
 134      * @return {@code true} if this job state reasons attribute did not already
 135      *         contain the specified element
 136      * @throws NullPointerException if the specified element is {@code null}
 137      * @throws ClassCastException if the specified element is not an instance of
 138      *         class {@link JobStateReason JobStateReason}




 139      * @since 1.5
 140      */
 141     public boolean add(JobStateReason o) {
 142         if (o == null) {
 143             throw new NullPointerException();
 144         }
 145         return super.add(o);
 146     }
 147 
 148     /**
 149      * Get the printing attribute class which is to be used as the "category"
 150      * for this printing attribute value.
 151      * <p>
 152      * For class {@code JobStateReasons}, the category is class
 153      * JobStateReasons itself.
 154      *
 155      * @return printing attribute class (category), an instance of class
 156      *         {@link Class java.lang.Class}
 157      */
 158     public final Class<? extends Attribute> getCategory() {
 159         return JobStateReasons.class;
 160     }
 161 
 162     /**
 163      * Get the name of the category of which this attribute value is an
 164      * instance.
 165      * <p>
 166      * For class JobStateReasons, the category name is
 167      * {@code "job-state-reasons"}.
 168      *
 169      * @return attribute category name
 170      */
 171     public final String getName() {
 172         return "job-state-reasons";
 173     }

 174 }
< prev index next >