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.SetOfIntegerSyntax; 29 import javax.print.attribute.SupportedValuesAttribute; 30 31 /** 32 * Class CopiesSupported is a printing attribute class, a set of integers, that 33 * gives the supported values for a {@link Copies Copies} attribute. It is 34 * restricted to a single contiguous range of integers; multiple non-overlapping 35 * ranges are not allowed. 36 * <P> 37 * <B>IPP Compatibility:</B> The CopiesSupported attribute's canonical array 38 * form gives the lower and upper bound for the range of copies to be included 39 * in an IPP "copies-supported" attribute. See class {@link 40 * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an 41 * explanation of canonical array form. The category name returned by 42 * {@code getName()} gives the IPP attribute name. 43 * 44 * @author Alan Kaminsky 45 */ 46 public final class CopiesSupported extends SetOfIntegerSyntax 47 implements SupportedValuesAttribute { 48 49 private static final long serialVersionUID = 6927711687034846001L; 50 51 /** 52 * Construct a new copies supported attribute containing a single integer. 53 * That is, only the one value of Copies is supported. 54 * 55 * @param member Set member. 56 * 57 * @exception IllegalArgumentException 58 * (Unchecked exception) Thrown if {@code member} is less than 1. 59 */ 60 public CopiesSupported(int member) { 61 super (member); 62 if (member < 1) { 63 throw new IllegalArgumentException("Copies value < 1 specified"); 64 } 65 } 66 67 /** 68 * Construct a new copies supported attribute containing a single range of 69 * integers. That is, only those values of Copies in the one range are 70 * supported. 71 * 72 * @param lowerBound Lower bound of the range. 73 * @param upperBound Upper bound of the range. 74 * 75 * @exception IllegalArgumentException 76 * (Unchecked exception) Thrown if a null range is specified or if a 77 * non-null range is specified with {@code lowerBound} less than 78 * 1. 79 */ 80 public CopiesSupported(int lowerBound, int upperBound) { 81 super(lowerBound, upperBound); 82 83 if (lowerBound > upperBound) { 84 throw new IllegalArgumentException("Null range specified"); 85 } else if (lowerBound < 1) { 86 throw new IllegalArgumentException("Copies value < 1 specified"); 87 } 88 } 89 90 /** 91 * Returns whether this copies supported attribute is equivalent to the 92 * passed in object. To be equivalent, all of the following conditions must 93 * be true: 94 * <OL TYPE=1> 95 * <LI> 96 * {@code object} is not null. 97 * <LI> 98 * {@code object} is an instance of class CopiesSupported. 99 * <LI> 100 * This copies supported attribute's members and {@code object}'s 101 * members are the same. 102 * </OL> 103 * 104 * @param object Object to compare to. 105 * 106 * @return True if {@code object} is equivalent to this copies 107 * supported attribute, false otherwise. 108 */ 109 public boolean equals(Object object) { 110 return super.equals (object) && object instanceof CopiesSupported; 111 } 112 113 /** 114 * Get the printing attribute class which is to be used as the "category" 115 * for this printing attribute value. 116 * <P> 117 * For class CopiesSupported, the category 118 * is class CopiesSupported itself. 119 * 120 * @return Printing attribute class (category), an instance of class 121 * {@link java.lang.Class java.lang.Class}. 122 */ 123 public final Class<? extends Attribute> getCategory() { 124 return CopiesSupported.class; 125 } 126 127 /** 128 * Get the name of the category of which this attribute value is an 129 * instance. 130 * <P> 131 * For class CopiesSupported, the category 132 * name is {@code "copies-supported"}. 133 * 134 * @return Attribute category name. 135 */ 136 public final String getName() { 137 return "copies-supported"; 138 } 139 140 } | 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.SetOfIntegerSyntax; 30 import javax.print.attribute.SupportedValuesAttribute; 31 32 /** 33 * Class {@code CopiesSupported} is a printing attribute class, a set of 34 * integers, that gives the supported values for a {@link Copies Copies} 35 * attribute. It is restricted to a single contiguous range of integers; 36 * multiple non-overlapping ranges are not allowed. 37 * <p> 38 * <b>IPP Compatibility:</b> The CopiesSupported attribute's canonical array 39 * form gives the lower and upper bound for the range of copies to be included 40 * in an IPP "copies-supported" attribute. See class 41 * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical 42 * array form. The category name returned by {@code getName()} gives the IPP 43 * attribute name. 44 * 45 * @author Alan Kaminsky 46 */ 47 public final class CopiesSupported extends SetOfIntegerSyntax 48 implements SupportedValuesAttribute { 49 50 /** 51 * Use serialVersionUID from JDK 1.4 for interoperability. 52 */ 53 private static final long serialVersionUID = 6927711687034846001L; 54 55 /** 56 * Construct a new copies supported attribute containing a single integer. 57 * That is, only the one value of {@code Copies} is supported. 58 * 59 * @param member set member 60 * @throws IllegalArgumentException if {@code member < 1} 61 */ 62 public CopiesSupported(int member) { 63 super (member); 64 if (member < 1) { 65 throw new IllegalArgumentException("Copies value < 1 specified"); 66 } 67 } 68 69 /** 70 * Construct a new copies supported attribute containing a single range of 71 * integers. That is, only those values of {@code Copies} in the one range 72 * are supported. 73 * 74 * @param lowerBound Lower bound of the range 75 * @param upperBound Upper bound of the range 76 * @throws IllegalArgumentException if a {@code null} range is specified or 77 * if a {@code non-null} range is specified with {@code lowerBound} 78 * less than 1 79 */ 80 public CopiesSupported(int lowerBound, int upperBound) { 81 super(lowerBound, upperBound); 82 83 if (lowerBound > upperBound) { 84 throw new IllegalArgumentException("Null range specified"); 85 } else if (lowerBound < 1) { 86 throw new IllegalArgumentException("Copies value < 1 specified"); 87 } 88 } 89 90 /** 91 * Returns whether this copies supported attribute is equivalent to the 92 * passed in object. To be equivalent, all of the following conditions must 93 * be true: 94 * <ol type=1> 95 * <li>{@code object} is not {@code null}. 96 * <li>{@code object} is an instance of class {@code CopiesSupported}. 97 * <li>This copies supported attribute's members and {@code object}'s 98 * members are the same. 99 * </ol> 100 * 101 * @param object {@code Object} to compare to 102 * @return {@code true} if {@code object} is equivalent to this copies 103 * supported attribute, {@code false} otherwise 104 */ 105 public boolean equals(Object object) { 106 return super.equals (object) && object instanceof CopiesSupported; 107 } 108 109 /** 110 * Get the printing attribute class which is to be used as the "category" 111 * for this printing attribute value. 112 * <p> 113 * For class {@code CopiesSupported}, the category is class 114 * {@code CopiesSupported} itself. 115 * 116 * @return printing attribute class (category), an instance of class 117 * {@link Class java.lang.Class} 118 */ 119 public final Class<? extends Attribute> getCategory() { 120 return CopiesSupported.class; 121 } 122 123 /** 124 * Get the name of the category of which this attribute value is an 125 * instance. 126 * <p> 127 * For class {@code CopiesSupported}, the category name is 128 * {@code "copies-supported"}. 129 * 130 * @return attribute category name 131 */ 132 public final String getName() { 133 return "copies-supported"; 134 } 135 } |