1 /*
   2  * Copyright (c) 2000, 2004, 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 javax.print.attribute.Attribute;
  28 import javax.print.attribute.IntegerSyntax;
  29 import javax.print.attribute.PrintRequestAttribute;
  30 import javax.print.attribute.PrintJobAttribute;
  31 
  32 /**
  33  * Class Copies is an integer valued printing attribute class that specifies the
  34  * number of copies to be printed.
  35  * <P>
  36  * On many devices the supported number of collated copies will be limited by
  37  * the number of physical output bins on the device, and may be different from
  38  * the number of uncollated copies which can be supported.
  39  * <P>
  40  * The effect of a Copies attribute with a value of <I>n</I> on a multidoc print
  41  * job (a job with multiple documents) depends on the (perhaps defaulted) value
  42  * of the {@link MultipleDocumentHandling MultipleDocumentHandling} attribute:
  43  * <UL>
  44  * <LI>
  45  * SINGLE_DOCUMENT -- The result will be <I>n</I> copies of a single output
  46  * document comprising all the input docs.
  47  * <P>
  48  * <LI>
  49  * SINGLE_DOCUMENT_NEW_SHEET -- The result will be <I>n</I> copies of a single
  50  * output document comprising all the input docs, and the first impression of
  51  * each input doc will always start on a new media sheet.
  52  * <P>
  53  * <LI>
  54  * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The result will be <I>n</I> copies of
  55  * the first input document, followed by <I>n</I> copies of the second input
  56  * document, . . . followed by <I>n</I> copies of the last input document.
  57  * <P>
  58  * <LI>
  59  * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The result will be the first input
  60  * document, the second input document, . . . the last input document, the group
  61  * of documents being repeated <I>n</I> times.
  62  * </UL>
  63  * <P>
  64  * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
  65  * category name returned by <CODE>getName()</CODE> gives the IPP attribute
  66  * name.
  67  * <P>
  68  *
  69  * @author  David Mendenhall
  70  * @author  Alan Kamihensky
  71  */
  72 public final class Copies extends IntegerSyntax
  73         implements PrintRequestAttribute, PrintJobAttribute {
  74 
  75     private static final long serialVersionUID = -6426631521680023833L;
  76 
  77     /**
  78      * Construct a new copies attribute with the given integer value.
  79      *
  80      * @param  value  Integer value.
  81      *
  82      * @exception  IllegalArgumentException
  83      *  (Unchecked exception) Thrown if <CODE>value</CODE> is less than 1.
  84      */
  85     public Copies(int value) {
  86         super (value, 1, Integer.MAX_VALUE);
  87     }
  88 
  89     /**
  90      * Returns whether this copies attribute is equivalent to the passed in
  91      * object. To be equivalent, all of the following conditions must be true:
  92      * <OL TYPE=1>
  93      * <LI>
  94      * <CODE>object</CODE> is not null.
  95      * <LI>
  96      * <CODE>object</CODE> is an instance of class Copies.
  97      * <LI>
  98      * This copies attribute's value and <CODE>object</CODE>'s value are
  99      * equal.
 100      * </OL>
 101      *
 102      * @param  object  Object to compare to.
 103      *
 104      * @return  True if <CODE>object</CODE> is equivalent to this copies
 105      *          attribute, false otherwise.
 106      */
 107     public boolean equals(Object object) {
 108         return super.equals (object) && object instanceof Copies;
 109     }
 110 
 111     /**
 112      * Get the printing attribute class which is to be used as the "category"
 113      * for this printing attribute value.
 114      * <P>
 115      * For class Copies, the category is class Copies itself.
 116      *
 117      * @return  Printing attribute class (category), an instance of class
 118      *          {@link java.lang.Class java.lang.Class}.
 119      */
 120     public final Class<? extends Attribute> getCategory() {
 121         return Copies.class;
 122     }
 123 
 124     /**
 125      * Get the name of the category of which this attribute value is an
 126      * instance.
 127      * <P>
 128      * For class Copies, the category name is <CODE>"copies"</CODE>.
 129      *
 130      * @return  Attribute category name.
 131      */
 132     public final String getName() {
 133         return "copies";
 134     }
 135 
 136 }