Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.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.EnumSyntax;31import javax.print.attribute.PrintJobAttribute;32import javax.print.attribute.PrintRequestAttribute;3334/**35* Class {@code MultipleDocumentHandling} is a printing attribute class, an36* enumeration, that controls finishing operations and the placement of one or37* more print-stream pages into impressions and onto media sheets. When the38* value of the {@link Copies Copies} attribute exceeds 1,39* {@code MultipleDocumentHandling} also controls the order in which the copies40* that result from processing the documents are produced. This attribute is41* relevant only for a multidoc print job consisting of two or more individual42* docs.43* <p>44* Briefly, {@code MultipleDocumentHandling} determines the relationship between45* the multiple input (electronic) documents fed into a multidoc print job and46* the output (physical) document or documents produced by the multidoc print47* job.48* There are two possibilities:49* <ul>50* <li>The multiple input documents are combined into a single output51* document. Finishing operations ({@link Finishings Finishings}), are52* performed on this single output document. The {@link Copies Copies}53* attribute tells how many copies of this single output document to produce.54* The {@code MultipleDocumentHandling} values {@code SINGLE_DOCUMENT} and55* {@code SINGLE_DOCUMENT_NEW_SHEET} specify two variations of this56* possibility.57* <li>The multiple input documents remain separate output documents.58* Finishing operations ({@link Finishings Finishings}), are performed on each59* output document separately. The {@link Copies Copies} attribute tells how60* many copies of each separate output document to produce. The61* {@code MultipleDocumentHandling} values62* {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} and63* {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} specify two variations of this64* possibility.65* </ul>66* In the detailed explanations below, if "{@code a}" represents an instance of67* document data, then the result of processing the data in document "{@code a}"68* is a sequence of media sheets represented by "{@code a(*)}".69* <p>70* The standard {@code MultipleDocumentHandling} values are:71* <ul>72* <li><a id="sdfi"></a>{@link #SINGLE_DOCUMENT <b>SINGLE_DOCUMENT</b>}. If a73* print job has multiple documents -- say, the document data is called74* {@code a} and {@code b} -- then the result of processing all the document75* data ({@code a} and then {@code b}) must be treated as a single sequence of76* media sheets for finishing operations; that is, finishing would be77* performed on the concatenation of the sequences {@code a(*),b(*)}. The78* printer must not force the data in each document instance to be formatted79* onto a new print-stream page, nor to start a new impression on a new media80* sheet. If more than one copy is made, the ordering of the sets of media81* sheets resulting from processing the document data must be82* {@code a(*),b(*),a(*),b(*),...}, and the printer object must force each83* copy ({@code a(*),b(*)}) to start on a new media sheet.84* <li><a id="sducfi"></a>{@link #SEPARATE_DOCUMENTS_UNCOLLATED_COPIES85* <b>SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</b>}. If a print job has multiple86* documents -- say, the document data is called {@code a} and {@code b} --87* then the result of processing the data in each document instance must be88* treated as a single sequence of media sheets for finishing operations; that89* is, the sets {@code a(*)} and {@code b(*)} would each be finished90* separately. The printer must force each copy of the result of processing91* the data in a single document to start on a new media sheet. If more than92* one copy is made, the ordering of the sets of media sheets resulting from93* processing the document data must be {@code a(*),a(*),...,b(*),b(*)...}.94* <li><a id="sdccfi"></a>{@link #SEPARATE_DOCUMENTS_COLLATED_COPIES95* <b>SEPARATE_DOCUMENTS_COLLATED_COPIES</b>}. If a print job has multiple96* documents -- say, the document data is called {@code a} and {@code b} --97* then the result of processing the data in each document instance must be98* treated as a single sequence of media sheets for finishing operations; that99* is, the sets {@code a(*)} and {@code b(*)} would each be finished100* separately. The printer must force each copy of the result of processing101* the data in a single document to start on a new media sheet. If more than102* one copy is made, the ordering of the sets of media sheets resulting from103* processing the document data must be {@code a(*),b(*),a(*),b(*),...}.104* <li><a id="sdnsfi"></a>{@link #SINGLE_DOCUMENT_NEW_SHEET105* <b>SINGLE_DOCUMENT_NEW_SHEET</b>}. Same as SINGLE_DOCUMENT, except that the106* printer must ensure that the first impression of each document instance in107* the job is placed on a new media sheet. This value allows multiple108* documents to be stapled together with a single staple where each document109* starts on a new sheet.110* </ul>111* <p>112* {@code SINGLE_DOCUMENT} is the same as113* {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} with respect to ordering of114* print-stream pages, but not media sheet generation, since115* {@code SINGLE_DOCUMENT} will put the first page of the next document on the116* back side of a sheet if an odd number of pages have been produced so far for117* the job, while {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} always forces the118* next document or document copy on to a new sheet.119* <p>120* In addition, if a {@link Finishings Finishings} attribute of121* {@link Finishings#STAPLE STAPLE} is specified, then:122* <ul>123* <li>With {@code SINGLE_DOCUMENT}, documents {@code a} and {@code b} are124* stapled together as a single document with no regard to new sheets.125* <li>With {@code SINGLE_DOCUMENT_NEW_SHEET}, documents {@code a} and126* {@code b} are stapled together as a single document, but document {@code b}127* starts on a new sheet.128* <li>With {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} and129* {@code SEPARATE_DOCUMENTS_COLLATED_COPIES}, documents {@code a} and130* {@code b} are stapled separately.131* </ul>132* <i>Note:</i> None of these values provide means to produce uncollated sheets133* within a document, i.e., where multiple copies of sheet <i>n</i> are produced134* before sheet <i>n</i>+1 of the same document. To specify that, see the135* {@link SheetCollate SheetCollate} attribute.136* <p>137* <b>IPP Compatibility:</b> The category name returned by {@code getName()} is138* the IPP attribute name. The enumeration's integer value is the IPP enum139* value. The {@code toString()} method returns the IPP string representation of140* the attribute value.141*142* @author David Mendenhall143* @author Alan Kaminsky144* @see Copies145* @see Finishings146* @see NumberUp147* @see PageRanges148* @see SheetCollate149* @see Sides150*/151public class MultipleDocumentHandling extends EnumSyntax152implements PrintRequestAttribute, PrintJobAttribute {153154/**155* Use serialVersionUID from JDK 1.4 for interoperability.156*/157@Serial158private static final long serialVersionUID = 8098326460746413466L;159160/**161* Single document -- see above for <a href="#sdfi">further information</a>.162*/163public static final MultipleDocumentHandling164SINGLE_DOCUMENT = new MultipleDocumentHandling (0);165166/**167* Separate documents uncollated copies -- see above for168* <a href="#sducfi">further information</a>.169*/170public static final MultipleDocumentHandling171SEPARATE_DOCUMENTS_UNCOLLATED_COPIES = new MultipleDocumentHandling (1);172173/**174* Separate documents collated copies -- see above for175* <a href="#sdccfi">further information</a>.176*/177public static final MultipleDocumentHandling178SEPARATE_DOCUMENTS_COLLATED_COPIES = new MultipleDocumentHandling (2);179180/**181* Single document new sheet -- see above for <a href="#sdnsfi">further182* information</a>.183*/184public static final MultipleDocumentHandling185SINGLE_DOCUMENT_NEW_SHEET = new MultipleDocumentHandling (3);186187188/**189* Construct a new multiple document handling enumeration value with the190* given integer value.191*192* @param value Integer value193*/194protected MultipleDocumentHandling(int value) {195super (value);196}197198/**199* The string table for class {@code MultipleDocumentHandling}.200*/201private static final String[] myStringTable = {202"single-document",203"separate-documents-uncollated-copies",204"separate-documents-collated-copies",205"single-document-new-sheet"206};207208/**209* The enumeration value table for class {@code MultipleDocumentHandling}.210*/211private static final MultipleDocumentHandling[] myEnumValueTable = {212SINGLE_DOCUMENT,213SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,214SEPARATE_DOCUMENTS_COLLATED_COPIES,215SINGLE_DOCUMENT_NEW_SHEET216};217218/**219* Returns the string table for class {@code MultipleDocumentHandling}.220*/221protected String[] getStringTable() {222return myStringTable.clone();223}224225/**226* Returns the enumeration value table for class227* {@code MultipleDocumentHandling}.228*/229protected EnumSyntax[] getEnumValueTable() {230return (EnumSyntax[])myEnumValueTable.clone();231}232233/**234* Get the printing attribute class which is to be used as the "category"235* for this printing attribute value.236* <p>237* For class {@code MultipleDocumentHandling} and any vendor-defined238* subclasses, the category is class {@code MultipleDocumentHandling}239* itself.240*241* @return printing attribute class (category), an instance of class242* {@link Class java.lang.Class}243*/244public final Class<? extends Attribute> getCategory() {245return MultipleDocumentHandling.class;246}247248/**249* Get the name of the category of which this attribute value is an250* instance.251* <p>252* For class {@code MultipleDocumentHandling} and any vendor-defined253* subclasses, the category name is {@code "multiple-document-handling"}.254*255* @return attribute category name256*/257public final String getName() {258return "multiple-document-handling";259}260}261262263