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 java.util.Collections;
21: import java.util.HashMap;
22: import java.util.HashSet;
23: import java.util.Map;
24: import java.util.Set;
25: import javax.print.attribute.Attribute;
26: import javax.print.attribute.PrintServiceAttribute;
27:
28: /*
29: * Table values are obtained from RFC2911: Internet Printing Protocol/1.1:
30: * Model and Semantics, section 4.4.11, http://ietf.org/rfc/rfc2911.txt?number=2911
31: */
32: public final class PrinterStateReasons extends
33: HashMap<PrinterStateReason, Severity> implements
34: PrintServiceAttribute {
35: private static final long serialVersionUID = -3731791085163619457L;
36:
37: public PrinterStateReasons() {
38: super ();
39: }
40:
41: public PrinterStateReasons(int initialCapacity) {
42: super (initialCapacity);
43: }
44:
45: public PrinterStateReasons(int initialCapacity, float loadFactor) {
46: super (initialCapacity, loadFactor);
47: }
48:
49: public PrinterStateReasons(Map<PrinterStateReason, Severity> map) {
50: this ();
51: for (Map.Entry<PrinterStateReason, Severity> mapEntry : map
52: .entrySet()) {
53: put(mapEntry.getKey(), mapEntry.getValue());
54: }
55: }
56:
57: public final Class<? extends Attribute> getCategory() {
58: return PrinterStateReasons.class;
59: }
60:
61: public final String getName() {
62: return "printer-state-reasons";
63: }
64:
65: @Override
66: public Severity put(PrinterStateReason reason, Severity severity) {
67: if (reason == null) {
68: throw new NullPointerException("Reason is null");
69: }
70: if (severity == null) {
71: throw new NullPointerException("Severity is null");
72: }
73: return super .put(reason, severity);
74: }
75:
76: public Set<PrinterStateReason> printerStateReasonSet(
77: Severity severity) {
78: if (severity == null) {
79: throw new NullPointerException("Severity is null");
80: }
81: Set<PrinterStateReason> set = new HashSet<PrinterStateReason>();
82: for (Map.Entry<PrinterStateReason, Severity> mapEntry : entrySet()) {
83: if (mapEntry.getValue() == severity) {
84: set.add(mapEntry.getKey());
85: }
86: }
87: return Collections.unmodifiableSet(set);
88: }
89: }
|