001 /*
002 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.print.attribute.standard;
026
027 import javax.print.attribute.Attribute;
028 import javax.print.attribute.IntegerSyntax;
029 import javax.print.attribute.PrintJobAttribute;
030
031 /**
032 * Class NumberOfDocuments is an integer valued printing attribute that
033 * indicates the number of individual docs the printer has accepted for this
034 * job, regardless of whether the docs' print data has reached the printer or
035 * not.
036 * <P>
037 * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
038 * category name returned by <CODE>getName()</CODE> gives the IPP attribute
039 * name.
040 * <P>
041 *
042 * @author Alan Kaminsky
043 */
044 public final class NumberOfDocuments extends IntegerSyntax implements
045 PrintJobAttribute {
046
047 private static final long serialVersionUID = 7891881310684461097L;
048
049 /**
050 * Construct a new number of documents attribute with the given integer
051 * value.
052 *
053 * @param value Integer value.
054 *
055 * @exception IllegalArgumentException
056 * (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
057 */
058 public NumberOfDocuments(int value) {
059 super (value, 0, Integer.MAX_VALUE);
060 }
061
062 /**
063 * Returns whether this number of documents attribute is equivalent to the
064 * passed in object. To be equivalent, all of the following conditions
065 * must be true:
066 * <OL TYPE=1>
067 * <LI>
068 * <CODE>object</CODE> is not null.
069 * <LI>
070 * <CODE>object</CODE> is an instance of class NumberOfDocuments.
071 * <LI>
072 * This number of documents attribute's value and <CODE>object</CODE>'s
073 * value are equal.
074 * </OL>
075 *
076 * @param object Object to compare to.
077 *
078 * @return True if <CODE>object</CODE> is equivalent to this number of
079 * documents attribute, false otherwise.
080 */
081 public boolean equals(Object object) {
082 return (super .equals(object) && object instanceof NumberOfDocuments);
083 }
084
085 /**
086 * Get the printing attribute class which is to be used as the "category"
087 * for this printing attribute value.
088 * <P>
089 * For class NumberOfDocuments, the
090 * category is class NumberOfDocuments itself.
091 *
092 * @return Printing attribute class (category), an instance of class
093 * {@link java.lang.Class java.lang.Class}.
094 */
095 public final Class<? extends Attribute> getCategory() {
096 return NumberOfDocuments.class;
097 }
098
099 /**
100 * Get the name of the category of which this attribute value is an
101 * instance.
102 * <P>
103 * For class NumberOfDocuments, the
104 * category name is <CODE>"number-of-documents"</CODE>.
105 *
106 * @return Attribute category name.
107 */
108 public final String getName() {
109 return "number-of-documents";
110 }
111
112 }
|