001 /*
002 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.print.attribute.standard;
026
027 import javax.print.attribute.Attribute;
028 import javax.print.attribute.EnumSyntax;
029 import javax.print.attribute.DocAttribute;
030 import javax.print.attribute.PrintRequestAttribute;
031 import javax.print.attribute.PrintJobAttribute;
032
033 /**
034 * Class Sides is a printing attribute class, an enumeration, that specifies
035 * how print-stream pages are to be imposed upon the sides of an instance of a
036 * selected medium, i.e., an impression.
037 * <P>
038 * The effect of a Sides attribute on a multidoc print job (a job with multiple
039 * documents) depends on whether all the docs have the same sides values
040 * specified or whether different docs have different sides values specified,
041 * and on the (perhaps defaulted) value of the {@link MultipleDocumentHandling
042 * MultipleDocumentHandling} attribute.
043 * <UL>
044 * <LI>
045 * If all the docs have the same sides value <I>n</I> specified, then any value
046 * of {@link MultipleDocumentHandling MultipleDocumentHandling} makes sense,
047 * and the printer's processing depends on the {@link MultipleDocumentHandling
048 * MultipleDocumentHandling} value:
049 * <UL>
050 * <LI>
051 * SINGLE_DOCUMENT -- All the input docs will be combined together into one
052 * output document. Each media sheet will consist of <I>n</I> impressions from
053 * the output document.
054 * <P>
055 * <LI>
056 * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
057 * into one output document. Each media sheet will consist of <I>n</I>
058 * impressions from the output document. However, the first impression of each
059 * input doc will always start on a new media sheet; this means the last media
060 * sheet of an input doc may have only one impression on it.
061 * <P>
062 * <LI>
063 * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
064 * Each media sheet will consist of <I>n</I> impressions from the input doc.
065 * Since the input docs are separate, the first impression of each input doc
066 * will always start on a new media sheet; this means the last media sheet of
067 * an input doc may have only one impression on it.
068 * <P>
069 * <LI>
070 * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
071 * Each media sheet will consist of <I>n</I> impressions from the input doc.
072 * Since the input docs are separate, the first impression of each input doc
073 * will always start on a new media sheet; this means the last media sheet of
074 * an input doc may have only one impression on it.
075 * </UL>
076 * <P>
077 * <UL>
078 * <LI>
079 * SINGLE_DOCUMENT -- All the input docs will be combined together into one
080 * output document. Each media sheet will consist of <I>n<SUB>i</SUB></I>
081 * impressions from the output document, where <I>i</I> is the number of the
082 * input doc corresponding to that point in the output document. When the next
083 * input doc has a different sides value from the previous input doc, the first
084 * print-stream page of the next input doc goes at the start of the next media
085 * sheet, possibly leaving only one impression on the previous media sheet.
086 * <P>
087 * <LI>
088 * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
089 * into one output document. Each media sheet will consist of <I>n</I>
090 * impressions from the output document. However, the first impression of each
091 * input doc will always start on a new media sheet; this means the last
092 * impression of an input doc may have only one impression on it.
093 * <P>
094 * <LI>
095 * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
096 * For input doc <I>i,</I> each media sheet will consist of <I>n<SUB>i</SUB></I>
097 * impressions from the input doc. Since the input docs are separate, the first
098 * impression of each input doc will always start on a new media sheet; this
099 * 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 implements DocAttribute,
122 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 <CODE>DUPLEX</CODE>}).
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 <CODE>TUMBLE</CODE>}).
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 * <CODE>TWO_SIDED_LONG_EDGE</CODE>}).
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 * <CODE>TWO_SIDED_SHORT_EDGE</CODE>}).
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 = { "one-sided",
172 "two-sided-long-edge", "two-sided-short-edge" };
173
174 private static final Sides[] myEnumValueTable = { ONE_SIDED,
175 TWO_SIDED_LONG_EDGE, TWO_SIDED_SHORT_EDGE };
176
177 /**
178 * Returns the string table for class Sides.
179 */
180 protected String[] getStringTable() {
181 return myStringTable;
182 }
183
184 /**
185 * Returns the enumeration value table for class Sides.
186 */
187 protected EnumSyntax[] getEnumValueTable() {
188 return myEnumValueTable;
189 }
190
191 /**
192 * Get the printing attribute class which is to be used as the "category"
193 * for this printing attribute value.
194 * <P>
195 * For class Sides, the category is class Sides itself.
196 *
197 * @return Printing attribute class (category), an instance of class
198 * {@link java.lang.Class java.lang.Class}.
199 */
200 public final Class<? extends Attribute> getCategory() {
201 return Sides.class;
202 }
203
204 /**
205 * Get the name of the category of which this attribute value is an
206 * instance.
207 * <P>
208 * For class Sides, the category name is <CODE>"sides"</CODE>.
209 *
210 * @return Attribute category name.
211 */
212 public final String getName() {
213 return "sides";
214 }
215
216 }
|