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