Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java
41171 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print.attribute.standard;2627import java.io.Serial;2829import javax.print.attribute.Attribute;30import javax.print.attribute.DocAttribute;31import javax.print.attribute.EnumSyntax;32import javax.print.attribute.PrintJobAttribute;33import javax.print.attribute.PrintRequestAttribute;3435/**36* Class {@code Finishings} is a printing attribute class, an enumeration, that37* identifies whether the printer applies a finishing operation of some kind of38* binding to each copy of each printed document in the job. For multidoc print39* jobs (jobs with multiple documents), the40* {@link MultipleDocumentHandling MultipleDocumentHandling} attribute41* determines what constitutes a "copy" for purposes of finishing.42* <p>43* Standard Finishings values are:44* <ul>45* <li>{@link #NONE NONE}46* <li>{@link #STAPLE STAPLE}47* <li>{@link #EDGE_STITCH EDGE_STITCH}48* <li>{@link #BIND BIND}49* <li>{@link #SADDLE_STITCH SADDLE_STITCH}50* <li>{@link #COVER COVER}51* </ul>52* <p>53* The following {@code Finishings} values are more specific; they indicate a54* corner or an edge as if the document were a portrait document:55* <ul>56* <li>{@link #STAPLE_TOP_LEFT STAPLE_TOP_LEFT}57* <li>{@link #EDGE_STITCH_LEFT EDGE_STITCH_LEFT}58* <li>{@link #STAPLE_DUAL_LEFT STAPLE_DUAL_LEFT}59* <li>{@link #STAPLE_BOTTOM_LEFT STAPLE_BOTTOM_LEFT}60* <li>{@link #EDGE_STITCH_TOP EDGE_STITCH_TOP}61* <li>{@link #STAPLE_DUAL_TOP STAPLE_DUAL_TOP}62* <li>{@link #STAPLE_TOP_RIGHT STAPLE_TOP_RIGHT}63* <li>{@link #EDGE_STITCH_RIGHT EDGE_STITCH_RIGHT}64* <li>{@link #STAPLE_DUAL_RIGHT STAPLE_DUAL_RIGHT}65* <li>{@link #STAPLE_BOTTOM_RIGHT STAPLE_BOTTOM_RIGHT}66* <li>{@link #EDGE_STITCH_BOTTOM EDGE_STITCH_BOTTOM}67* <li>{@link #STAPLE_DUAL_BOTTOM STAPLE_DUAL_BOTTOM}68* </ul>69* <p>70* The STAPLE_<i>XXX</i> values are specified with respect to the document as if71* the document were a portrait document. If the document is actually a72* landscape or a reverse-landscape document, the client supplies the73* appropriate transformed value. For example, to position a staple in the upper74* left hand corner of a landscape document when held for reading, the client75* supplies the {@code STAPLE_BOTTOM_LEFT} value (since landscape is defined as76* a +90 degree rotation from portrait, i.e., anti-clockwise). On the other77* hand, to position a staple in the upper left hand corner of a78* reverse-landscape document when held for reading, the client supplies the79* {@code STAPLE_TOP_RIGHT} value (since reverse-landscape is defined as a -9080* degree rotation from portrait, i.e., clockwise).81* <p>82* The angle (vertical, horizontal, angled) of each staple with respect to the83* document depends on the implementation which may in turn depend on the value84* of the attribute.85* <p>86* The effect of a {@code Finishings} attribute on a multidoc print job (a job87* with multiple documents) depends on whether all the docs have the same88* binding specified or whether different docs have different bindings89* specified, and on the (perhaps defaulted) value of the90* {@link MultipleDocumentHandling MultipleDocumentHandling} attribute.91* <ul>92* <li>If all the docs have the same binding specified, then any value of93* {@link MultipleDocumentHandling MultipleDocumentHandling} makes sense, and94* the printer's processing depends on the95* {@link MultipleDocumentHandling MultipleDocumentHandling} value:96* <ul>97* <li>{@code SINGLE_DOCUMENT} -- All the input docs will be bound together98* as one output document with the specified binding.99* <li>{@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be bound100* together as one output document with the specified binding, and the first101* impression of each input doc will always start on a new media sheet.102* <li>{@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- Each input doc will103* be bound separately with the specified binding.104* <li>{@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- Each input doc will be105* bound separately with the specified binding.106* </ul>107* <li>If different docs have different bindings specified, then only two108* values of {@link MultipleDocumentHandling MultipleDocumentHandling} make109* sense, and the printer reports an error when the job is submitted if any110* other value is specified:111* <ul>112* <li>{@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- Each input doc will113* be bound separately with its own specified binding.114* <li>{@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- Each input doc will be115* bound separately with its own specified binding.116* </ul>117* </ul>118* <p>119* <b>IPP Compatibility:</b> Class Finishings encapsulates some of the IPP enum120* values that can be included in an IPP "finishings" attribute, which is a set121* of enums. The category name returned by {@code getName()} is the IPP122* attribute name. The enumeration's integer value is the IPP enum value. The123* {@code toString()} method returns the IPP string representation of the124* attribute value. In IPP Finishings is a multi-value attribute, this API125* currently allows only one binding to be specified.126*127* @author Alan Kaminsky128*/129public class Finishings extends EnumSyntax130implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {131132/**133* Use serialVersionUID from JDK 1.4 for interoperability.134*/135@Serial136private static final long serialVersionUID = -627840419548391754L;137138/**139* Perform no binding.140*/141public static final Finishings NONE = new Finishings(3);142143/**144* Bind the document(s) with one or more staples. The exact number and145* placement of the staples is site-defined.146*/147public static final Finishings STAPLE = new Finishings(4);148149/**150* This value is specified when it is desired to select a non-printed (or151* pre-printed) cover for the document. This does not supplant the152* specification of a printed cover (on cover stock medium) by the document153* itself.154*/155public static final Finishings COVER = new Finishings(6);156157/**158* This value indicates that a binding is to be applied to the document; the159* type and placement of the binding is site-defined.160*/161public static final Finishings BIND = new Finishings(7);162163/**164* Bind the document(s) with one or more staples (wire stitches) along the165* middle fold. The exact number and placement of the staples and the middle166* fold is implementation- and/or site-defined.167*/168public static final Finishings SADDLE_STITCH =169new Finishings(8);170171/**172* Bind the document(s) with one or more staples (wire stitches) along one173* edge. The exact number and placement of the staples is implementation-174* and/or site- defined.175*/176public static final Finishings EDGE_STITCH =177new Finishings(9);178179/**180* Bind the document(s) with one or more staples in the top left corner.181*/182public static final Finishings STAPLE_TOP_LEFT =183new Finishings(20);184185/**186* Bind the document(s) with one or more staples in the bottom left corner.187*/188public static final Finishings STAPLE_BOTTOM_LEFT =189new Finishings(21);190191/**192* Bind the document(s) with one or more staples in the top right corner.193*/194public static final Finishings STAPLE_TOP_RIGHT =195new Finishings(22);196197/**198* Bind the document(s) with one or more staples in the bottom right corner.199*/200public static final Finishings STAPLE_BOTTOM_RIGHT =201new Finishings(23);202203/**204* Bind the document(s) with one or more staples (wire stitches) along the205* left edge. The exact number and placement of the staples is206* implementation- and/or site-defined.207*/208public static final Finishings EDGE_STITCH_LEFT =209new Finishings(24);210211/**212* Bind the document(s) with one or more staples (wire stitches) along the213* top edge. The exact number and placement of the staples is214* implementation- and/or site-defined.215*/216public static final Finishings EDGE_STITCH_TOP =217new Finishings(25);218219/**220* Bind the document(s) with one or more staples (wire stitches) along the221* right edge. The exact number and placement of the staples is222* implementation- and/or site-defined.223*/224public static final Finishings EDGE_STITCH_RIGHT =225new Finishings(26);226227/**228* Bind the document(s) with one or more staples (wire stitches) along the229* bottom edge. The exact number and placement of the staples is230* implementation- and/or site-defined.231*/232public static final Finishings EDGE_STITCH_BOTTOM =233new Finishings(27);234235/**236* Bind the document(s) with two staples (wire stitches) along the left edge237* assuming a portrait document (see above).238*/239public static final Finishings STAPLE_DUAL_LEFT =240new Finishings(28);241242/**243* Bind the document(s) with two staples (wire stitches) along the top edge244* assuming a portrait document (see above).245*/246public static final Finishings STAPLE_DUAL_TOP =247new Finishings(29);248249/**250* Bind the document(s) with two staples (wire stitches) along the right251* edge assuming a portrait document (see above).252*/253public static final Finishings STAPLE_DUAL_RIGHT =254new Finishings(30);255256/**257* Bind the document(s) with two staples (wire stitches) along the bottom258* edge assuming a portrait document (see above).259*/260public static final Finishings STAPLE_DUAL_BOTTOM =261new Finishings(31);262263/**264* Construct a new finishings binding enumeration value with the given265* integer value.266*267* @param value Integer value268*/269protected Finishings(int value) {270super(value);271}272273/**274* The string table for class {@code Finishings}.275*/276private static final String[] myStringTable =277{"none",278"staple",279null,280"cover",281"bind",282"saddle-stitch",283"edge-stitch",284null, // The next ten enum values are reserved.285null,286null,287null,288null,289null,290null,291null,292null,293null,294"staple-top-left",295"staple-bottom-left",296"staple-top-right",297"staple-bottom-right",298"edge-stitch-left",299"edge-stitch-top",300"edge-stitch-right",301"edge-stitch-bottom",302"staple-dual-left",303"staple-dual-top",304"staple-dual-right",305"staple-dual-bottom"306};307308/**309* The enumeration value table for class {@code Finishings}.310*/311private static final Finishings[] myEnumValueTable =312{NONE,313STAPLE,314null,315COVER,316BIND,317SADDLE_STITCH,318EDGE_STITCH,319null, // The next ten enum values are reserved.320null,321null,322null,323null,324null,325null,326null,327null,328null,329STAPLE_TOP_LEFT,330STAPLE_BOTTOM_LEFT,331STAPLE_TOP_RIGHT,332STAPLE_BOTTOM_RIGHT,333EDGE_STITCH_LEFT,334EDGE_STITCH_TOP,335EDGE_STITCH_RIGHT,336EDGE_STITCH_BOTTOM,337STAPLE_DUAL_LEFT,338STAPLE_DUAL_TOP,339STAPLE_DUAL_RIGHT,340STAPLE_DUAL_BOTTOM341};342343/**344* Returns the string table for class {@code Finishings}.345*/346protected String[] getStringTable() {347return myStringTable.clone();348}349350/**351* Returns the enumeration value table for class {@code Finishings}.352*/353protected EnumSyntax[] getEnumValueTable() {354return (EnumSyntax[])myEnumValueTable.clone();355}356357/**358* Returns the lowest integer value used by class {@code Finishings}.359*/360protected int getOffset() {361return 3;362}363364/**365* Get the printing attribute class which is to be used as the "category"366* for this printing attribute value.367* <p>368* For class {@code Finishings} and any vendor-defined subclasses, the369* category is class {@code Finishings} itself.370*371* @return printing attribute class (category), an instance of class372* {@link Class java.lang.Class}373*/374public final Class<? extends Attribute> getCategory() {375return Finishings.class;376}377378/**379* Get the name of the category of which this attribute value is an380* instance.381* <p>382* For class {@code Finishings} and any vendor-defined subclasses, the383* category name is {@code "finishings"}.384*385* @return attribute category name386*/387public final String getName() {388return "finishings";389}390}391392393