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