KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > attribute > standard > JobKOctets


1 /*
2  * @(#)JobKOctets.java 1.8 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.print.attribute.standard;
8
9 import javax.print.attribute.Attribute JavaDoc;
10 import javax.print.attribute.IntegerSyntax JavaDoc;
11 import javax.print.attribute.PrintRequestAttribute JavaDoc;
12 import javax.print.attribute.PrintJobAttribute JavaDoc;
13
14 /**
15  * Class JobKOctets is an integer valued printing attribute class that specifies
16  * the total size of the document(s) in K octets, i.e., in units of 1024 octets
17  * requested to be processed in the job. The value must be rounded up, so that a
18  * job between 1 and 1024 octets must be indicated as being 1K octets, 1025 to
19  * 2048 must be 2K octets, etc. For a multidoc print job (a job with multiple
20  * documents), the JobKOctets value is computed by adding up the individual
21  * documents' sizes in octets, then rounding up to the next K octets value.
22  * <P>
23  * The JobKOctets attribute describes the size of the job. This attribute is not
24  * intended to be a counter; it is intended to be useful routing and scheduling
25  * information if known. The printer may try to compute the JobKOctets
26  * attribute's value if it is not supplied in the Print Request. Even if the
27  * client does supply a value for the JobKOctets attribute in the Print Request,
28  * the printer may choose to change the value if the printer is able to compute
29  * a value which is more accurate than the client supplied value. The printer
30  * may be able to determine the correct value for the JobKOctets attribute
31  * either right at job submission time or at any later point in time.
32  * <P>
33  * The JobKOctets value must not include the multiplicative factors contributed
34  * by the number of copies specified by the {@link Copies Copies} attribute,
35  * independent of whether the device can process multiple copies without making
36  * multiple passes over the job or document data and independent of whether the
37  * output is collated or not. Thus the value is independent of the
38  * implementation and indicates the size of the document(s) measured in K octets
39  * independent of the number of copies.
40  * <P>
41  * The JobKOctets value must also not include the multiplicative factor due to a
42  * copies instruction embedded in the document data. If the document data
43  * actually includes replications of the document data, this value will include
44  * such replication. In other words, this value is always the size of the source
45  * document data, rather than a measure of the hardcopy output to be produced.
46  * <P>
47  * The size of a doc is computed based on the print data representation class as
48  * specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as
49  * shown in the table below.
50  * <P>
51  * <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=1 SUMMARY="Table showing computation of doc sizes">
52  * <TR BGCOLOR="#E5E5E5">
53  * <TH>Representation Class</TH>
54  * <TH>Document Size</TH>
55  * </TR>
56  * <TR>
57  * <TD>byte[]</TD>
58  * <TD>Length of the byte array</TD>
59  * </TR>
60  * <TR>
61  * <TD>java.io.InputStream</TD>
62  * <TD>Number of bytes read from the stream</TD>
63  * </TR>
64  * <TR>
65  * <TD>char[]</TD>
66  * <TD>Length of the character array x 2</TD>
67  * </TR>
68  * <TR>
69  * <TD>java.lang.String</TD>
70  * <TD>Length of the string x 2</TD>
71  * </TR>
72  * <TR>
73  * <TD>java.io.Reader</TD>
74  * <TD>Number of characters read from the stream x 2</TD>
75  * </TR>
76  * <TR>
77  * <TD>java.net.URL</TD>
78  * <TD>Number of bytes read from the file at the given URL address</TD>
79  * </TR>
80  * <TR>
81  * <TD>java.awt.image.renderable.RenderableImage</TD>
82  * <TD>Implementation dependent&#42;</TD>
83  * </TR>
84  * <TR>
85  * <TD>java.awt.print.Printable</TD>
86  * <TD>Implementation dependent&#42;</TD>
87  * </TR>
88  * <TR>
89  * <TD>java.awt.print.Pageable</TD>
90  * <TD>Implementation dependent&#42;</TD>
91  * </TR>
92  * </TABLE>
93  * <P>
94  * &#42; In these cases the Print Service itself generates the print data sent
95  * to the printer. If the Print Service supports the JobKOctets attribute, for
96  * these cases the Print Service itself must calculate the size of the print
97  * data, replacing any JobKOctets value the client specified.
98  * <P>
99  * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
100  * category name returned by <CODE>getName()</CODE> gives the IPP attribute
101  * name.
102  * <P>
103  *
104  * @see JobKOctetsSupported
105  * @see JobKOctetsProcessed
106  * @see JobImpressions
107  * @see JobMediaSheets
108  *
109  * @author Alan Kaminsky
110  */

111 public final class JobKOctets extends IntegerSyntax JavaDoc
112     implements PrintRequestAttribute JavaDoc, PrintJobAttribute JavaDoc {
113
114     private static final long serialVersionUID = -8959710146498202869L;
115
116     /**
117      * Construct a new job K octets attribute with the given integer value.
118      *
119      * @param value Integer value.
120      *
121      * @exception IllegalArgumentException
122      * (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
123      */

124     public JobKOctets(int value) {
125     super (value, 0, Integer.MAX_VALUE);
126     }
127
128     /**
129      * Returns whether this job K octets attribute is equivalent to the passed
130      * in object. To be equivalent, all of the following conditions must be
131      * true:
132      * <OL TYPE=1>
133      * <LI>
134      * <CODE>object</CODE> is not null.
135      * <LI>
136      * <CODE>object</CODE> is an instance of class JobKOctets.
137      * <LI>
138      * This job K octets attribute's value and <CODE>object</CODE>'s value
139      * are equal.
140      * </OL>
141      *
142      * @param object Object to compare to.
143      *
144      * @return True if <CODE>object</CODE> is equivalent to this job K
145      * octets attribute, false otherwise.
146      */

147     public boolean equals(Object JavaDoc object) {
148     return super.equals(object) && object instanceof JobKOctets JavaDoc;
149     }
150
151     /**
152      * Get the printing attribute class which is to be used as the "category"
153      * for this printing attribute value.
154      * <P>
155      * For class JobKOctets, the category is class JobKOctets itself.
156      *
157      * @return Printing attribute class (category), an instance of class
158      * {@link java.lang.Class java.lang.Class}.
159      */

160     public final Class JavaDoc<? extends Attribute JavaDoc> getCategory() {
161     return JobKOctets JavaDoc.class;
162     }
163     
164     /**
165      * Get the name of the category of which this attribute value is an
166      * instance.
167      * <P>
168      * For class JobKOctets, the category name is <CODE>"job-k-octets"</CODE>.
169      *
170      * @return Attribute category name.
171      */

172     public final String JavaDoc getName() {
173     return "job-k-octets";
174     }
175
176 }
177
Popular Tags