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.IntegerSyntax; 30 import javax.print.attribute.PrintJobAttribute; 31 import javax.print.attribute.PrintRequestAttribute; 32 33 /** 34 * Class {@code Copies} is an integer valued printing attribute class that 35 * specifies the number of copies to be printed. 36 * <p> 37 * On many devices the supported number of collated copies will be limited by 38 * the number of physical output bins on the device, and may be different from 39 * the number of uncollated copies which can be supported. 40 * <p> 41 * The effect of a {@code Copies} attribute with a value of <i>n</i> on a 42 * multidoc print job (a job with multiple documents) depends on the (perhaps 43 * defaulted) value of the 44 * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute: 45 * <ul> 46 * <li>{@code SINGLE_DOCUMENT} -- The result will be <i>n</i> copies of a 47 * single output document comprising all the input docs. 48 * <li>{@code SINGLE_DOCUMENT_NEW_SHEET} -- The result will be <i>n</i> copies 49 * of a single output document comprising all the input docs, and the first 50 * impression of each input doc will always start on a new media sheet. 51 * <li>{@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The result will be 52 * <i>n</i> copies of the first input document, followed by <i>n</i> copies of 53 * the second input document, . . . followed by <i>n</i> copies of the last 54 * input document. 55 * <li>{@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The result will be the 56 * first input document, the second input document, . . . the last input 57 * document, the group of documents being repeated <i>n</i> times. 58 * </ul> 59 * <p> 60 * <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The 61 * category name returned by {@code getName()} gives the IPP attribute name. 62 * 63 * @author David Mendenhall 64 * @author Alan Kamihensky 65 */ 66 public final class Copies extends IntegerSyntax 67 implements PrintRequestAttribute, PrintJobAttribute { 68 69 /** 70 * Use serialVersionUID from JDK 1.4 for interoperability. 71 */ 72 private static final long serialVersionUID = -6426631521680023833L; 73 74 /** 75 * Construct a new copies attribute with the given integer value. 76 * 77 * @param value Integer value 78 * @throws IllegalArgumentException if {@code value < 1} 79 */ 80 public Copies(int value) { 81 super (value, 1, Integer.MAX_VALUE); 82 } 83 84 /** 85 * Returns whether this copies attribute is equivalent to the passed in 86 * object. To be equivalent, all of the following conditions must be true: 87 * <ol type=1> 88 * <li>{@code object} is not {@code null}. 89 * <li>{@code object} is an instance of class {@code Copies}. 90 * <li>This copies attribute's value and {@code object}'s value are equal. 91 * </ol> 92 * 93 * @param object {@code Object} to compare to 94 * @return {@code true} if {@code object} is equivalent to this copies 95 * attribute, {@code false} otherwise 96 */ 97 public boolean equals(Object object) { 98 return super.equals (object) && object instanceof Copies; 99 } 100 101 /** 102 * Get the printing attribute class which is to be used as the "category" 103 * for this printing attribute value. 104 * <p> 105 * For class {@code Copies}, the category is class {@code Copies} itself. 106 * 107 * @return printing attribute class (category), an instance of class 108 * {@link Class java.lang.Class} 109 */ 110 public final Class<? extends Attribute> getCategory() { 111 return Copies.class; 112 } 113 114 /** 115 * Get the name of the category of which this attribute value is an 116 * instance. 117 * <p> 118 * For class {@code Copies}, the category name is {@code "copies"}. 119 * 120 * @return attribute category name 121 */ 122 public final String getName() { 123 return "copies"; 124 } 125 }