2362N/A * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A set of attributes which control a print job. 0N/A * Instances of this class control the number of copies, default selection, 169N/A * destination, print dialog, file and printer names, page ranges, multiple 0N/A * document handling (including collation), and multi-page imposition (such 0N/A * as duplex) of every print job which uses the instance. Attribute names are 169N/A * compliant with the Internet Printing Protocol (IPP) 1.1 where possible. 0N/A * Attribute values are partially compliant where possible. 169N/A * To use a method which takes an inner class type, pass a reference to 169N/A * one of the constant fields of the inner class. Client code cannot create 169N/A * new instances of the inner class types because none of those classes 169N/A * has a public constructor. For example, to set the print dialog type to 169N/A * the cross-platform, pure Java print dialog, use the following code: 0N/A * import java.awt.JobAttributes; 0N/A * public class PureJavaPrintDialogExample { 0N/A * public void setPureJavaPrintDialog(JobAttributes jobAttributes) { 169N/A * jobAttributes.setDialog(JobAttributes.DialogType.COMMON); 0N/A * Every IPP attribute which supports an <i>attributeName</i>-default value 0N/A * has a corresponding <code>set<i>attributeName</i>ToDefault</code> method. 169N/A * Default value fields are not provided. 169N/A * @author David Mendenhall 169N/A * A type-safe enumeration of possible default selection states. 0N/A "all",
"range",
"selection" * The <code>DefaultSelectionType</code> instance to use for * specifying that all pages of the job should be printed. * The <code>DefaultSelectionType</code> instance to use for * specifying that a range of pages of the job should be printed. * The <code>DefaultSelectionType</code> instance to use for * specifying that the current selection should be printed. * A type-safe enumeration of possible job destinations. private static final int I_FILE =
0;
* The <code>DestinationType</code> instance to use for * specifying print to file. * The <code>DestinationType</code> instance to use for * specifying print to printer. * A type-safe enumeration of possible dialogs to display to the user. private static final int I_NONE =
2;
"common",
"native",
"none" * The <code>DialogType</code> instance to use for * specifying the cross-platform, pure Java print dialog. * The <code>DialogType</code> instance to use for * specifying the platform's native print dialog. * The <code>DialogType</code> instance to use for * specifying no print dialog. * A type-safe enumeration of possible multiple copy handling states. * It is used to control how the sheets of multiple copies of a single "separate-documents-collated-copies",
"separate-documents-uncollated-copies" * The <code>MultipleDocumentHandlingType</code> instance to use for specifying * that the job should be divided into separate, collated copies. * The <code>MultipleDocumentHandlingType</code> instance to use for specifying * that the job should be divided into separate, uncollated copies. * A type-safe enumeration of possible multi-page impositions. These * impositions are in compliance with IPP 1.1. "one-sided",
"two-sided-long-edge",
"two-sided-short-edge" * The <code>SidesType</code> instance to use for specifying that * consecutive job pages should be printed upon the same side of * consecutive media sheets. * The <code>SidesType</code> instance to use for specifying that * consecutive job pages should be printed upon front and back sides * of consecutive media sheets, such that the orientation of each pair * of pages on the medium would be correct for the reader as if for * binding on the long edge. * The <code>SidesType</code> instance to use for specifying that * consecutive job pages should be printed upon front and back sides * of consecutive media sheets, such that the orientation of each pair * of pages on the medium would be correct for the reader as if for * binding on the short edge. * Constructs a <code>JobAttributes</code> instance with default * values for every attribute. The dialog defaults to * <code>DialogType.NATIVE</code>. Min page defaults to * <code>1</code>. Max page defaults to <code>Integer.MAX_VALUE</code>. * Destination defaults to <code>DestinationType.PRINTER</code>. * Selection defaults to <code>DefaultSelectionType.ALL</code>. * Number of copies defaults to <code>1</code>. Multiple document handling defaults * to <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</code>. * Sides defaults to <code>SidesType.ONE_SIDED</code>. File name defaults * Constructs a <code>JobAttributes</code> instance which is a copy * of the supplied <code>JobAttributes</code>. * @param obj the <code>JobAttributes</code> to copy * Constructs a <code>JobAttributes</code> instance with the * specified values for every attribute. * @param copies an integer greater than 0 * @param defaultSelection <code>DefaultSelectionType.ALL</code>, * <code>DefaultSelectionType.RANGE</code>, or * <code>DefaultSelectionType.SELECTION</code> * @param destination <code>DesintationType.FILE</code> or * <code>DesintationType.PRINTER</code> * @param dialog <code>DialogType.COMMON</code>, * <code>DialogType.NATIVE</code>, or * <code>DialogType.NONE</code> * @param fileName the possibly <code>null</code> file name * @param maxPage an integer greater than zero and greater than or equal * @param minPage an integer greater than zero and less than or equal * @param multipleDocumentHandling * <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES</code> or * <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</code> * @param pageRanges an array of integer arrays of two elements; an array * is interpreted as a range spanning all pages including and * between the specified pages; ranges must be in ascending * order and must not overlap; specified page numbers cannot be * less than <i>minPage</i> nor greater than <i>maxPage</i>; * (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 }, * new int[] { 15, 19 } }), * specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. Note that * (<code>new int[][] { new int[] { 1, 1 }, new int[] { 1, 2 } }</code>), * is an invalid set of page ranges because the two ranges * @param printer the possibly <code>null</code> printer name * @param sides <code>SidesType.ONE_SIDED</code>, * <code>SidesType.TWO_SIDED_LONG_EDGE</code>, or * <code>SidesType.TWO_SIDED_SHORT_EDGE</code> * @throws IllegalArgumentException if one or more of the above * Creates and returns a copy of this <code>JobAttributes</code>. * @return the newly created copy; it is safe to cast this Object into * a <code>JobAttributes</code> // Since we implement Cloneable, this should never happen * Sets all of the attributes of this <code>JobAttributes</code> to * the same values as the attributes of obj. * @param obj the <code>JobAttributes</code> to copy // okay because we never modify the contents of pageRanges * Returns the number of copies the application should render for jobs * using these attributes. This attribute is updated to the value chosen * @return an integer greater than 0. * Specifies the number of copies the application should render for jobs * using these attributes. Not specifying this attribute is equivalent to * specifying <code>1</code>. * @param copies an integer greater than 0 * @throws IllegalArgumentException if <code>copies</code> is less than * Sets the number of copies the application should render for jobs using * these attributes to the default. The default number of copies is 1. * Specifies whether, for jobs using these attributes, the application * should print all pages, the range specified by the return value of * <code>getPageRanges</code>, or the current selection. This attribute * is updated to the value chosen by the user. * @return DefaultSelectionType.ALL, DefaultSelectionType.RANGE, or * DefaultSelectionType.SELECTION * Specifies whether, for jobs using these attributes, the application * should print all pages, the range specified by the return value of * <code>getPageRanges</code>, or the current selection. Not specifying * this attribute is equivalent to specifying DefaultSelectionType.ALL. * @param defaultSelection DefaultSelectionType.ALL, * DefaultSelectionType.RANGE, or DefaultSelectionType.SELECTION. * @throws IllegalArgumentException if defaultSelection is <code>null</code> * Specifies whether output will be to a printer or a file for jobs using * these attributes. This attribute is updated to the value chosen by the * @return DesintationType.FILE or DesintationType.PRINTER * Specifies whether output will be to a printer or a file for jobs using * these attributes. Not specifying this attribute is equivalent to * specifying DesintationType.PRINTER. * @param destination DesintationType.FILE or DesintationType.PRINTER. * @throws IllegalArgumentException if destination is null. * Returns whether, for jobs using these attributes, the user should see * a print dialog in which to modify the print settings, and which type of * print dialog should be displayed. DialogType.COMMON denotes a cross- * platform, pure Java print dialog. DialogType.NATIVE denotes the * platform's native print dialog. If a platform does not support a native * print dialog, the pure Java print dialog is displayed instead. * DialogType.NONE specifies no print dialog (i.e., background printing). * This attribute cannot be modified by, and is not subject to any * limitations of, the implementation or the target printer. * @return <code>DialogType.COMMON</code>, <code>DialogType.NATIVE</code>, or * <code>DialogType.NONE</code> * Specifies whether, for jobs using these attributes, the user should see * a print dialog in which to modify the print settings, and which type of * print dialog should be displayed. DialogType.COMMON denotes a cross- * platform, pure Java print dialog. DialogType.NATIVE denotes the * platform's native print dialog. If a platform does not support a native * print dialog, the pure Java print dialog is displayed instead. * DialogType.NONE specifies no print dialog (i.e., background printing). * Not specifying this attribute is equivalent to specifying * @param dialog DialogType.COMMON, DialogType.NATIVE, or * @throws IllegalArgumentException if dialog is null. * Specifies the file name for the output file for jobs using these * attributes. This attribute is updated to the value chosen by the user. * @return the possibly <code>null</code> file name * Specifies the file name for the output file for jobs using these * attributes. Default is platform-dependent and implementation-defined. * @param fileName the possibly null file name. * Returns, for jobs using these attributes, the first page to be * printed, if a range of pages is to be printed. This attribute is * updated to the value chosen by the user. An application should ignore * this attribute on output, unless the return value of the <code> * getDefaultSelection</code> method is DefaultSelectionType.RANGE. An * application should honor the return value of <code>getPageRanges</code> * over the return value of this method, if possible. * @return an integer greater than zero and less than or equal to * <i>toPage</i> and greater than or equal to <i>minPage</i> and * less than or equal to <i>maxPage</i>. * Specifies, for jobs using these attributes, the first page to be * printed, if a range of pages is to be printed. If this attribute is not * specified, then the values from the pageRanges attribute are used. If * pageRanges and either or both of fromPage and toPage are specified, * pageRanges takes precedence. Specifying none of pageRanges, fromPage, * or toPage is equivalent to calling * setPageRanges(new int[][] { new int[] { <i>minPage</i> } }); * @param fromPage an integer greater than zero and less than or equal to * <i>toPage</i> and greater than or equal to <i>minPage</i> and * less than or equal to <i>maxPage</i>. * @throws IllegalArgumentException if one or more of the above * conditions is violated. * Specifies the maximum value the user can specify as the last page to * be printed for jobs using these attributes. This attribute cannot be * modified by, and is not subject to any limitations of, the * implementation or the target printer. * @return an integer greater than zero and greater than or equal * Specifies the maximum value the user can specify as the last page to * be printed for jobs using these attributes. Not specifying this * attribute is equivalent to specifying <code>Integer.MAX_VALUE</code>. * @param maxPage an integer greater than zero and greater than or equal * @throws IllegalArgumentException if one or more of the above * Specifies the minimum value the user can specify as the first page to * be printed for jobs using these attributes. This attribute cannot be * modified by, and is not subject to any limitations of, the * implementation or the target printer. * @return an integer greater than zero and less than or equal * Specifies the minimum value the user can specify as the first page to * be printed for jobs using these attributes. Not specifying this * attribute is equivalent to specifying <code>1</code>. * @param minPage an integer greater than zero and less than or equal * @throws IllegalArgumentException if one or more of the above * conditions is violated. * Specifies the handling of multiple copies, including collation, for * jobs using these attributes. This attribute is updated to the value * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES. * Specifies the handling of multiple copies, including collation, for * jobs using these attributes. Not specifying this attribute is equivalent * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES. * @param multipleDocumentHandling * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES. * @throws IllegalArgumentException if multipleDocumentHandling is null. "multipleDocumentHandling");
* Sets the handling of multiple copies, including collation, for jobs * using these attributes to the default. The default handling is * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES. * Specifies, for jobs using these attributes, the ranges of pages to be * printed, if a range of pages is to be printed. All range numbers are * inclusive. This attribute is updated to the value chosen by the user. * An application should ignore this attribute on output, unless the * return value of the <code>getDefaultSelection</code> method is * DefaultSelectionType.RANGE. * @return an array of integer arrays of 2 elements. An array * is interpreted as a range spanning all pages including and * between the specified pages. Ranges must be in ascending * order and must not overlap. Specified page numbers cannot be * less than <i>minPage</i> nor greater than <i>maxPage</i>. * (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 }, * new int[] { 15, 19 } }), * specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. // Return a copy because otherwise client code could circumvent the // the checks made in setPageRanges by modifying the returned * Specifies, for jobs using these attributes, the ranges of pages to be * printed, if a range of pages is to be printed. All range numbers are * inclusive. If this attribute is not specified, then the values from the * fromPage and toPages attributes are used. If pageRanges and either or * both of fromPage and toPage are specified, pageRanges takes precedence. * Specifying none of pageRanges, fromPage, or toPage is equivalent to * calling setPageRanges(new int[][] { new int[] { <i>minPage</i>, * @param pageRanges an array of integer arrays of 2 elements. An array * is interpreted as a range spanning all pages including and * between the specified pages. Ranges must be in ascending * order and must not overlap. Specified page numbers cannot be * less than <i>minPage</i> nor greater than <i>maxPage</i>. * (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 }, * new int[] { 15, 19 } }), * specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. Note that * (new int[][] { new int[] { 1, 1 }, new int[] { 1, 2 } }), * is an invalid set of page ranges because the two ranges * @throws IllegalArgumentException if one or more of the above * conditions is violated. String xcp =
"Invalid value for attribute pageRanges";
// Store a copy because otherwise client code could circumvent the // the checks made above by holding a reference to the array and // modifying it after calling setPageRanges. * Returns the destination printer for jobs using these attributes. This * attribute is updated to the value chosen by the user. * @return the possibly null printer name. * Specifies the destination printer for jobs using these attributes. * Default is platform-dependent and implementation-defined. * @param printer the possibly null printer name. * Returns how consecutive pages should be imposed upon the sides of the * print medium for jobs using these attributes. SidesType.ONE_SIDED * imposes each consecutive page upon the same side of consecutive media * sheets. This imposition is sometimes called <i>simplex</i>. * SidesType.TWO_SIDED_LONG_EDGE imposes each consecutive pair of pages * upon front and back sides of consecutive media sheets, such that the * orientation of each pair of pages on the medium would be correct for * the reader as if for binding on the long edge. This imposition is * sometimes called <i>duplex</i>. SidesType.TWO_SIDED_SHORT_EDGE imposes * each consecutive pair of pages upon front and back sides of consecutive * media sheets, such that the orientation of each pair of pages on the * medium would be correct for the reader as if for binding on the short * edge. This imposition is sometimes called <i>tumble</i>. This attribute * is updated to the value chosen by the user. * @return SidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or * SidesType.TWO_SIDED_SHORT_EDGE. * Specifies how consecutive pages should be imposed upon the sides of the * print medium for jobs using these attributes. SidesType.ONE_SIDED * imposes each consecutive page upon the same side of consecutive media * sheets. This imposition is sometimes called <i>simplex</i>. * SidesType.TWO_SIDED_LONG_EDGE imposes each consecutive pair of pages * upon front and back sides of consecutive media sheets, such that the * orientation of each pair of pages on the medium would be correct for * the reader as if for binding on the long edge. This imposition is * sometimes called <i>duplex</i>. SidesType.TWO_SIDED_SHORT_EDGE imposes * each consecutive pair of pages upon front and back sides of consecutive * media sheets, such that the orientation of each pair of pages on the * medium would be correct for the reader as if for binding on the short * edge. This imposition is sometimes called <i>tumble</i>. Not specifying * this attribute is equivalent to specifying SidesType.ONE_SIDED. * @param sides SidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or * SidesType.TWO_SIDED_SHORT_EDGE. * @throws IllegalArgumentException if sides is null. * Sets how consecutive pages should be imposed upon the sides of the * print medium for jobs using these attributes to the default. The * default imposition is SidesType.ONE_SIDED. * Returns, for jobs using these attributes, the last page (inclusive) * to be printed, if a range of pages is to be printed. This attribute is * updated to the value chosen by the user. An application should ignore * this attribute on output, unless the return value of the <code> * getDefaultSelection</code> method is DefaultSelectionType.RANGE. An * application should honor the return value of <code>getPageRanges</code> * over the return value of this method, if possible. * @return an integer greater than zero and greater than or equal * to <i>toPage</i> and greater than or equal to <i>minPage</i> * and less than or equal to <i>maxPage</i>. * Specifies, for jobs using these attributes, the last page (inclusive) * to be printed, if a range of pages is to be printed. * If this attribute is not specified, then the values from the pageRanges * attribute are used. If pageRanges and either or both of fromPage and * toPage are specified, pageRanges takes precedence. Specifying none of * pageRanges, fromPage, or toPage is equivalent to calling * setPageRanges(new int[][] { new int[] { <i>minPage</i> } }); * @param toPage an integer greater than zero and greater than or equal * to <i>fromPage</i> and greater than or equal to <i>minPage</i> * and less than or equal to <i>maxPage</i>. * @throws IllegalArgumentException if one or more of the above * conditions is violated. * Determines whether two JobAttributes are equal to each other. * Two JobAttributes are equal if and only if each of their attributes are * equal. Attributes of enumeration type are equal if and only if the * fields refer to the same unique enumeration object. A set of page * ranges is equal if and only if the sets are of equal length, each range * enumerates the same pages, and the ranges are in the same order. * @param obj the object whose equality will be checked. * @return whether obj is equal to this JobAttribute according to the * Returns a hash code value for this JobAttributes. * Returns a string representation of this JobAttributes. * @return the string representation. return "copies=" +
getCopies() +
",defaultSelection=" +
",minPage=" +
getMinPage() +
",multiple-document-handling=" +