KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > snmp > EnumRowStatus


1 /*
2  * @(#)file EnumRowStatus.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 1.11
5  * @(#)date 08/02/09
6  *
7  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
8  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
9  */

10
11 package com.sun.jmx.snmp;
12
13 import java.io.Serializable JavaDoc;
14 import java.util.Hashtable JavaDoc;
15
16 import com.sun.jmx.snmp.SnmpValue;
17 import com.sun.jmx.snmp.SnmpInt;
18
19 import com.sun.jmx.snmp.Enumerated;
20
21 /**
22  * This class is an internal class which is used to represent RowStatus
23  * codes as defined in RFC 2579.
24  *
25  * It defines an additional code, <i>unspecified</i>, which is
26  * implementation specific, and is used to identify
27  * unspecified actions (when for instance the RowStatus variable
28  * is not present in the varbind list) or uninitialized values.
29  *
30  * mibgen does not generate objects of this class but any variable
31  * using the RowStatus textual convention can be converted into an
32  * object of this class thanks to the
33  * <code>EnumRowStatus(Enumerated valueIndex)</code> constructor.
34  *
35  * <p><b>This API is a Sun Microsystems internal API and is subject
36  * to change without notice.</b></p>
37  **/

38
39 public class EnumRowStatus extends Enumerated implements Serializable JavaDoc {
40
41     /**
42      * This value is SNMP Runtime implementation specific, and is used to identify
43      * unspecified actions (when for instance the RowStatus variable
44      * is not present in the varbind list) or uninitialized values.
45      */

46     public final static int unspecified = 0;
47
48     /**
49      * This value corresponds to the <i>active</i> RowStatus, as defined in
50      * RFC 2579 from SMIv2:
51      * <ul>
52      * <i>active</i> indicates that the conceptual row is available for
53      * use by the managed device;
54      * </ul>
55      */

56     public final static int active = 1;
57
58     /**
59      * This value corresponds to the <i>notInService</i> RowStatus, as
60      * defined in RFC 2579 from SMIv2:
61      * <ul>
62      * <i>notInService</i> indicates that the conceptual
63      * row exists in the agent, but is unavailable for use by
64      * the managed device; <i>notInService</i> has
65      * no implication regarding the internal consistency of
66      * the row, availability of resources, or consistency with
67      * the current state of the managed device;
68      * </ul>
69      **/

70     public final static int notInService = 2;
71
72     /**
73      * This value corresponds to the <i>notReady</i> RowStatus, as defined
74      * in RFC 2579 from SMIv2:
75      * <ul>
76      * <i>notReady</i> indicates that the conceptual row
77      * exists in the agent, but is missing information
78      * necessary in order to be available for use by the
79      * managed device (i.e., one or more required columns in
80      * the conceptual row have not been instantiated);
81      * </ul>
82      */

83     public final static int notReady = 3;
84
85     /**
86      * This value corresponds to the <i>createAndGo</i> RowStatus,
87      * as defined in RFC 2579 from SMIv2:
88      * <ul>
89      * <i>createAndGo</i> is supplied by a management
90      * station wishing to create a new instance of a
91      * conceptual row and to have its status automatically set
92      * to active, making it available for use by the managed
93      * device;
94      * </ul>
95      */

96     public final static int createAndGo = 4;
97
98     /**
99      * This value corresponds to the <i>createAndWait</i> RowStatus,
100      * as defined in RFC 2579 from SMIv2:
101      * <ul>
102      * <i>createAndWait</i> is supplied by a management
103      * station wishing to create a new instance of a
104      * conceptual row (but not make it available for use by
105      * the managed device);
106      * </ul>
107      */

108     public final static int createAndWait = 5;
109
110     /**
111      * This value corresponds to the <i>destroy</i> RowStatus, as defined in
112      * RFC 2579 from SMIv2:
113      * <ul>
114      * <i>destroy</i> is supplied by a management station
115      * wishing to delete all of the instances associated with
116      * an existing conceptual row.
117      * </ul>
118      */

119     public final static int destroy = 6;
120
121     /**
122      * Build an <code>EnumRowStatus</code> from an <code>int</code>.
123      * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
124      * the values defined in RFC 2579.
125      * @exception IllegalArgumentException if the given
126      * <code>valueIndex</code> is not valid.
127      **/

128     public EnumRowStatus(int valueIndex)
129     throws IllegalArgumentException JavaDoc {
130     super(valueIndex);
131     }
132     
133     /**
134      * Build an <code>EnumRowStatus</code> from an <code>Enumerated</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(Enumerated valueIndex)
141     throws IllegalArgumentException JavaDoc {
142     this(valueIndex.intValue());
143     }
144     
145     /**
146      * Build an <code>EnumRowStatus</code> from a <code>long</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(long valueIndex)
153     throws IllegalArgumentException JavaDoc {
154     this((int)valueIndex);
155     }
156
157     /**
158      * Build an <code>EnumRowStatus</code> from an <code>Integer</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(Integer JavaDoc valueIndex)
165     throws IllegalArgumentException JavaDoc {
166     super(valueIndex);
167     }
168     
169     /**
170      * Build an <code>EnumRowStatus</code> from a <code>Long</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(Long JavaDoc valueIndex)
177     throws IllegalArgumentException JavaDoc {
178     this(valueIndex.longValue());
179     }
180     
181     /**
182      * Build an <code>EnumRowStatus</code> with <i>unspecified</i> value.
183      **/

184     public EnumRowStatus()
185     throws IllegalArgumentException JavaDoc {
186     this(unspecified);
187     }
188
189     /**
190      * Build an <code>EnumRowStatus</code> from a <code>String</code>.
191      * @param x should be either "unspecified", or one of
192      * the values defined in RFC 2579 ("active", "notReady", etc...)
193      * @exception IllegalArgumentException if the given String
194      * <code>x</code> is not valid.
195      **/

196     public EnumRowStatus(String JavaDoc x)
197     throws IllegalArgumentException JavaDoc {
198     super(x);
199     }
200
201     /**
202      * Build an <code>EnumRowStatus</code> from an <code>SnmpInt</code>.
203      * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
204      * the values defined in RFC 2579.
205      * @exception IllegalArgumentException if the given
206      * <code>valueIndex</code> is not valid.
207      **/

208     public EnumRowStatus(SnmpInt valueIndex)
209     throws IllegalArgumentException JavaDoc {
210     this(valueIndex.intValue());
211     }
212
213     /**
214      * Build an SnmpValue from this object.
215      *
216      * @exception IllegalArgumentException if this object holds an
217      * <i>unspecified</i> value.
218      * @return an SnmpInt containing this object value.
219      **/

220     public SnmpInt toSnmpValue()
221     throws IllegalArgumentException JavaDoc {
222     if (value == unspecified)
223         throw new
224         IllegalArgumentException JavaDoc("`unspecified' is not a valid SNMP value.");
225     return new SnmpInt(value);
226     }
227
228     /**
229      * Check that the given <code>value</code> is valid.
230      *
231      * Valid values are:
232      * <ul><li><i>unspecified(0)</i></li>
233      * <li><i>active(1)</i></li>
234      * <li><i>notInService(2)</i></li>
235      * <li><i>notReady(3)</i></li>
236      * <li><i>createAndGo(4)</i></li>
237      * <li><i>createAndWait(5)</i></li>
238      * <li><i>destroy(6)</i></li>
239      * </ul>
240      *
241      **/

242     static public boolean isValidValue(int value) {
243     if (value < 0) return false;
244     if (value > 6) return false;
245     return true;
246     }
247
248     // Documented in Enumerated
249
//
250
protected Hashtable JavaDoc getIntTable() {
251     return EnumRowStatus.getRSIntTable();
252     }
253
254     // Documented in Enumerated
255
//
256
protected Hashtable JavaDoc getStringTable() {
257     return EnumRowStatus.getRSStringTable();
258     }
259
260     static final Hashtable JavaDoc getRSIntTable() {
261     return intTable ;
262     }
263     
264     static final Hashtable JavaDoc getRSStringTable() {
265     return stringTable ;
266     }
267
268     // Initialize the mapping tables.
269
//
270
final static Hashtable JavaDoc intTable = new Hashtable JavaDoc();
271     final static Hashtable JavaDoc stringTable = new Hashtable JavaDoc();
272     static {
273     intTable.put(new Integer JavaDoc(0), "unspecified");
274     intTable.put(new Integer JavaDoc(3), "notReady");
275     intTable.put(new Integer JavaDoc(6), "destroy");
276     intTable.put(new Integer JavaDoc(2), "notInService");
277     intTable.put(new Integer JavaDoc(5), "createAndWait");
278     intTable.put(new Integer JavaDoc(1), "active");
279     intTable.put(new Integer JavaDoc(4), "createAndGo");
280     stringTable.put("unspecified", new Integer JavaDoc(0));
281     stringTable.put("notReady", new Integer JavaDoc(3));
282     stringTable.put("destroy", new Integer JavaDoc(6));
283     stringTable.put("notInService", new Integer JavaDoc(2));
284     stringTable.put("createAndWait", new Integer JavaDoc(5));
285     stringTable.put("active", new Integer JavaDoc(1));
286     stringTable.put("createAndGo", new Integer JavaDoc(4));
287     }
288
289
290 }
291
292
Popular Tags