View Javadoc
1   /*
2    * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4    *
5    * This code is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License version 2 only, as
7    * published by the Free Software Foundation.  Oracle designates this
8    * particular file as subject to the "Classpath" exception as provided
9    * by Oracle in the LICENSE file that accompanied this code.
10   *
11   * This code is distributed in the hope that it will be useful, but WITHOUT
12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   * version 2 for more details (a copy is included in the LICENSE file that
15   * accompanied this code).
16   *
17   * You should have received a copy of the GNU General Public License version
18   * 2 along with this work; if not, write to the Free Software Foundation,
19   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20   *
21   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22   * or visit www.oracle.com if you need additional information or have any
23   * questions.
24   */
25  package javax.print.attribute.standard;
26  
27  import javax.print.attribute.Attribute;
28  import javax.print.attribute.EnumSyntax;
29  import javax.print.attribute.DocAttribute;
30  import javax.print.attribute.PrintRequestAttribute;
31  import javax.print.attribute.PrintJobAttribute;
32  
33  /**
34   * Class Sides is a printing attribute class, an enumeration, that specifies
35   * how print-stream pages are to be imposed upon the sides of an instance of a
36   * selected medium, i.e., an impression.
37   * <P>
38   * The effect of a Sides attribute on a multidoc print job (a job with multiple
39   * documents) depends on whether all the docs have the same sides values
40   * specified or whether different docs have different sides values specified,
41   * and on the (perhaps defaulted) value of the {@link MultipleDocumentHandling
42   * MultipleDocumentHandling} attribute.
43   * <UL>
44   * <LI>
45   * If all the docs have the same sides value <I>n</I> specified, then any value
46   * of {@link MultipleDocumentHandling MultipleDocumentHandling} makes sense,
47   * and the printer's processing depends on the {@link MultipleDocumentHandling
48   * MultipleDocumentHandling} value:
49   * <UL>
50   * <LI>
51   * SINGLE_DOCUMENT -- All the input docs will be combined together into one
52   * output document. Each media sheet will consist of <I>n</I> impressions from
53   * the output document.
54   * <P>
55   * <LI>
56   * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
57   * into one output document. Each media sheet will consist of <I>n</I>
58   * impressions from the output document. However, the first impression of each
59   * input doc will always start on a new media sheet; this means the last media
60   * sheet of an input doc may have only one impression on it.
61   * <P>
62   * <LI>
63   * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
64   * Each media sheet will consist of <I>n</I> impressions from the input doc.
65   * Since the input docs are separate, the first impression of each input doc
66   * will always start on a new media sheet; this means the last media sheet of
67   * an input doc may have only one impression on it.
68   * <P>
69   * <LI>
70   * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
71   * Each media sheet will consist of <I>n</I> impressions from the input doc.
72   * Since the input docs are separate, the first impression of each input doc
73   * will always start on a new media sheet; this means the last media sheet of
74   * an input doc may have only one impression on it.
75   * </UL>
76   * <P>
77   * <UL>
78   * <LI>
79   * SINGLE_DOCUMENT -- All the input docs will be combined together into one
80   * output document. Each media sheet will consist of <I>n<SUB>i</SUB></I>
81   * impressions from the output document, where <I>i</I> is the number of the
82   * input doc corresponding to that point in the output document. When the next
83   * input doc has a different sides value from the previous input doc, the first
84   * print-stream page of the next input doc goes at the start of the next media
85   * sheet, possibly leaving only one impression on the previous media sheet.
86   * <P>
87   * <LI>
88   * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
89   * into one output document. Each media sheet will consist of <I>n</I>
90   * impressions from the output document. However, the first impression of each
91   * input doc will always start on a new media sheet; this means the last
92   * impression of an input doc may have only one impression on it.
93   * <P>
94   * <LI>
95   * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
96   * For input doc <I>i,</I> each media sheet will consist of <I>n<SUB>i</SUB></I>
97   * impressions from the input doc. Since the input docs are separate, the first
98   * impression of each input doc will always start on a new media sheet; this
99   * means the last media sheet of an input doc may have only one impression on
100  * it.
101  * <P>
102  * <LI>
103  * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
104  * For input doc <I>i,</I> each media sheet will consist of <I>n<SUB>i</SUB></I>
105  * impressions from the input doc. Since the input docs are separate, the first
106  * impression of each input doc will always start on a new media sheet; this
107  * means the last media sheet of an input doc may have only one impression on
108  * it.
109  * </UL>
110  * </UL>
111  * <P>
112  * <B>IPP Compatibility:</B> The category name returned by
113  * <CODE>getName()</CODE> is the IPP attribute name.  The enumeration's
114  * integer value is the IPP enum value.  The <code>toString()</code> method
115  * returns the IPP string representation of the attribute value.
116  * <P>
117  *
118  * @author  Alan Kaminsky
119  */
120 
121 public final class Sides extends EnumSyntax
122     implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
123 
124     private static final long serialVersionUID = -6890309414893262822L;
125 
126     /**
127      * Imposes each consecutive print-stream page upon the same side of
128      * consecutive media sheets.
129      */
130     public static final Sides ONE_SIDED = new Sides(0);
131 
132     /**
133      * Imposes each consecutive pair of print-stream pages upon front and back
134      * sides of consecutive media sheets, such that the orientation of each
135      * pair of print-stream pages on the medium would be correct for the
136      * reader as if for binding on the long edge. This imposition is also
137      * known as "duplex" (see {@link #DUPLEX DUPLEX}).
138      */
139     public static final Sides TWO_SIDED_LONG_EDGE = new Sides(1);
140 
141     /**
142      * Imposes each consecutive pair of print-stream pages upon front and back
143      * sides of consecutive media sheets, such that the orientation of each
144      * pair of print-stream pages on the medium would be correct for the
145      * reader as if for binding on the short edge. This imposition is also
146      * known as "tumble" (see {@link #TUMBLE TUMBLE}).
147      */
148     public static final Sides TWO_SIDED_SHORT_EDGE = new Sides(2);
149 
150     /**
151      * An alias for "two sided long edge" (see {@link #TWO_SIDED_LONG_EDGE
152      * TWO_SIDED_LONG_EDGE}).
153      */
154     public static final Sides DUPLEX = TWO_SIDED_LONG_EDGE;
155 
156     /**
157      * An alias for "two sided short edge" (see {@link #TWO_SIDED_SHORT_EDGE
158      * TWO_SIDED_SHORT_EDGE}).
159      */
160     public static final Sides TUMBLE = TWO_SIDED_SHORT_EDGE;
161 
162     /**
163      * Construct a new sides enumeration value with the given integer value.
164      *
165      * @param  value  Integer value.
166      */
167     protected Sides(int value) {
168         super (value);
169     }
170 
171     private static final String[] myStringTable = {
172         "one-sided",
173         "two-sided-long-edge",
174         "two-sided-short-edge"
175     };
176 
177     private static final Sides[] myEnumValueTable = {
178         ONE_SIDED,
179         TWO_SIDED_LONG_EDGE,
180         TWO_SIDED_SHORT_EDGE
181     };
182 
183     /**
184      * Returns the string table for class Sides.
185      */
186     protected String[] getStringTable() {
187         return myStringTable;
188     }
189 
190     /**
191      * Returns the enumeration value table for class Sides.
192      */
193     protected EnumSyntax[] getEnumValueTable() {
194         return myEnumValueTable;
195     }
196 
197     /**
198      * Get the printing attribute class which is to be used as the "category"
199      * for this printing attribute value.
200      * <P>
201      * For class Sides, the category is class Sides itself.
202      *
203      * @return  Printing attribute class (category), an instance of class
204      *          {@link java.lang.Class java.lang.Class}.
205      */
206     public final Class<? extends Attribute> getCategory() {
207         return Sides.class;
208     }
209 
210     /**
211      * Get the name of the category of which this attribute value is an
212      * instance.
213      * <P>
214      * For class Sides, the category name is <CODE>"sides"</CODE>.
215      *
216      * @return  Attribute category name.
217      */
218     public final String getName() {
219         return "sides";
220     }
221 
222 }