1 /* 2 * Copyright (c) 2000, 2014, 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.IntegerSyntax; 29 import javax.print.attribute.PrintRequestAttribute; 30 import javax.print.attribute.PrintJobAttribute; 31 32 /** 33 * Class JobMediaSheets is an integer valued printing attribute class that 34 * specifies the total number of media sheets to be produced for this job. 35 * <P> 36 * The JobMediaSheets attribute describes the size of the job. This attribute is 37 * not intended to be a counter; it is intended to be useful routing and 38 * scheduling information if known. The printer may try to compute the 39 * JobMediaSheets attribute's value if it is not supplied in the Print Request. 40 * Even if the client does supply a value for the JobMediaSheets attribute in 41 * the Print Request, the printer may choose to change the value if the printer 42 * is able to compute a value which is more accurate than the client supplied 43 * value. The printer may be able to determine the correct value for the 44 * JobMediaSheets attribute either right at job submission time or at any later 45 * point in time. 46 * <P> 47 * Unlike the {@link JobKOctets JobKOctets} and {@link JobImpressions 48 * JobImpressions} attributes, the JobMediaSheets value must include the 49 * multiplicative factors contributed by the number of copies specified by the 50 * {@link Copies Copies} attribute and a "number of copies" instruction embedded 51 * in the document data, if any. This difference allows the system administrator 52 * to control the lower and upper bounds of both (1) the size of the document(s) 53 * with {@link JobKOctetsSupported JobKOctetsSupported} and {@link 54 * JobImpressionsSupported JobImpressionsSupported} and (2) the size of the job 55 * with {@link JobMediaSheetsSupported JobMediaSheetsSupported}. 56 * <P> 57 * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The 58 * category name returned by {@code getName()} gives the IPP attribute 59 * name. 60 * 61 * @see JobMediaSheetsSupported 62 * @see JobMediaSheetsCompleted 63 * @see JobKOctets 64 * @see JobImpressions 65 * 66 * @author Alan Kaminsky 67 */ 68 public class JobMediaSheets extends IntegerSyntax 69 implements PrintRequestAttribute, PrintJobAttribute { 70 71 72 private static final long serialVersionUID = 408871131531979741L; 73 74 /** 75 * Construct a new job media sheets attribute with the given integer 76 * value. 77 * 78 * @param value Integer value. 79 * 80 * @exception IllegalArgumentException 81 * (Unchecked exception) Thrown if {@code value} is less than 0. 82 */ 83 public JobMediaSheets(int value) { 84 super (value, 0, Integer.MAX_VALUE); 85 } 86 87 /** 88 * Returns whether this job media sheets attribute is equivalent to the 89 * passed in object. To be equivalent, all of the following conditions must 90 * be true: 91 * <OL TYPE=1> 92 * <LI> 93 * {@code object} is not null. 94 * <LI> 95 * {@code object} is an instance of class JobMediaSheets. 96 * <LI> 97 * This job media sheets attribute's value and {@code object}'s 98 * value are equal. 99 * </OL> 100 * 101 * @param object Object to compare to. 102 * 103 * @return True if {@code object} is equivalent to this job media 104 * sheets attribute, false otherwise. 105 */ 106 public boolean equals(Object object) { 107 return super.equals(object) && object instanceof JobMediaSheets; 108 } 109 110 /** 111 * Get the printing attribute class which is to be used as the "category" 112 * for this printing attribute value. 113 * <P> 114 * For class JobMediaSheets and any vendor-defined subclasses, the category 115 * is class JobMediaSheets itself. 116 * 117 * @return Printing attribute class (category), an instance of class 118 * {@link java.lang.Class java.lang.Class}. 119 */ 120 public final Class<? extends Attribute> getCategory() { 121 return JobMediaSheets.class; 122 } 123 124 /** 125 * Get the name of the category of which this attribute value is an 126 * instance. 127 * <P> 128 * For class JobMediaSheets and any vendor-defined subclasses, the 129 * category name is {@code "job-media-sheets"}. 130 * 131 * @return Attribute category name. 132 */ 133 public final String getName() { 134 return "job-media-sheets"; 135 } 136 137 } | 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 JobMediaSheets} is an integer valued printing attribute class 35 * that specifies the total number of media sheets to be produced for this job. 36 * <p> 37 * The {@code JobMediaSheets} attribute describes the size of the job. This 38 * attribute is not intended to be a counter; it is intended to be useful 39 * routing and scheduling information if known. The printer may try to compute 40 * the {@code JobMediaSheets} attribute's value if it is not supplied in the 41 * Print Request. Even if the client does supply a value for the 42 * {@code JobMediaSheets} attribute in the Print Request, the printer may choose 43 * to change the value if the printer is able to compute a value which is more 44 * accurate than the client supplied value. The printer may be able to determine 45 * the correct value for the {@code JobMediaSheets} attribute either right at 46 * job submission time or at any later point in time. 47 * <p> 48 * Unlike the {@link JobKOctets JobKOctets} and 49 * {@link JobImpressions JobImpressions} attributes, the {@code JobMediaSheets} 50 * value must include the multiplicative factors contributed by the number of 51 * copies specified by the {@link Copies Copies} attribute and a "number of 52 * copies" instruction embedded in the document data, if any. This difference 53 * allows the system administrator to control the lower and upper bounds of both 54 * (1) the size of the document(s) with 55 * {@link JobKOctetsSupported JobKOctetsSupported} and 56 * {@link JobImpressionsSupported JobImpressionsSupported} and (2) the size of 57 * the job with {@link JobMediaSheetsSupported JobMediaSheetsSupported}. 58 * <p> 59 * <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The 60 * category name returned by {@code getName()} gives the IPP attribute name. 61 * 62 * @author Alan Kaminsky 63 * @see JobMediaSheetsSupported 64 * @see JobMediaSheetsCompleted 65 * @see JobKOctets 66 * @see JobImpressions 67 */ 68 public class JobMediaSheets extends IntegerSyntax 69 implements PrintRequestAttribute, PrintJobAttribute { 70 71 /** 72 * Use serialVersionUID from JDK 1.4 for interoperability. 73 */ 74 private static final long serialVersionUID = 408871131531979741L; 75 76 /** 77 * Construct a new job media sheets attribute with the given integer value. 78 * 79 * @param value Integer value 80 * @throws IllegalArgumentException if {@code value} is negative 81 */ 82 public JobMediaSheets(int value) { 83 super (value, 0, Integer.MAX_VALUE); 84 } 85 86 /** 87 * Returns whether this job media sheets attribute is equivalent to the 88 * passed in object. To be equivalent, all of the following conditions must 89 * be true: 90 * <ol type=1> 91 * <li>{@code object} is not {@code null}. 92 * <li>{@code object} is an instance of class {@code JobMediaSheets}. 93 * <li>This job media sheets attribute's value and {@code object}'s value 94 * are equal. 95 * </ol> 96 * 97 * @param object {@code Object} to compare to 98 * @return {@code true} if {@code object} is equivalent to this job media 99 * sheets attribute, {@code false} otherwise 100 */ 101 public boolean equals(Object object) { 102 return super.equals(object) && object instanceof JobMediaSheets; 103 } 104 105 /** 106 * Get the printing attribute class which is to be used as the "category" 107 * for this printing attribute value. 108 * <p> 109 * For class {@code JobMediaSheets} and any vendor-defined subclasses, the 110 * category is class {@code JobMediaSheets} itself. 111 * 112 * @return printing attribute class (category), an instance of class 113 * {@link Class java.lang.Class} 114 */ 115 public final Class<? extends Attribute> getCategory() { 116 return JobMediaSheets.class; 117 } 118 119 /** 120 * Get the name of the category of which this attribute value is an 121 * instance. 122 * <p> 123 * For class {@code JobMediaSheets} and any vendor-defined subclasses, the 124 * category name is {@code "job-media-sheets"}. 125 * 126 * @return attribute category name 127 */ 128 public final String getName() { 129 return "job-media-sheets"; 130 } 131 } |