01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.print.attribute.standard;
19:
20: import javax.print.attribute.Attribute;
21: import javax.print.attribute.SetOfIntegerSyntax;
22: import javax.print.attribute.SupportedValuesAttribute;
23:
24: public final class NumberUpSupported extends SetOfIntegerSyntax
25: implements SupportedValuesAttribute {
26: private static final long serialVersionUID = -1041573395759141805L;
27:
28: public NumberUpSupported(int value) {
29: super (value);
30: if (value < 1) {
31: throw new IllegalArgumentException("Value" + value
32: + "is less than 1");
33: }
34: }
35:
36: public NumberUpSupported(int lowerBound, int upperBound) {
37: super (lowerBound, upperBound);
38: if (lowerBound > upperBound) {
39: throw new IllegalArgumentException(
40: "Null range: lowerBound " + "> upperBound");
41: } else if (lowerBound < 1) {
42: throw new IllegalArgumentException("Lower bound "
43: + lowerBound + " is less than 1");
44: }
45: }
46:
47: public NumberUpSupported(int[][] members) {
48: super (members);
49: if (members == null) {
50: throw new NullPointerException("Null int[][] parameter");
51: }
52: int[][] canonicalArray = getMembers();
53: if (canonicalArray.length == 0) {
54: throw new IllegalArgumentException("Zero-length array");
55: }
56: for (int i = 0; i < canonicalArray.length; i++) {
57: if (canonicalArray[i][0] < 1) {
58: throw new IllegalArgumentException(
59: "Valid values are not " + "less than 1");
60: }
61: }
62: }
63:
64: @Override
65: public boolean equals(Object object) {
66: if (!(object instanceof NumberUpSupported)) {
67: return false;
68: }
69: return super .equals(object);
70: }
71:
72: public Class<? extends Attribute> getCategory() {
73: return NumberUpSupported.class;
74: }
75:
76: public String getName() {
77: return "number-up-supported";
78: }
79: }
|