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