1. /*
  2. * @(#)Sides.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.EnumSyntax;
  9. import javax.print.attribute.DocAttribute;
  10. import javax.print.attribute.PrintRequestAttribute;
  11. import javax.print.attribute.PrintJobAttribute;
  12. /**
  13. * Class Sides is a printing attribute class, an enumeration, that specifies
  14. * how print-stream pages are to be imposed upon the sides of an instance of a
  15. * selected medium, i.e., an impression.
  16. * <P>
  17. * The effect of a Sides attribute on a multidoc print job (a job with multiple
  18. * documents) depends on whether all the docs have the same sides values
  19. * specified or whether different docs have different sides values specified,
  20. * and on the (perhaps defaulted) value of the {@link MultipleDocumentHandling
  21. * MultipleDocumentHandling} attribute.
  22. * <UL>
  23. * <LI>
  24. * If all the docs have the same sides value <I>n</I> specified, then any value
  25. * of {@link MultipleDocumentHandling MultipleDocumentHandling} makes sense,
  26. * and the printer's processing depends on the {@link MultipleDocumentHandling
  27. * MultipleDocumentHandling} value:
  28. * <UL>
  29. * <LI>
  30. * SINGLE_DOCUMENT -- All the input docs will be combined together into one
  31. * output document. Each media sheet will consist of <I>n</I> impressions from
  32. * the output document.
  33. * <P>
  34. * <LI>
  35. * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
  36. * into one output document. Each media sheet will consist of <I>n</I>
  37. * impressions from the output document. However, the first impression of each
  38. * input doc will always start on a new media sheet; this means the last media
  39. * sheet of an input doc may have only one impression on it.
  40. * <P>
  41. * <LI>
  42. * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
  43. * Each media sheet will consist of <I>n</I> impressions from the input doc.
  44. * Since the input docs are separate, the first impression of each input doc
  45. * will always start on a new media sheet; this means the last media sheet of
  46. * an input doc may have only one impression on it.
  47. * <P>
  48. * <LI>
  49. * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
  50. * Each media sheet will consist of <I>n</I> impressions from the input doc.
  51. * Since the input docs are separate, the first impression of each input doc
  52. * will always start on a new media sheet; this means the last media sheet of
  53. * an input doc may have only one impression on it.
  54. * </UL>
  55. * <P>
  56. * <UL>
  57. * <LI>
  58. * SINGLE_DOCUMENT -- All the input docs will be combined together into one
  59. * output document. Each media sheet will consist of <I>n<SUB>i</SUB></I>
  60. * impressions from the output document, where <I>i</I> is the number of the
  61. * input doc corresponding to that point in the output document. When the next
  62. * input doc has a different sides value from the previous input doc, the first
  63. * print-stream page of the next input doc goes at the start of the next media
  64. * sheet, possibly leaving only one impression on the previous media sheet.
  65. * <P>
  66. * <LI>
  67. * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
  68. * into one output document. Each media sheet will consist of <I>n</I>
  69. * impressions from the output document. However, the first impression of each
  70. * input doc will always start on a new media sheet; this means the last
  71. * impression of an input doc may have only one impression on it.
  72. * <P>
  73. * <LI>
  74. * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
  75. * For input doc <I>i,</I> each media sheet will consist of <I>n<SUB>i</SUB></I>
  76. * impressions from the input doc. Since the input docs are separate, the first
  77. * impression of each input doc will always start on a new media sheet; this
  78. * means the last media sheet of an input doc may have only one impression on
  79. * it.
  80. * <P>
  81. * <LI>
  82. * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
  83. * For input doc <I>i,</I> each media sheet will consist of <I>n<SUB>i</SUB></I>
  84. * impressions from the input doc. Since the input docs are separate, the first
  85. * impression of each input doc will always start on a new media sheet; this
  86. * means the last media sheet of an input doc may have only one impression on
  87. * it.
  88. * </UL>
  89. * </UL>
  90. * <P>
  91. * <B>IPP Compatibility:</B> The category name returned by
  92. * <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
  93. * integer value is the IPP enum value. The <code>toString()</code> method
  94. * returns the IPP string representation of the attribute value.
  95. * <P>
  96. *
  97. * @author Alan Kaminsky
  98. */
  99. public final class Sides extends EnumSyntax
  100. implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
  101. /**
  102. * Imposes each consecutive print-stream page upon the same side of
  103. * consecutive media sheets.
  104. */
  105. public static final Sides ONE_SIDED = new Sides(0);
  106. /**
  107. * Imposes each consecutive pair of print-stream pages upon front and back
  108. * sides of consecutive media sheets, such that the orientation of each
  109. * pair of print-stream pages on the medium would be correct for the
  110. * reader as if for binding on the long edge. This imposition is also
  111. * known as "duplex" (see {@link #DUPLEX <CODE>DUPLEX</CODE>}).
  112. */
  113. public static final Sides TWO_SIDED_LONG_EDGE = new Sides(1);
  114. /**
  115. * Imposes each consecutive pair of print-stream pages upon front and back
  116. * sides of consecutive media sheets, such that the orientation of each
  117. * pair of print-stream pages on the medium would be correct for the
  118. * reader as if for binding on the short edge. This imposition is also
  119. * known as "tumble" (see {@link #TUMBLE <CODE>TUMBLE</CODE>}).
  120. */
  121. public static final Sides TWO_SIDED_SHORT_EDGE = new Sides(2);
  122. /**
  123. * An alias for "two sided long edge" (see {@link #TWO_SIDED_LONG_EDGE
  124. * <CODE>TWO_SIDED_LONG_EDGE</CODE>}).
  125. */
  126. public static final Sides DUPLEX = TWO_SIDED_LONG_EDGE;
  127. /**
  128. * An alias for "two sided short edge" (see {@link #TWO_SIDED_SHORT_EDGE
  129. * <CODE>TWO_SIDED_SHORT_EDGE</CODE>}).
  130. */
  131. public static final Sides TUMBLE = TWO_SIDED_SHORT_EDGE;
  132. /**
  133. * Construct a new sides enumeration value with the given integer value.
  134. *
  135. * @param value Integer value.
  136. */
  137. protected Sides(int value) {
  138. super (value);
  139. }
  140. private static final String[] myStringTable = {
  141. "one-sided",
  142. "two-sided-long-edge",
  143. "two-sided-short-edge"
  144. };
  145. private static final Sides[] myEnumValueTable = {
  146. ONE_SIDED,
  147. TWO_SIDED_LONG_EDGE,
  148. TWO_SIDED_SHORT_EDGE
  149. };
  150. /**
  151. * Returns the string table for class Sides.
  152. */
  153. protected String[] getStringTable() {
  154. return myStringTable;
  155. }
  156. /**
  157. * Returns the enumeration value table for class Sides.
  158. */
  159. protected EnumSyntax[] getEnumValueTable() {
  160. return myEnumValueTable;
  161. }
  162. /**
  163. * Get the printing attribute class which is to be used as the "category"
  164. * for this printing attribute value.
  165. * <P>
  166. * For class Sides, the category is class Sides itself.
  167. *
  168. * @return Printing attribute class (category), an instance of class
  169. * {@link java.lang.Class java.lang.Class}.
  170. */
  171. public final Class getCategory() {
  172. return Sides.class;
  173. }
  174. /**
  175. * Get the name of the category of which this attribute value is an
  176. * instance.
  177. * <P>
  178. * For class Sides, the category name is <CODE>"sides"</CODE>.
  179. *
  180. * @return Attribute category name.
  181. */
  182. public final String getName() {
  183. return "sides";
  184. }
  185. }