1. /*
  2. * @(#)file EnumRowStatus.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 1.11
  5. * @(#)date 04/09/15
  6. *
  7. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  8. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  9. */
  10. package com.sun.jmx.snmp;
  11. import java.io.Serializable;
  12. import java.util.Hashtable;
  13. import com.sun.jmx.snmp.SnmpValue;
  14. import com.sun.jmx.snmp.SnmpInt;
  15. import com.sun.jmx.snmp.Enumerated;
  16. /**
  17. * This class is an internal class which is used to represent RowStatus
  18. * codes as defined in RFC 2579.
  19. *
  20. * It defines an additional code, <i>unspecified</i>, which is
  21. * implementation specific, and is used to identify
  22. * unspecified actions (when for instance the RowStatus variable
  23. * is not present in the varbind list) or uninitialized values.
  24. *
  25. * mibgen does not generate objects of this class but any variable
  26. * using the RowStatus textual convention can be converted into an
  27. * object of this class thanks to the
  28. * <code>EnumRowStatus(Enumerated valueIndex)</code> constructor.
  29. *
  30. * <p><b>This API is a Sun Microsystems internal API and is subject
  31. * to change without notice.</b></p>
  32. **/
  33. public class EnumRowStatus extends Enumerated implements Serializable {
  34. /**
  35. * This value is SNMP Runtime implementation specific, and is used to identify
  36. * unspecified actions (when for instance the RowStatus variable
  37. * is not present in the varbind list) or uninitialized values.
  38. */
  39. public final static int unspecified = 0;
  40. /**
  41. * This value corresponds to the <i>active</i> RowStatus, as defined in
  42. * RFC 2579 from SMIv2:
  43. * <ul>
  44. * <i>active</i> indicates that the conceptual row is available for
  45. * use by the managed device;
  46. * </ul>
  47. */
  48. public final static int active = 1;
  49. /**
  50. * This value corresponds to the <i>notInService</i> RowStatus, as
  51. * defined in RFC 2579 from SMIv2:
  52. * <ul>
  53. * <i>notInService</i> indicates that the conceptual
  54. * row exists in the agent, but is unavailable for use by
  55. * the managed device; <i>notInService</i> has
  56. * no implication regarding the internal consistency of
  57. * the row, availability of resources, or consistency with
  58. * the current state of the managed device;
  59. * </ul>
  60. **/
  61. public final static int notInService = 2;
  62. /**
  63. * This value corresponds to the <i>notReady</i> RowStatus, as defined
  64. * in RFC 2579 from SMIv2:
  65. * <ul>
  66. * <i>notReady</i> indicates that the conceptual row
  67. * exists in the agent, but is missing information
  68. * necessary in order to be available for use by the
  69. * managed device (i.e., one or more required columns in
  70. * the conceptual row have not been instantiated);
  71. * </ul>
  72. */
  73. public final static int notReady = 3;
  74. /**
  75. * This value corresponds to the <i>createAndGo</i> RowStatus,
  76. * as defined in RFC 2579 from SMIv2:
  77. * <ul>
  78. * <i>createAndGo</i> is supplied by a management
  79. * station wishing to create a new instance of a
  80. * conceptual row and to have its status automatically set
  81. * to active, making it available for use by the managed
  82. * device;
  83. * </ul>
  84. */
  85. public final static int createAndGo = 4;
  86. /**
  87. * This value corresponds to the <i>createAndWait</i> RowStatus,
  88. * as defined in RFC 2579 from SMIv2:
  89. * <ul>
  90. * <i>createAndWait</i> is supplied by a management
  91. * station wishing to create a new instance of a
  92. * conceptual row (but not make it available for use by
  93. * the managed device);
  94. * </ul>
  95. */
  96. public final static int createAndWait = 5;
  97. /**
  98. * This value corresponds to the <i>destroy</i> RowStatus, as defined in
  99. * RFC 2579 from SMIv2:
  100. * <ul>
  101. * <i>destroy</i> is supplied by a management station
  102. * wishing to delete all of the instances associated with
  103. * an existing conceptual row.
  104. * </ul>
  105. */
  106. public final static int destroy = 6;
  107. /**
  108. * Build an <code>EnumRowStatus</code> from an <code>int</code>.
  109. * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
  110. * the values defined in RFC 2579.
  111. * @exception IllegalArgumentException if the given
  112. * <code>valueIndex</code> is not valid.
  113. **/
  114. public EnumRowStatus(int valueIndex)
  115. throws IllegalArgumentException {
  116. super(valueIndex);
  117. }
  118. /**
  119. * Build an <code>EnumRowStatus</code> from an <code>Enumerated</code>.
  120. * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
  121. * the values defined in RFC 2579.
  122. * @exception IllegalArgumentException if the given
  123. * <code>valueIndex</code> is not valid.
  124. **/
  125. public EnumRowStatus(Enumerated valueIndex)
  126. throws IllegalArgumentException {
  127. this(valueIndex.intValue());
  128. }
  129. /**
  130. * Build an <code>EnumRowStatus</code> from a <code>long</code>.
  131. * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
  132. * the values defined in RFC 2579.
  133. * @exception IllegalArgumentException if the given
  134. * <code>valueIndex</code> is not valid.
  135. **/
  136. public EnumRowStatus(long valueIndex)
  137. throws IllegalArgumentException {
  138. this((int)valueIndex);
  139. }
  140. /**
  141. * Build an <code>EnumRowStatus</code> from an <code>Integer</code>.
  142. * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
  143. * the values defined in RFC 2579.
  144. * @exception IllegalArgumentException if the given
  145. * <code>valueIndex</code> is not valid.
  146. **/
  147. public EnumRowStatus(Integer valueIndex)
  148. throws IllegalArgumentException {
  149. super(valueIndex);
  150. }
  151. /**
  152. * Build an <code>EnumRowStatus</code> from a <code>Long</code>.
  153. * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
  154. * the values defined in RFC 2579.
  155. * @exception IllegalArgumentException if the given
  156. * <code>valueIndex</code> is not valid.
  157. **/
  158. public EnumRowStatus(Long valueIndex)
  159. throws IllegalArgumentException {
  160. this(valueIndex.longValue());
  161. }
  162. /**
  163. * Build an <code>EnumRowStatus</code> with <i>unspecified</i> value.
  164. **/
  165. public EnumRowStatus()
  166. throws IllegalArgumentException {
  167. this(unspecified);
  168. }
  169. /**
  170. * Build an <code>EnumRowStatus</code> from a <code>String</code>.
  171. * @param x should be either "unspecified", or one of
  172. * the values defined in RFC 2579 ("active", "notReady", etc...)
  173. * @exception IllegalArgumentException if the given String
  174. * <code>x</code> is not valid.
  175. **/
  176. public EnumRowStatus(String x)
  177. throws IllegalArgumentException {
  178. super(x);
  179. }
  180. /**
  181. * Build an <code>EnumRowStatus</code> from an <code>SnmpInt</code>.
  182. * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
  183. * the values defined in RFC 2579.
  184. * @exception IllegalArgumentException if the given
  185. * <code>valueIndex</code> is not valid.
  186. **/
  187. public EnumRowStatus(SnmpInt valueIndex)
  188. throws IllegalArgumentException {
  189. this(valueIndex.intValue());
  190. }
  191. /**
  192. * Build an SnmpValue from this object.
  193. *
  194. * @exception IllegalArgumentException if this object holds an
  195. * <i>unspecified</i> value.
  196. * @return an SnmpInt containing this object value.
  197. **/
  198. public SnmpInt toSnmpValue()
  199. throws IllegalArgumentException {
  200. if (value == unspecified)
  201. throw new
  202. IllegalArgumentException("`unspecified' is not a valid SNMP value.");
  203. return new SnmpInt(value);
  204. }
  205. /**
  206. * Check that the given <code>value</code> is valid.
  207. *
  208. * Valid values are:
  209. * <ul><li><i>unspecified(0)</i></li>
  210. * <li><i>active(1)</i></li>
  211. * <li><i>notInService(2)</i></li>
  212. * <li><i>notReady(3)</i></li>
  213. * <li><i>createAndGo(4)</i></li>
  214. * <li><i>createAndWait(5)</i></li>
  215. * <li><i>destroy(6)</i></li>
  216. * </ul>
  217. *
  218. **/
  219. static public boolean isValidValue(int value) {
  220. if (value < 0) return false;
  221. if (value > 6) return false;
  222. return true;
  223. }
  224. // Documented in Enumerated
  225. //
  226. protected Hashtable getIntTable() {
  227. return EnumRowStatus.getRSIntTable();
  228. }
  229. // Documented in Enumerated
  230. //
  231. protected Hashtable getStringTable() {
  232. return EnumRowStatus.getRSStringTable();
  233. }
  234. static final Hashtable getRSIntTable() {
  235. return intTable ;
  236. }
  237. static final Hashtable getRSStringTable() {
  238. return stringTable ;
  239. }
  240. // Initialize the mapping tables.
  241. //
  242. final static Hashtable intTable = new Hashtable();
  243. final static Hashtable stringTable = new Hashtable();
  244. static {
  245. intTable.put(new Integer(0), "unspecified");
  246. intTable.put(new Integer(3), "notReady");
  247. intTable.put(new Integer(6), "destroy");
  248. intTable.put(new Integer(2), "notInService");
  249. intTable.put(new Integer(5), "createAndWait");
  250. intTable.put(new Integer(1), "active");
  251. intTable.put(new Integer(4), "createAndGo");
  252. stringTable.put("unspecified", new Integer(0));
  253. stringTable.put("notReady", new Integer(3));
  254. stringTable.put("destroy", new Integer(6));
  255. stringTable.put("notInService", new Integer(2));
  256. stringTable.put("createAndWait", new Integer(5));
  257. stringTable.put("active", new Integer(1));
  258. stringTable.put("createAndGo", new Integer(4));
  259. }
  260. }