Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java
41171 views
1
/*
2
* Copyright (c) 2000, 2021, 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
26
package javax.print.attribute.standard;
27
28
import java.io.Serial;
29
30
import javax.print.attribute.Attribute;
31
import javax.print.attribute.IntegerSyntax;
32
import javax.print.attribute.PrintJobAttribute;
33
import javax.print.attribute.PrintRequestAttribute;
34
35
/**
36
* Class {@code JobKOctets} is an integer valued printing attribute class that
37
* specifies the total size of the document(s) in K octets, i.e., in units of
38
* 1024 octets requested to be processed in the job. The value must be rounded
39
* up, so that a job between 1 and 1024 octets must be indicated as being 1K
40
* octets, 1025 to 2048 must be 2K octets, etc. For a multidoc print job (a job
41
* with multiple documents), the {@code JobKOctets} value is computed by adding
42
* up the individual documents' sizes in octets, then rounding up to the next K
43
* octets value.
44
* <p>
45
* The {@code JobKOctets} attribute describes the size of the job. This
46
* attribute is not intended to be a counter; it is intended to be useful
47
* routing and scheduling information if known. The printer may try to compute
48
* the {@code JobKOctets} attribute's value if it is not supplied in the Print
49
* Request. Even if the client does supply a value for the {@code JobKOctets}
50
* attribute in the Print Request, the printer may choose to change the value if
51
* the printer is able to compute a value which is more accurate than the client
52
* supplied value. The printer may be able to determine the correct value for
53
* the {@code JobKOctets} attribute either right at job submission time or at
54
* any later point in time.
55
* <p>
56
* The {@code JobKOctets} value must not include the multiplicative factors
57
* contributed by the number of copies specified by the {@link Copies Copies}
58
* attribute, independent of whether the device can process multiple copies
59
* without making multiple passes over the job or document data and independent
60
* of whether the output is collated or not. Thus the value is independent of
61
* the implementation and indicates the size of the document(s) measured in K
62
* octets independent of the number of copies.
63
* <p>
64
* The {@code JobKOctets} value must also not include the multiplicative factor
65
* due to a copies instruction embedded in the document data. If the document
66
* data actually includes replications of the document data, this value will
67
* include such replication. In other words, this value is always the size of
68
* the source document data, rather than a measure of the hardcopy output to be
69
* produced.
70
* <p>
71
* The size of a doc is computed based on the print data representation class as
72
* specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as shown in
73
* the table below.
74
*
75
* <table class="striped">
76
* <caption>Table showing computation of doc sizes</caption>
77
* <thead>
78
* <tr>
79
* <th scope="col">Representation Class
80
* <th scope="col">Document Size
81
* </thead>
82
* <tbody>
83
* <tr>
84
* <th scope="row">{@code byte[]}
85
* <td>Length of the byte array
86
* <tr>
87
* <th scope="row">{@code java.io.InputStream}
88
* <td>Number of bytes read from the stream
89
* <tr>
90
* <th scope="row">{@code char[]}
91
* <td>Length of the character array x 2
92
* <tr>
93
* <th scope="row">{@code java.lang.String}
94
* <td>Length of the string x 2
95
* <tr>
96
* <th scope="row">{@code java.io.Reader}
97
* <td>Number of characters read from the stream x 2
98
* <tr>
99
* <th scope="row">{@code java.net.URL}
100
* <td>Number of bytes read from the file at the given {@code URL} address
101
* <tr>
102
* <th scope="row">{@code java.awt.image.renderable.RenderableImage}
103
* <td>Implementation dependent&#42;
104
* <tr>
105
* <th scope="row">{@code java.awt.print.Printable}
106
* <td>Implementation dependent&#42;
107
* <tr>
108
* <th scope="row">{@code java.awt.print.Pageable}
109
* <td>Implementation dependent&#42;
110
* </tbody>
111
* </table>
112
* <p>
113
* &#42; In these cases the Print Service itself generates the print data sent
114
* to the printer. If the Print Service supports the {@code JobKOctets}
115
* attribute, for these cases the Print Service itself must calculate the size
116
* of the print data, replacing any {@code JobKOctets} value the client
117
* specified.
118
* <p>
119
* <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The
120
* category name returned by {@code getName()} gives the IPP attribute name.
121
*
122
* @author Alan Kaminsky
123
* @see JobKOctetsSupported
124
* @see JobKOctetsProcessed
125
* @see JobImpressions
126
* @see JobMediaSheets
127
*/
128
public final class JobKOctets extends IntegerSyntax
129
implements PrintRequestAttribute, PrintJobAttribute {
130
131
/**
132
* Use serialVersionUID from JDK 1.4 for interoperability.
133
*/
134
@Serial
135
private static final long serialVersionUID = -8959710146498202869L;
136
137
/**
138
* Construct a new job K octets attribute with the given integer value.
139
*
140
* @param value Integer value
141
* @throws IllegalArgumentException if {@code value} is negative
142
*/
143
public JobKOctets(int value) {
144
super (value, 0, Integer.MAX_VALUE);
145
}
146
147
/**
148
* Returns whether this job K octets attribute is equivalent to the passed
149
* in object. To be equivalent, all of the following conditions must be
150
* true:
151
* <ol type=1>
152
* <li>{@code object} is not {@code null}.
153
* <li>{@code object} is an instance of class {@code JobKOctets}.
154
* <li>This job K octets attribute's value and {@code object}'s value are
155
* equal.
156
* </ol>
157
*
158
* @param object {@code Object} to compare to
159
* @return {@code true} if {@code object} is equivalent to this job K octets
160
* attribute, {@code false} otherwise
161
*/
162
public boolean equals(Object object) {
163
return super.equals(object) && object instanceof JobKOctets;
164
}
165
166
/**
167
* Get the printing attribute class which is to be used as the "category"
168
* for this printing attribute value.
169
* <p>
170
* For class {@code JobKOctets}, the category is class
171
* {@code JobKOctets} itself.
172
*
173
* @return printing attribute class (category), an instance of class
174
* {@link Class java.lang.Class}
175
*/
176
public final Class<? extends Attribute> getCategory() {
177
return JobKOctets.class;
178
}
179
180
/**
181
* Get the name of the category of which this attribute value is an
182
* instance.
183
* <p>
184
* For class {@code JobKOctets}, the category name is
185
* {@code "job-k-octets"}.
186
*
187
* @return attribute category name
188
*/
189
public final String getName() {
190
return "job-k-octets";
191
}
192
}
193
194