Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/attribute/standard/JobStateReasons.java
38918 views
/*1* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package javax.print.attribute.standard;2526import java.util.Collection;27import java.util.HashSet;2829import javax.print.attribute.Attribute;30import javax.print.attribute.PrintJobAttribute;3132/**33* Class JobStateReasons is a printing attribute class, a set of enumeration34* values, that provides additional information about the job's current state,35* i.e., information that augments the value of the job's {@link JobState36* JobState} attribute.37* <P>38* Instances of {@link JobStateReason JobStateReason} do not appear in a Print39* Job's attribute set directly. Rather, a JobStateReasons attribute appears in40* the Print Job's attribute set. The JobStateReasons attribute contains zero,41* one, or more than one {@link JobStateReason JobStateReason} objects which42* pertain to the Print Job's status. The printer adds a {@link JobStateReason43* JobStateReason} object to the Print Job's JobStateReasons attribute when the44* corresponding condition becomes true of the Print Job, and the printer45* removes the {@link JobStateReason JobStateReason} object again when the46* corresponding condition becomes false, regardless of whether the Print Job's47* overall {@link JobState JobState} also changed.48* <P>49* Class JobStateReasons inherits its implementation from class {@link50* java.util.HashSet java.util.HashSet}. Unlike most printing attributes which51* are immutable once constructed, class JobStateReasons is designed to be52* mutable; you can add {@link JobStateReason JobStateReason} objects to an53* existing JobStateReasons object and remove them again. However, like class54* {@link java.util.HashSet java.util.HashSet}, class JobStateReasons is not55* multiple thread safe. If a JobStateReasons object will be used by multiple56* threads, be sure to synchronize its operations (e.g., using a synchronized57* set view obtained from class {@link java.util.Collections58* java.util.Collections}).59* <P>60* <B>IPP Compatibility:</B> The string value returned by each individual {@link61* JobStateReason JobStateReason} object's <CODE>toString()</CODE> method gives62* the IPP keyword value. The category name returned by <CODE>getName()</CODE>63* gives the IPP attribute name.64* <P>65*66* @author Alan Kaminsky67*/68public final class JobStateReasons69extends HashSet<JobStateReason> implements PrintJobAttribute {7071private static final long serialVersionUID = 8849088261264331812L;7273/**74* Construct a new, empty job state reasons attribute; the underlying hash75* set has the default initial capacity and load factor.76*/77public JobStateReasons() {78super();79}8081/**82* Construct a new, empty job state reasons attribute; the underlying hash83* 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 less87* than zero.88*/89public JobStateReasons(int initialCapacity) {90super (initialCapacity);91}9293/**94* Construct a new, empty job state reasons attribute; the underlying hash95* 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 less100* than zero.101*/102public JobStateReasons(int initialCapacity, float loadFactor) {103super (initialCapacity, loadFactor);104}105106/**107* Construct a new job state reasons attribute that contains the same108* {@link JobStateReason JobStateReason} objects as the given collection.109* The underlying hash set's initial capacity and load factor are as110* specified in the superclass constructor {@link111* java.util.HashSet#HashSet(java.util.Collection)112* HashSet(Collection)}.113*114* @param collection Collection to copy.115*116* @exception NullPointerException117* (unchecked exception) Thrown if <CODE>collection</CODE> is null or118* if any element in <CODE>collection</CODE> is null.119* @throws ClassCastException120* (unchecked exception) Thrown if any element in121* <CODE>collection</CODE> is not an instance of class {@link122* JobStateReason JobStateReason}.123*/124public JobStateReasons(Collection<JobStateReason> collection) {125super (collection);126}127128/**129* Adds the specified element to this job state reasons attribute if it is130* not already present. The element to be added must be an instance of class131* {@link JobStateReason JobStateReason}. If this job state reasons132* attribute already contains the specified element, the call leaves this133* job state reasons attribute unchanged and returns <tt>false</tt>.134*135* @param o Element to be added to this job state reasons attribute.136*137* @return <tt>true</tt> if this job state reasons attribute did not138* already contain the specified element.139*140* @throws NullPointerException141* (unchecked exception) Thrown if the specified element is null.142* @throws ClassCastException143* (unchecked exception) Thrown if the specified element is not an144* instance of class {@link JobStateReason JobStateReason}.145* @since 1.5146*/147public boolean add(JobStateReason o) {148if (o == null) {149throw new NullPointerException();150}151return super.add ((JobStateReason) o);152}153154/**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 class161* {@link java.lang.Class java.lang.Class}.162*/163public final Class<? extends Attribute> getCategory() {164return JobStateReasons.class;165}166167/**168* Get the name of the category of which this attribute value is an169* instance.170* <P>171* For class JobStateReasons, the category172* name is <CODE>"job-state-reasons"</CODE>.173*174* @return Attribute category name.175*/176public final String getName() {177return "job-state-reasons";178}179180}181182183