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  *
  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  *
  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  *
  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  *
  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  *
  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  *
  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  *
 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  *
 117  * @author  Alan Kaminsky
 118  */
 119 
 120 public final class Sides extends EnumSyntax
 121     implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
 122 
 123     private static final long serialVersionUID = -6890309414893262822L;
 124 
 125     /**
 126      * Imposes each consecutive print-stream page upon the same side of
 127      * consecutive media sheets.
 128      */
 129     public static final Sides ONE_SIDED = new Sides(0);
 130 
 131     /**
 132      * Imposes each consecutive pair of print-stream pages upon front and back
 133      * sides of consecutive media sheets, such that the orientation of each
 134      * pair of print-stream pages on the medium would be correct for the
 135      * reader as if for binding on the long edge. This imposition is also
 136      * known as "duplex" (see {@link #DUPLEX DUPLEX}).
 137      */
 138     public static final Sides TWO_SIDED_LONG_EDGE = new Sides(1);
 139 
 140     /**
 141      * Imposes each consecutive pair of print-stream pages upon front and back
 142      * sides of consecutive media sheets, such that the orientation of each
 143      * pair of print-stream pages on the medium would be correct for the
 144      * reader as if for binding on the short edge. This imposition is also
 145      * known as "tumble" (see {@link #TUMBLE TUMBLE}).
 146      */
 147     public static final Sides TWO_SIDED_SHORT_EDGE = new Sides(2);
 148 
 149     /**
 150      * An alias for "two sided long edge" (see {@link #TWO_SIDED_LONG_EDGE
 151      * TWO_SIDED_LONG_EDGE}).
 152      */
 153     public static final Sides DUPLEX = TWO_SIDED_LONG_EDGE;
 154 
 155     /**
 156      * An alias for "two sided short edge" (see {@link #TWO_SIDED_SHORT_EDGE
 157      * TWO_SIDED_SHORT_EDGE}).
 158      */
 159     public static final Sides TUMBLE = TWO_SIDED_SHORT_EDGE;
 160 
 161     /**
 162      * Construct a new sides enumeration value with the given integer value.
 163      *
 164      * @param  value  Integer value.
 165      */
 166     protected Sides(int value) {
 167         super (value);
 168     }
 169 
 170     private static final String[] myStringTable = {
 171         "one-sided",
 172         "two-sided-long-edge",
 173         "two-sided-short-edge"
 174     };
 175 
 176     private static final Sides[] myEnumValueTable = {
 177         ONE_SIDED,
 178         TWO_SIDED_LONG_EDGE,
 179         TWO_SIDED_SHORT_EDGE
 180     };
 181 
 182     /**
 183      * Returns the string table for class Sides.
 184      */
 185     protected String[] getStringTable() {
 186         return myStringTable;
 187     }
 188 
 189     /**
 190      * Returns the enumeration value table for class Sides.
 191      */
 192     protected EnumSyntax[] getEnumValueTable() {
 193         return myEnumValueTable;
 194     }
 195 
 196     /**
 197      * Get the printing attribute class which is to be used as the "category"
 198      * for this printing attribute value.
 199      * <P>
 200      * For class Sides, the category is class Sides itself.
 201      *
 202      * @return  Printing attribute class (category), an instance of class
 203      *          {@link java.lang.Class java.lang.Class}.
 204      */
 205     public final Class<? extends Attribute> getCategory() {
 206         return Sides.class;
 207     }
 208 
 209     /**
 210      * Get the name of the category of which this attribute value is an
 211      * instance.
 212      * <P>
 213      * For class Sides, the category name is <CODE>"sides"</CODE>.
 214      *
 215      * @return  Attribute category name.
 216      */
 217     public final String getName() {
 218         return "sides";
 219     }
 220 
 221 }