Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/attribute/standard/JobKOctets.java
38918 views
/*1* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package javax.print.attribute.standard;2526import javax.print.attribute.Attribute;27import javax.print.attribute.IntegerSyntax;28import javax.print.attribute.PrintRequestAttribute;29import javax.print.attribute.PrintJobAttribute;3031/**32* Class JobKOctets is an integer valued printing attribute class that specifies33* the total size of the document(s) in K octets, i.e., in units of 1024 octets34* requested to be processed in the job. The value must be rounded up, so that a35* job between 1 and 1024 octets must be indicated as being 1K octets, 1025 to36* 2048 must be 2K octets, etc. For a multidoc print job (a job with multiple37* documents), the JobKOctets value is computed by adding up the individual38* documents' sizes in octets, then rounding up to the next K octets value.39* <P>40* The JobKOctets attribute describes the size of the job. This attribute is not41* intended to be a counter; it is intended to be useful routing and scheduling42* information if known. The printer may try to compute the JobKOctets43* attribute's value if it is not supplied in the Print Request. Even if the44* client does supply a value for the JobKOctets attribute in the Print Request,45* the printer may choose to change the value if the printer is able to compute46* a value which is more accurate than the client supplied value. The printer47* may be able to determine the correct value for the JobKOctets attribute48* either right at job submission time or at any later point in time.49* <P>50* The JobKOctets value must not include the multiplicative factors contributed51* by the number of copies specified by the {@link Copies Copies} attribute,52* independent of whether the device can process multiple copies without making53* multiple passes over the job or document data and independent of whether the54* output is collated or not. Thus the value is independent of the55* implementation and indicates the size of the document(s) measured in K octets56* independent of the number of copies.57* <P>58* The JobKOctets value must also not include the multiplicative factor due to a59* copies instruction embedded in the document data. If the document data60* actually includes replications of the document data, this value will include61* such replication. In other words, this value is always the size of the source62* document data, rather than a measure of the hardcopy output to be produced.63* <P>64* The size of a doc is computed based on the print data representation class as65* specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as66* shown in the table below.67* <P>68* <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=1 SUMMARY="Table showing computation of doc sizes">69* <TR>70* <TH>Representation Class</TH>71* <TH>Document Size</TH>72* </TR>73* <TR>74* <TD>byte[]</TD>75* <TD>Length of the byte array</TD>76* </TR>77* <TR>78* <TD>java.io.InputStream</TD>79* <TD>Number of bytes read from the stream</TD>80* </TR>81* <TR>82* <TD>char[]</TD>83* <TD>Length of the character array x 2</TD>84* </TR>85* <TR>86* <TD>java.lang.String</TD>87* <TD>Length of the string x 2</TD>88* </TR>89* <TR>90* <TD>java.io.Reader</TD>91* <TD>Number of characters read from the stream x 2</TD>92* </TR>93* <TR>94* <TD>java.net.URL</TD>95* <TD>Number of bytes read from the file at the given URL address</TD>96* </TR>97* <TR>98* <TD>java.awt.image.renderable.RenderableImage</TD>99* <TD>Implementation dependent*</TD>100* </TR>101* <TR>102* <TD>java.awt.print.Printable</TD>103* <TD>Implementation dependent*</TD>104* </TR>105* <TR>106* <TD>java.awt.print.Pageable</TD>107* <TD>Implementation dependent*</TD>108* </TR>109* </TABLE>110* <P>111* * In these cases the Print Service itself generates the print data sent112* to the printer. If the Print Service supports the JobKOctets attribute, for113* these cases the Print Service itself must calculate the size of the print114* data, replacing any JobKOctets value the client specified.115* <P>116* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The117* category name returned by <CODE>getName()</CODE> gives the IPP attribute118* name.119* <P>120*121* @see JobKOctetsSupported122* @see JobKOctetsProcessed123* @see JobImpressions124* @see JobMediaSheets125*126* @author Alan Kaminsky127*/128public final class JobKOctets extends IntegerSyntax129implements PrintRequestAttribute, PrintJobAttribute {130131private static final long serialVersionUID = -8959710146498202869L;132133/**134* Construct a new job K octets attribute with the given integer value.135*136* @param value Integer value.137*138* @exception IllegalArgumentException139* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.140*/141public JobKOctets(int value) {142super (value, 0, Integer.MAX_VALUE);143}144145/**146* Returns whether this job K octets attribute is equivalent to the passed147* in object. To be equivalent, all of the following conditions must be148* true:149* <OL TYPE=1>150* <LI>151* <CODE>object</CODE> is not null.152* <LI>153* <CODE>object</CODE> is an instance of class JobKOctets.154* <LI>155* This job K octets attribute's value and <CODE>object</CODE>'s value156* are equal.157* </OL>158*159* @param object Object to compare to.160*161* @return True if <CODE>object</CODE> is equivalent to this job K162* octets attribute, false otherwise.163*/164public boolean equals(Object object) {165return super.equals(object) && object instanceof JobKOctets;166}167168/**169* Get the printing attribute class which is to be used as the "category"170* for this printing attribute value.171* <P>172* For class JobKOctets, the category is class JobKOctets itself.173*174* @return Printing attribute class (category), an instance of class175* {@link java.lang.Class java.lang.Class}.176*/177public final Class<? extends Attribute> getCategory() {178return JobKOctets.class;179}180181/**182* Get the name of the category of which this attribute value is an183* instance.184* <P>185* For class JobKOctets, the category name is <CODE>"job-k-octets"</CODE>.186*187* @return Attribute category name.188*/189public final String getName() {190return "job-k-octets";191}192193}194195196