Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java
41171 views
1
/*
2
* Copyright (c) 2000, 2021, 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 java.io.Serial;
29
import java.util.Collection;
30
import java.util.HashSet;
31
32
import javax.print.attribute.Attribute;
33
import javax.print.attribute.PrintJobAttribute;
34
35
/**
36
* Class {@code JobStateReasons} is a printing attribute class, a set of
37
* enumeration values, that provides additional information about the job's
38
* current state, i.e., information that augments the value of the job's
39
* {@link JobState JobState} attribute.
40
* <p>
41
* Instances of {@link JobStateReason JobStateReason} do not appear in a Print
42
* Job's attribute set directly. Rather, a {@code JobStateReasons} attribute
43
* appears in the Print Job's attribute set. The {@code JobStateReasons}
44
* attribute contains zero, one, or more than one
45
* {@link JobStateReason JobStateReason} objects which pertain to the Print
46
* Job's status. The printer adds a {@link JobStateReason JobStateReason} object
47
* to the Print Job's JobStateReasons attribute when the corresponding condition
48
* becomes true of the Print Job, and the printer removes the
49
* {@link JobStateReason JobStateReason} object again when the corresponding
50
* condition becomes false, regardless of whether the Print Job's overall
51
* {@link JobState JobState} also changed.
52
* <p>
53
* Class {@code JobStateReasons} inherits its implementation from class
54
* {@link HashSet java.util.HashSet}. Unlike most printing attributes
55
* which are immutable once constructed, class {@code JobStateReasons} is
56
* designed to be mutable; you can add {@link JobStateReason JobStateReason}
57
* objects to an existing {@code JobStateReasons} object and remove them again.
58
* However, like class {@link HashSet java.util.HashSet}, class
59
* {@code JobStateReasons} is not multiple thread safe. If a
60
* {@code JobStateReasons} object will be used by multiple threads, be sure to
61
* synchronize its operations (e.g., using a synchronized set view obtained
62
* from class {@link java.util.Collections java.util.Collections}).
63
* <p>
64
* <b>IPP Compatibility:</b> The string value returned by each individual
65
* {@link JobStateReason JobStateReason} object's {@code toString()} method
66
* gives the IPP keyword value. The category name returned by {@code getName()}
67
* gives the IPP attribute name.
68
*
69
* @author Alan Kaminsky
70
*/
71
public final class JobStateReasons
72
extends HashSet<JobStateReason> implements PrintJobAttribute {
73
74
/**
75
* Use serialVersionUID from JDK 1.4 for interoperability.
76
*/
77
@Serial
78
private static final long serialVersionUID = 8849088261264331812L;
79
80
/**
81
* Construct a new, empty job state reasons attribute; the underlying hash
82
* set has the default initial capacity and load factor.
83
*/
84
public JobStateReasons() {
85
super();
86
}
87
88
/**
89
* Construct a new, empty job state reasons attribute; the underlying hash
90
* set has the given initial capacity and the default load factor.
91
*
92
* @param initialCapacity initial capacity
93
* @throws IllegalArgumentException if the initial capacity is negative
94
*/
95
public JobStateReasons(int initialCapacity) {
96
super (initialCapacity);
97
}
98
99
/**
100
* Construct a new, empty job state reasons attribute; the underlying hash
101
* set has the given initial capacity and load factor.
102
*
103
* @param initialCapacity initial capacity
104
* @param loadFactor load factor
105
* @throws IllegalArgumentException if the initial capacity is negative
106
*/
107
public JobStateReasons(int initialCapacity, float loadFactor) {
108
super (initialCapacity, loadFactor);
109
}
110
111
/**
112
* Construct a new job state reasons attribute that contains the same
113
* {@link JobStateReason JobStateReason} objects as the given collection.
114
* The underlying hash set's initial capacity and load factor are as
115
* specified in the superclass constructor
116
* {@link HashSet#HashSet(Collection) HashSet(Collection)}.
117
*
118
* @param collection collection to copy
119
* @throws NullPointerException if {@code collection} is {@code null} or if
120
* any element in {@code collection} is {@code null}
121
* @throws ClassCastException if any element in {@code collection} is not an
122
* instance of class {@link JobStateReason JobStateReason}
123
*/
124
public JobStateReasons(Collection<JobStateReason> collection) {
125
super (collection);
126
}
127
128
/**
129
* Adds the specified element to this job state reasons attribute if it is
130
* not already present. The element to be added must be an instance of class
131
* {@link JobStateReason JobStateReason}. If this job state reasons
132
* attribute already contains the specified element, the call leaves this
133
* job state reasons attribute unchanged and returns {@code false}.
134
*
135
* @param o element to be added to this job state reasons attribute
136
* @return {@code true} if this job state reasons attribute did not already
137
* contain the specified element
138
* @throws NullPointerException if the specified element is {@code null}
139
* @throws ClassCastException if the specified element is not an instance of
140
* class {@link JobStateReason JobStateReason}
141
* @since 1.5
142
*/
143
public boolean add(JobStateReason o) {
144
if (o == null) {
145
throw new NullPointerException();
146
}
147
return super.add(o);
148
}
149
150
/**
151
* Get the printing attribute class which is to be used as the "category"
152
* for this printing attribute value.
153
* <p>
154
* For class {@code JobStateReasons}, the category is class
155
* JobStateReasons itself.
156
*
157
* @return printing attribute class (category), an instance of class
158
* {@link Class java.lang.Class}
159
*/
160
public final Class<? extends Attribute> getCategory() {
161
return JobStateReasons.class;
162
}
163
164
/**
165
* Get the name of the category of which this attribute value is an
166
* instance.
167
* <p>
168
* For class JobStateReasons, the category name is
169
* {@code "job-state-reasons"}.
170
*
171
* @return attribute category name
172
*/
173
public final String getName() {
174
return "job-state-reasons";
175
}
176
}
177
178