Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jmx/snmp/EnumRowStatus.java
38924 views
1
/*
2
* Copyright (c) 2000, 2012, 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 com.sun.jmx.snmp;
27
28
import java.io.Serializable;
29
import java.util.Hashtable;
30
31
32
/**
33
* This class is an internal class which is used to represent RowStatus
34
* codes as defined in RFC 2579.
35
*
36
* It defines an additional code, <i>unspecified</i>, which is
37
* implementation specific, and is used to identify
38
* unspecified actions (when for instance the RowStatus variable
39
* is not present in the varbind list) or uninitialized values.
40
*
41
* mibgen does not generate objects of this class but any variable
42
* using the RowStatus textual convention can be converted into an
43
* object of this class thanks to the
44
* <code>EnumRowStatus(Enumerated valueIndex)</code> constructor.
45
*
46
* <p><b>This API is a Sun Microsystems internal API and is subject
47
* to change without notice.</b></p>
48
**/
49
50
public class EnumRowStatus extends Enumerated implements Serializable {
51
private static final long serialVersionUID = 8966519271130162420L;
52
53
/**
54
* This value is SNMP Runtime implementation specific, and is used to identify
55
* unspecified actions (when for instance the RowStatus variable
56
* is not present in the varbind list) or uninitialized values.
57
*/
58
public final static int unspecified = 0;
59
60
/**
61
* This value corresponds to the <i>active</i> RowStatus, as defined in
62
* RFC 2579 from SMIv2:
63
* <ul>
64
* <i>active</i> indicates that the conceptual row is available for
65
* use by the managed device;
66
* </ul>
67
*/
68
public final static int active = 1;
69
70
/**
71
* This value corresponds to the <i>notInService</i> RowStatus, as
72
* defined in RFC 2579 from SMIv2:
73
* <ul>
74
* <i>notInService</i> indicates that the conceptual
75
* row exists in the agent, but is unavailable for use by
76
* the managed device; <i>notInService</i> has
77
* no implication regarding the internal consistency of
78
* the row, availability of resources, or consistency with
79
* the current state of the managed device;
80
* </ul>
81
**/
82
public final static int notInService = 2;
83
84
/**
85
* This value corresponds to the <i>notReady</i> RowStatus, as defined
86
* in RFC 2579 from SMIv2:
87
* <ul>
88
* <i>notReady</i> indicates that the conceptual row
89
* exists in the agent, but is missing information
90
* necessary in order to be available for use by the
91
* managed device (i.e., one or more required columns in
92
* the conceptual row have not been instantiated);
93
* </ul>
94
*/
95
public final static int notReady = 3;
96
97
/**
98
* This value corresponds to the <i>createAndGo</i> RowStatus,
99
* as defined in RFC 2579 from SMIv2:
100
* <ul>
101
* <i>createAndGo</i> is supplied by a management
102
* station wishing to create a new instance of a
103
* conceptual row and to have its status automatically set
104
* to active, making it available for use by the managed
105
* device;
106
* </ul>
107
*/
108
public final static int createAndGo = 4;
109
110
/**
111
* This value corresponds to the <i>createAndWait</i> RowStatus,
112
* as defined in RFC 2579 from SMIv2:
113
* <ul>
114
* <i>createAndWait</i> is supplied by a management
115
* station wishing to create a new instance of a
116
* conceptual row (but not make it available for use by
117
* the managed device);
118
* </ul>
119
*/
120
public final static int createAndWait = 5;
121
122
/**
123
* This value corresponds to the <i>destroy</i> RowStatus, as defined in
124
* RFC 2579 from SMIv2:
125
* <ul>
126
* <i>destroy</i> is supplied by a management station
127
* wishing to delete all of the instances associated with
128
* an existing conceptual row.
129
* </ul>
130
*/
131
public final static int destroy = 6;
132
133
/**
134
* Build an <code>EnumRowStatus</code> from an <code>int</code>.
135
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
136
* the values defined in RFC 2579.
137
* @exception IllegalArgumentException if the given
138
* <code>valueIndex</code> is not valid.
139
**/
140
public EnumRowStatus(int valueIndex)
141
throws IllegalArgumentException {
142
super(valueIndex);
143
}
144
145
/**
146
* Build an <code>EnumRowStatus</code> from an <code>Enumerated</code>.
147
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
148
* the values defined in RFC 2579.
149
* @exception IllegalArgumentException if the given
150
* <code>valueIndex</code> is not valid.
151
**/
152
public EnumRowStatus(Enumerated valueIndex)
153
throws IllegalArgumentException {
154
this(valueIndex.intValue());
155
}
156
157
/**
158
* Build an <code>EnumRowStatus</code> from a <code>long</code>.
159
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
160
* the values defined in RFC 2579.
161
* @exception IllegalArgumentException if the given
162
* <code>valueIndex</code> is not valid.
163
**/
164
public EnumRowStatus(long valueIndex)
165
throws IllegalArgumentException {
166
this((int)valueIndex);
167
}
168
169
/**
170
* Build an <code>EnumRowStatus</code> from an <code>Integer</code>.
171
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
172
* the values defined in RFC 2579.
173
* @exception IllegalArgumentException if the given
174
* <code>valueIndex</code> is not valid.
175
**/
176
public EnumRowStatus(Integer valueIndex)
177
throws IllegalArgumentException {
178
super(valueIndex);
179
}
180
181
/**
182
* Build an <code>EnumRowStatus</code> from a <code>Long</code>.
183
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
184
* the values defined in RFC 2579.
185
* @exception IllegalArgumentException if the given
186
* <code>valueIndex</code> is not valid.
187
**/
188
public EnumRowStatus(Long valueIndex)
189
throws IllegalArgumentException {
190
this(valueIndex.longValue());
191
}
192
193
/**
194
* Build an <code>EnumRowStatus</code> with <i>unspecified</i> value.
195
**/
196
public EnumRowStatus()
197
throws IllegalArgumentException {
198
this(unspecified);
199
}
200
201
/**
202
* Build an <code>EnumRowStatus</code> from a <code>String</code>.
203
* @param x should be either "unspecified", or one of
204
* the values defined in RFC 2579 ("active", "notReady", etc...)
205
* @exception IllegalArgumentException if the given String
206
* <code>x</code> is not valid.
207
**/
208
public EnumRowStatus(String x)
209
throws IllegalArgumentException {
210
super(x);
211
}
212
213
/**
214
* Build an <code>EnumRowStatus</code> from an <code>SnmpInt</code>.
215
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
216
* the values defined in RFC 2579.
217
* @exception IllegalArgumentException if the given
218
* <code>valueIndex</code> is not valid.
219
**/
220
public EnumRowStatus(SnmpInt valueIndex)
221
throws IllegalArgumentException {
222
this(valueIndex.intValue());
223
}
224
225
/**
226
* Build an SnmpValue from this object.
227
*
228
* @exception IllegalArgumentException if this object holds an
229
* <i>unspecified</i> value.
230
* @return an SnmpInt containing this object value.
231
**/
232
public SnmpInt toSnmpValue()
233
throws IllegalArgumentException {
234
if (value == unspecified)
235
throw new
236
IllegalArgumentException("`unspecified' is not a valid SNMP value.");
237
return new SnmpInt(value);
238
}
239
240
/**
241
* Check that the given <code>value</code> is valid.
242
*
243
* Valid values are:
244
* <ul><li><i>unspecified(0)</i></li>
245
* <li><i>active(1)</i></li>
246
* <li><i>notInService(2)</i></li>
247
* <li><i>notReady(3)</i></li>
248
* <li><i>createAndGo(4)</i></li>
249
* <li><i>createAndWait(5)</i></li>
250
* <li><i>destroy(6)</i></li>
251
* </ul>
252
*
253
**/
254
static public boolean isValidValue(int value) {
255
if (value < 0) return false;
256
if (value > 6) return false;
257
return true;
258
}
259
260
// Documented in Enumerated
261
//
262
@Override
263
protected Hashtable<Integer, String> getIntTable() {
264
return EnumRowStatus.getRSIntTable();
265
}
266
267
// Documented in Enumerated
268
//
269
@Override
270
protected Hashtable<String, Integer> getStringTable() {
271
return EnumRowStatus.getRSStringTable();
272
}
273
274
static Hashtable<Integer, String> getRSIntTable() {
275
return intTable ;
276
}
277
278
static Hashtable<String, Integer> getRSStringTable() {
279
return stringTable ;
280
}
281
282
// Initialize the mapping tables.
283
//
284
final static Hashtable<Integer, String> intTable = new Hashtable<>();
285
final static Hashtable<String, Integer> stringTable = new Hashtable<>();
286
static {
287
intTable.put(new Integer(0), "unspecified");
288
intTable.put(new Integer(3), "notReady");
289
intTable.put(new Integer(6), "destroy");
290
intTable.put(new Integer(2), "notInService");
291
intTable.put(new Integer(5), "createAndWait");
292
intTable.put(new Integer(1), "active");
293
intTable.put(new Integer(4), "createAndGo");
294
stringTable.put("unspecified", new Integer(0));
295
stringTable.put("notReady", new Integer(3));
296
stringTable.put("destroy", new Integer(6));
297
stringTable.put("notInService", new Integer(2));
298
stringTable.put("createAndWait", new Integer(5));
299
stringTable.put("active", new Integer(1));
300
stringTable.put("createAndGo", new Integer(4));
301
}
302
303
304
}
305
306