Save This Page
Home » openjdk-7 » javax » print » attribute » standard » [javadoc | source]
    1   /*
    2    * Copyright 2000-2006 Sun Microsystems, Inc.  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.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any 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()</CODE> method gives
   63    * the IPP keyword value. The category name returned by <CODE>getName()</CODE>
   64    * gives the IPP attribute name.
   65    * <P>
   66    *
   67    * @author  Alan Kaminsky
   68    */
   69   public final class JobStateReasons
   70       extends HashSet<JobStateReason> implements PrintJobAttribute {
   71   
   72       private static final long serialVersionUID = 8849088261264331812L;
   73   
   74       /**
   75        * Construct a new, empty job state reasons attribute; the underlying hash
   76        * set has the default initial capacity and load factor.
   77        */
   78       public JobStateReasons() {
   79           super();
   80       }
   81   
   82       /**
   83        * Construct a new, empty job state reasons attribute; the underlying hash
   84        * set has the given initial capacity and the default load factor.
   85        *
   86        * @param  initialCapacity  Initial capacity.
   87        * @throws IllegalArgumentException if the initial capacity is less
   88        *     than zero.
   89        */
   90       public JobStateReasons(int initialCapacity) {
   91           super (initialCapacity);
   92       }
   93   
   94       /**
   95        * Construct a new, empty job state reasons attribute; the underlying hash
   96        * set has the given initial capacity and load factor.
   97        *
   98        * @param  initialCapacity  Initial capacity.
   99        * @param  loadFactor       Load factor.
  100        * @throws IllegalArgumentException if the initial capacity is less
  101        *     than zero.
  102        */
  103       public JobStateReasons(int initialCapacity, float loadFactor) {
  104           super (initialCapacity, loadFactor);
  105       }
  106   
  107       /**
  108        * Construct a new job state reasons attribute that contains the same
  109        * {@link JobStateReason JobStateReason} objects as the given collection.
  110        * The underlying hash set's initial capacity and load factor are as
  111        * specified in the superclass constructor {@link
  112        * java.util.HashSet#HashSet(java.util.Collection)
  113        * <CODE>HashSet(Collection)</CODE>}.
  114        *
  115        * @param  collection  Collection to copy.
  116        *
  117        * @exception  NullPointerException
  118        *     (unchecked exception) Thrown if <CODE>collection</CODE> is null or
  119        *     if any element in <CODE>collection</CODE> is null.
  120        * @throws  ClassCastException
  121        *     (unchecked exception) Thrown if any element in
  122        *     <CODE>collection</CODE> is not an instance of class {@link
  123        *     JobStateReason JobStateReason}.
  124        */
  125      public JobStateReasons(Collection<JobStateReason> collection) {
  126          super (collection);
  127      }
  128   
  129       /**
  130        * Adds the specified element to this job state reasons attribute if it is
  131        * not already present. The element to be added must be an instance of class
  132        * {@link JobStateReason JobStateReason}. If this job state reasons
  133        * attribute already contains the specified element, the call leaves this
  134        * job state reasons attribute unchanged and returns <tt>false</tt>.
  135        *
  136        * @param  o  Element to be added to this job state reasons attribute.
  137        *
  138        * @return  <tt>true</tt> if this job state reasons attribute did not
  139        *          already contain the specified element.
  140        *
  141        * @throws  NullPointerException
  142        *     (unchecked exception) Thrown if the specified element is null.
  143        * @throws  ClassCastException
  144        *     (unchecked exception) Thrown if the specified element is not an
  145        *     instance of class {@link JobStateReason JobStateReason}.
  146        * @since 1.5
  147        */
  148       public boolean add(JobStateReason o) {
  149           if (o == null) {
  150               throw new NullPointerException();
  151           }
  152           return super.add ((JobStateReason) o);
  153       }
  154   
  155       /**
  156        * Get the printing attribute class which is to be used as the "category"
  157        * for this printing attribute value.
  158        * <P>
  159        * For class JobStateReasons, the category is class JobStateReasons itself.
  160        *
  161        * @return  Printing attribute class (category), an instance of class
  162        *          {@link java.lang.Class java.lang.Class}.
  163        */
  164       public final Class<? extends Attribute> getCategory() {
  165           return JobStateReasons.class;
  166       }
  167   
  168       /**
  169        * Get the name of the category of which this attribute value is an
  170        * instance.
  171        * <P>
  172        * For class JobStateReasons, the category
  173        * name is <CODE>"job-state-reasons"</CODE>.
  174        *
  175        * @return  Attribute category name.
  176        */
  177       public final String getName() {
  178           return "job-state-reasons";
  179       }
  180   
  181   }

Save This Page
Home » openjdk-7 » javax » print » attribute » standard » [javadoc | source]