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 JobMediaSheets is an integer valued printing attribute class that
  34  * specifies the total number of media sheets to be produced for this job.
  35  * <P>
  36  * The JobMediaSheets attribute describes the size of the job. This attribute is
  37  * not intended to be a counter; it is intended to be useful routing and
  38  * scheduling information if known. The printer may try to compute the
  39  * JobMediaSheets attribute's value if it is not supplied in the Print Request.
  40  * Even if the client does supply a value for the JobMediaSheets attribute in
  41  * the Print Request, the printer may choose to change the value if the printer
  42  * is able to compute a value which is more accurate than the client supplied
  43  * value. The printer may be able to determine the correct value for the
  44  * JobMediaSheets attribute either right at job submission time or at any later
  45  * point in time.
  46  * <P>
  47  * Unlike the {@link JobKOctets JobKOctets} and {@link JobImpressions
  48  * JobImpressions} attributes, the JobMediaSheets value must include the
  49  * multiplicative factors contributed by the number of copies specified by the
  50  * {@link Copies Copies} attribute and a "number of copies" instruction embedded
  51  * in the document data, if any. This difference allows the system administrator
  52  * to control the lower and upper bounds of both (1) the size of the document(s)
  53  * with {@link JobKOctetsSupported JobKOctetsSupported} and {@link
  54  * JobImpressionsSupported JobImpressionsSupported} and (2) the size of the job
  55  * with {@link JobMediaSheetsSupported JobMediaSheetsSupported}.
  56  * <P>
  57  * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
  58  * category name returned by <CODE>getName()</CODE> gives the IPP attribute
  59  * name.
  60  * <P>
  61  *
  62  * @see JobMediaSheetsSupported
  63  * @see JobMediaSheetsCompleted
  64  * @see JobKOctets
  65  * @see JobImpressions
  66  *
  67  * @author  Alan Kaminsky
  68  */
  69 public class JobMediaSheets extends IntegerSyntax
  70         implements PrintRequestAttribute, PrintJobAttribute {
  71 
  72 
  73     private static final long serialVersionUID = 408871131531979741L;
  74 
  75     /**
  76      * Construct a new job media sheets attribute with the given integer
  77      * value.
  78      *
  79      * @param  value  Integer value.
  80      *
  81      * @exception  IllegalArgumentException
  82      *   (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
  83      */
  84     public JobMediaSheets(int value) {
  85         super (value, 0, Integer.MAX_VALUE);
  86     }
  87 
  88     /**
  89      * Returns whether this job media sheets attribute is equivalent to the
  90      * passed in object. To be equivalent, all of the following conditions must
  91      * 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 JobMediaSheets.
  97      * <LI>
  98      * This job media sheets attribute's value and <CODE>object</CODE>'s
  99      * value are equal.
 100      * </OL>
 101      *
 102      * @param  object  Object to compare to.
 103      *
 104      * @return  True if <CODE>object</CODE> is equivalent to this job media
 105      *          sheets attribute, false otherwise.
 106      */
 107     public boolean equals(Object object) {
 108         return super.equals(object) && object instanceof JobMediaSheets;
 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 JobMediaSheets and any vendor-defined subclasses, the category
 116      * is class JobMediaSheets itself.
 117      *
 118      * @return  Printing attribute class (category), an instance of class
 119      *          {@link java.lang.Class java.lang.Class}.
 120      */
 121     public final Class<? extends Attribute> getCategory() {
 122         return JobMediaSheets.class;
 123     }
 124 
 125     /**
 126      * Get the name of the category of which this attribute value is an
 127      * instance.
 128      * <P>
 129      * For class JobMediaSheets and any vendor-defined subclasses, the
 130      * category name is <CODE>"job-media-sheets"</CODE>.
 131      *
 132      * @return  Attribute category name.
 133      */
 134     public final String getName() {
 135         return "job-media-sheets";
 136     }
 137 
 138 }