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 JobKOctetsProcessed is an integer valued printing attribute class that
033 * specifies the total number of print data octets processed so far in K octets,
034 * i.e., in units of 1024 octets. The value must be rounded up, so that a job
035 * between 1 and 1024 octets inclusive must be indicated as being 1K octets,
036 * 1025 to 2048 inclusive must be 2K, etc. For a multidoc print job (a job with
037 * multiple documents), the JobKOctetsProcessed value is computed by adding up
038 * the individual documents' number of octets processed so far, then rounding up
039 * to the next K octets value.
040 * <P>
041 * The JobKOctetsProcessed attribute describes the progress of the job. This
042 * attribute is intended to be a counter. That is, the JobKOctetsProcessed value
043 * for a job that has not started processing must be 0. When the job's {@link
044 * JobState JobState} is PROCESSING or PROCESSING_STOPPED, the
045 * JobKOctetsProcessed value is intended to increase as the job is processed; it
046 * indicates the amount of the job that has been processed at the time the Print
047 * Job's attribute set is queried or at the time a print job event is reported.
048 * When the job enters the COMPLETED, CANCELED, or ABORTED states, the
049 * JobKOctetsProcessed value is the final value for the job.
050 * <P>
051 * For implementations where multiple copies are produced by the interpreter
052 * with only a single pass over the data, the final value of the
053 * JobKOctetsProcessed attribute must be equal to the value of the {@link
054 * JobKOctets JobKOctets} attribute. For implementations where multiple copies
055 * are produced by the interpreter by processing the data for each copy, the
056 * final value must be a multiple of the value of the {@link JobKOctets
057 * JobKOctets} attribute.
058 * <P>
059 * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
060 * category name returned by <CODE>getName()</CODE> gives the IPP attribute
061 * name.
062 * <P>
063 *
064 * @see JobKOctets
065 * @see JobKOctetsSupported
066 * @see JobImpressionsCompleted
067 * @see JobMediaSheetsCompleted
068 *
069 * @author Alan Kaminsky
070 */
071 public final class JobKOctetsProcessed extends IntegerSyntax implements
072 PrintJobAttribute {
073
074 private static final long serialVersionUID = -6265238509657881806L;
075
076 /**
077 * Construct a new job K octets processed attribute with the given integer
078 * value.
079 *
080 * @param value Integer value.
081 *
082 * @exception IllegalArgumentException
083 * (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
084 */
085 public JobKOctetsProcessed(int value) {
086 super (value, 0, Integer.MAX_VALUE);
087 }
088
089 /**
090 * Returns whether this job K octets processed attribute is equivalent to
091 * the passed in object. To be equivalent, all of the following conditions
092 * must be true:
093 * <OL TYPE=1>
094 * <LI>
095 * <CODE>object</CODE> is not null.
096 * <LI>
097 * <CODE>object</CODE> is an instance of class JobKOctetsProcessed.
098 * <LI>
099 * This job K octets processed attribute's value and
100 * <CODE>object</CODE>'s value are equal.
101 * </OL>
102 *
103 * @param object Object to compare to.
104 *
105 * @return True if <CODE>object</CODE> is equivalent to this job K
106 * octets processed attribute, false otherwise.
107 */
108 public boolean equals(Object object) {
109 return (super .equals(object) && object instanceof JobKOctetsProcessed);
110 }
111
112 /**
113 * Get the printing attribute class which is to be used as the "category"
114 * for this printing attribute value.
115 * <P>
116 * For class JobKOctetsProcessed, the category is class
117 * JobKOctetsProcessed itself.
118 *
119 * @return Printing attribute class (category), an instance of class
120 * {@link java.lang.Class java.lang.Class}.
121 */
122 public final Class<? extends Attribute> getCategory() {
123 return JobKOctetsProcessed.class;
124 }
125
126 /**
127 * Get the name of the category of which this attribute value is an
128 * instance.
129 * <P>
130 * For class JobKOctetsProcessed, the category name is
131 * <CODE>"job-k-octets-processed"</CODE>.
132 *
133 * @return Attribute category name.
134 */
135 public final String getName() {
136 return "job-k-octets-processed";
137 }
138
139 }
|