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. import javax.print.attribute.Attribute;
  9. import javax.print.attribute.IntegerSyntax;
  10. import javax.print.attribute.PrintRequestAttribute;
  11. import javax.print.attribute.PrintJobAttribute;
  12. /**
  13. * Class JobKOctets is an integer valued printing attribute class that specifies
  14. * the total size of the document(s) in K octets, i.e., in units of 1024 octets
  15. * requested to be processed in the job. The value must be rounded up, so that a
  16. * job between 1 and 1024 octets must be indicated as being 1K octets, 1025 to
  17. * 2048 must be 2K octets, etc. For a multidoc print job (a job with multiple
  18. * documents), the JobKOctets value is computed by adding up the individual
  19. * documents' sizes in octets, then rounding up to the next K octets value.
  20. * <P>
  21. * The JobKOctets attribute describes the size of the job. This attribute is not
  22. * intended to be a counter; it is intended to be useful routing and scheduling
  23. * information if known. The printer may try to compute the JobKOctets
  24. * attribute's value if it is not supplied in the Print Request. Even if the
  25. * client does supply a value for the JobKOctets attribute in the Print Request,
  26. * the printer may choose to change the value if the printer is able to compute
  27. * a value which is more accurate than the client supplied value. The printer
  28. * may be able to determine the correct value for the JobKOctets attribute
  29. * either right at job submission time or at any later point in time.
  30. * <P>
  31. * The JobKOctets value must not include the multiplicative factors contributed
  32. * by the number of copies specified by the {@link Copies Copies} attribute,
  33. * independent of whether the device can process multiple copies without making
  34. * multiple passes over the job or document data and independent of whether the
  35. * output is collated or not. Thus the value is independent of the
  36. * implementation and indicates the size of the document(s) measured in K octets
  37. * independent of the number of copies.
  38. * <P>
  39. * The JobKOctets value must also not include the multiplicative factor due to a
  40. * copies instruction embedded in the document data. If the document data
  41. * actually includes replications of the document data, this value will include
  42. * such replication. In other words, this value is always the size of the source
  43. * document data, rather than a measure of the hardcopy output to be produced.
  44. * <P>
  45. * The size of a doc is computed based on the print data representation class as
  46. * specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as
  47. * shown in the table below.
  48. * <P>
  49. * <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=1 SUMMARY="Table showing computation of doc sizes">
  50. * <TR BGCOLOR="#E5E5E5">
  51. * <TH>Representation Class</TH>
  52. * <TH>Document Size</TH>
  53. * </TR>
  54. * <TR>
  55. * <TD>byte[]</TD>
  56. * <TD>Length of the byte array</TD>
  57. * </TR>
  58. * <TR>
  59. * <TD>java.io.InputStream</TD>
  60. * <TD>Number of bytes read from the stream</TD>
  61. * </TR>
  62. * <TR>
  63. * <TD>char[]</TD>
  64. * <TD>Length of the character array x 2</TD>
  65. * </TR>
  66. * <TR>
  67. * <TD>java.lang.String</TD>
  68. * <TD>Length of the string x 2</TD>
  69. * </TR>
  70. * <TR>
  71. * <TD>java.io.Reader</TD>
  72. * <TD>Number of characters read from the stream x 2</TD>
  73. * </TR>
  74. * <TR>
  75. * <TD>java.net.URL</TD>
  76. * <TD>Number of bytes read from the file at the given URL address</TD>
  77. * </TR>
  78. * <TR>
  79. * <TD>java.awt.image.renderable.RenderableImage</TD>
  80. * <TD>Implementation dependent*</TD>
  81. * </TR>
  82. * <TR>
  83. * <TD>java.awt.print.Printable</TD>
  84. * <TD>Implementation dependent*</TD>
  85. * </TR>
  86. * <TR>
  87. * <TD>java.awt.print.Pageable</TD>
  88. * <TD>Implementation dependent*</TD>
  89. * </TR>
  90. * </TABLE>
  91. * <P>
  92. * * In these cases the Print Service itself generates the print data sent
  93. * to the printer. If the Print Service supports the JobKOctets attribute, for
  94. * these cases the Print Service itself must calculate the size of the print
  95. * data, replacing any JobKOctets value the client specified.
  96. * <P>
  97. * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
  98. * category name returned by <CODE>getName()</CODE> gives the IPP attribute
  99. * name.
  100. * <P>
  101. *
  102. * @see JobKOctetsSupported
  103. * @see JobKOctetsProcessed
  104. * @see JobImpressions
  105. * @see JobMediaSheets
  106. *
  107. * @author Alan Kaminsky
  108. */
  109. public final class JobKOctets extends IntegerSyntax
  110. implements PrintRequestAttribute, PrintJobAttribute {
  111. private static final long serialVersionUID = -8959710146498202869L;
  112. /**
  113. * Construct a new job K octets attribute with the given integer value.
  114. *
  115. * @param value Integer value.
  116. *
  117. * @exception IllegalArgumentException
  118. * (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
  119. */
  120. public JobKOctets(int value) {
  121. super (value, 0, Integer.MAX_VALUE);
  122. }
  123. /**
  124. * Returns whether this job K octets attribute is equivalent to the passed
  125. * in object. To be equivalent, all of the following conditions must be
  126. * true:
  127. * <OL TYPE=1>
  128. * <LI>
  129. * <CODE>object</CODE> is not null.
  130. * <LI>
  131. * <CODE>object</CODE> is an instance of class JobKOctets.
  132. * <LI>
  133. * This job K octets attribute's value and <CODE>object</CODE>'s value
  134. * are equal.
  135. * </OL>
  136. *
  137. * @param object Object to compare to.
  138. *
  139. * @return True if <CODE>object</CODE> is equivalent to this job K
  140. * octets attribute, false otherwise.
  141. */
  142. public boolean equals(Object object) {
  143. return super.equals(object) && object instanceof JobKOctets;
  144. }
  145. /**
  146. * Get the printing attribute class which is to be used as the "category"
  147. * for this printing attribute value.
  148. * <P>
  149. * For class JobKOctets, the category is class JobKOctets itself.
  150. *
  151. * @return Printing attribute class (category), an instance of class
  152. * {@link java.lang.Class java.lang.Class}.
  153. */
  154. public final Class<? extends Attribute> getCategory() {
  155. return JobKOctets.class;
  156. }
  157. /**
  158. * Get the name of the category of which this attribute value is an
  159. * instance.
  160. * <P>
  161. * For class JobKOctets, the category name is <CODE>"job-k-octets"</CODE>.
  162. *
  163. * @return Attribute category name.
  164. */
  165. public final String getName() {
  166. return "job-k-octets";
  167. }
  168. }