0N/A/*
2362N/A * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.jmx.snmp;
0N/A
0N/Aimport java.io.Serializable;
0N/Aimport java.util.Hashtable;
0N/A
0N/Aimport com.sun.jmx.snmp.SnmpValue;
0N/Aimport com.sun.jmx.snmp.SnmpInt;
0N/A
0N/Aimport com.sun.jmx.snmp.Enumerated;
0N/A
0N/A/**
0N/A * This class is an internal class which is used to represent RowStatus
0N/A * codes as defined in RFC 2579.
0N/A *
0N/A * It defines an additional code, <i>unspecified</i>, which is
0N/A * implementation specific, and is used to identify
0N/A * unspecified actions (when for instance the RowStatus variable
0N/A * is not present in the varbind list) or uninitialized values.
0N/A *
0N/A * mibgen does not generate objects of this class but any variable
0N/A * using the RowStatus textual convention can be converted into an
0N/A * object of this class thanks to the
0N/A * <code>EnumRowStatus(Enumerated valueIndex)</code> constructor.
0N/A *
0N/A * <p><b>This API is a Sun Microsystems internal API and is subject
0N/A * to change without notice.</b></p>
0N/A **/
0N/A
0N/Apublic class EnumRowStatus extends Enumerated implements Serializable {
0N/A private static final long serialVersionUID = 8966519271130162420L;
0N/A
0N/A /**
0N/A * This value is SNMP Runtime implementation specific, and is used to identify
0N/A * unspecified actions (when for instance the RowStatus variable
0N/A * is not present in the varbind list) or uninitialized values.
0N/A */
0N/A public final static int unspecified = 0;
0N/A
0N/A /**
0N/A * This value corresponds to the <i>active</i> RowStatus, as defined in
0N/A * RFC 2579 from SMIv2:
0N/A * <ul>
0N/A * <i>active</i> indicates that the conceptual row is available for
0N/A * use by the managed device;
0N/A * </ul>
0N/A */
0N/A public final static int active = 1;
0N/A
0N/A /**
0N/A * This value corresponds to the <i>notInService</i> RowStatus, as
0N/A * defined in RFC 2579 from SMIv2:
0N/A * <ul>
0N/A * <i>notInService</i> indicates that the conceptual
0N/A * row exists in the agent, but is unavailable for use by
0N/A * the managed device; <i>notInService</i> has
0N/A * no implication regarding the internal consistency of
0N/A * the row, availability of resources, or consistency with
0N/A * the current state of the managed device;
0N/A * </ul>
0N/A **/
0N/A public final static int notInService = 2;
0N/A
0N/A /**
0N/A * This value corresponds to the <i>notReady</i> RowStatus, as defined
0N/A * in RFC 2579 from SMIv2:
0N/A * <ul>
0N/A * <i>notReady</i> indicates that the conceptual row
0N/A * exists in the agent, but is missing information
0N/A * necessary in order to be available for use by the
0N/A * managed device (i.e., one or more required columns in
0N/A * the conceptual row have not been instantiated);
0N/A * </ul>
0N/A */
0N/A public final static int notReady = 3;
0N/A
0N/A /**
0N/A * This value corresponds to the <i>createAndGo</i> RowStatus,
0N/A * as defined in RFC 2579 from SMIv2:
0N/A * <ul>
0N/A * <i>createAndGo</i> is supplied by a management
0N/A * station wishing to create a new instance of a
0N/A * conceptual row and to have its status automatically set
0N/A * to active, making it available for use by the managed
0N/A * device;
0N/A * </ul>
0N/A */
0N/A public final static int createAndGo = 4;
0N/A
0N/A /**
0N/A * This value corresponds to the <i>createAndWait</i> RowStatus,
0N/A * as defined in RFC 2579 from SMIv2:
0N/A * <ul>
0N/A * <i>createAndWait</i> is supplied by a management
0N/A * station wishing to create a new instance of a
0N/A * conceptual row (but not make it available for use by
0N/A * the managed device);
0N/A * </ul>
0N/A */
0N/A public final static int createAndWait = 5;
0N/A
0N/A /**
0N/A * This value corresponds to the <i>destroy</i> RowStatus, as defined in
0N/A * RFC 2579 from SMIv2:
0N/A * <ul>
0N/A * <i>destroy</i> is supplied by a management station
0N/A * wishing to delete all of the instances associated with
0N/A * an existing conceptual row.
0N/A * </ul>
0N/A */
0N/A public final static int destroy = 6;
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> from an <code>int</code>.
0N/A * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
0N/A * the values defined in RFC 2579.
0N/A * @exception IllegalArgumentException if the given
0N/A * <code>valueIndex</code> is not valid.
0N/A **/
0N/A public EnumRowStatus(int valueIndex)
0N/A throws IllegalArgumentException {
0N/A super(valueIndex);
0N/A }
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> from an <code>Enumerated</code>.
0N/A * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
0N/A * the values defined in RFC 2579.
0N/A * @exception IllegalArgumentException if the given
0N/A * <code>valueIndex</code> is not valid.
0N/A **/
0N/A public EnumRowStatus(Enumerated valueIndex)
0N/A throws IllegalArgumentException {
0N/A this(valueIndex.intValue());
0N/A }
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> from a <code>long</code>.
0N/A * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
0N/A * the values defined in RFC 2579.
0N/A * @exception IllegalArgumentException if the given
0N/A * <code>valueIndex</code> is not valid.
0N/A **/
0N/A public EnumRowStatus(long valueIndex)
0N/A throws IllegalArgumentException {
0N/A this((int)valueIndex);
0N/A }
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> from an <code>Integer</code>.
0N/A * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
0N/A * the values defined in RFC 2579.
0N/A * @exception IllegalArgumentException if the given
0N/A * <code>valueIndex</code> is not valid.
0N/A **/
0N/A public EnumRowStatus(Integer valueIndex)
0N/A throws IllegalArgumentException {
0N/A super(valueIndex);
0N/A }
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> from a <code>Long</code>.
0N/A * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
0N/A * the values defined in RFC 2579.
0N/A * @exception IllegalArgumentException if the given
0N/A * <code>valueIndex</code> is not valid.
0N/A **/
0N/A public EnumRowStatus(Long valueIndex)
0N/A throws IllegalArgumentException {
0N/A this(valueIndex.longValue());
0N/A }
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> with <i>unspecified</i> value.
0N/A **/
0N/A public EnumRowStatus()
0N/A throws IllegalArgumentException {
0N/A this(unspecified);
0N/A }
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> from a <code>String</code>.
0N/A * @param x should be either "unspecified", or one of
0N/A * the values defined in RFC 2579 ("active", "notReady", etc...)
0N/A * @exception IllegalArgumentException if the given String
0N/A * <code>x</code> is not valid.
0N/A **/
0N/A public EnumRowStatus(String x)
0N/A throws IllegalArgumentException {
0N/A super(x);
0N/A }
0N/A
0N/A /**
0N/A * Build an <code>EnumRowStatus</code> from an <code>SnmpInt</code>.
0N/A * @param valueIndex should be either 0 (<i>unspecified</i>), or one of
0N/A * the values defined in RFC 2579.
0N/A * @exception IllegalArgumentException if the given
0N/A * <code>valueIndex</code> is not valid.
0N/A **/
0N/A public EnumRowStatus(SnmpInt valueIndex)
0N/A throws IllegalArgumentException {
0N/A this(valueIndex.intValue());
0N/A }
0N/A
0N/A /**
0N/A * Build an SnmpValue from this object.
0N/A *
0N/A * @exception IllegalArgumentException if this object holds an
0N/A * <i>unspecified</i> value.
0N/A * @return an SnmpInt containing this object value.
0N/A **/
0N/A public SnmpInt toSnmpValue()
0N/A throws IllegalArgumentException {
0N/A if (value == unspecified)
0N/A throw new
0N/A IllegalArgumentException("`unspecified' is not a valid SNMP value.");
0N/A return new SnmpInt(value);
0N/A }
0N/A
0N/A /**
0N/A * Check that the given <code>value</code> is valid.
0N/A *
0N/A * Valid values are:
0N/A * <ul><li><i>unspecified(0)</i></li>
0N/A * <li><i>active(1)</i></li>
0N/A * <li><i>notInService(2)</i></li>
0N/A * <li><i>notReady(3)</i></li>
0N/A * <li><i>createAndGo(4)</i></li>
0N/A * <li><i>createAndWait(5)</i></li>
0N/A * <li><i>destroy(6)</i></li>
0N/A * </ul>
0N/A *
0N/A **/
0N/A static public boolean isValidValue(int value) {
0N/A if (value < 0) return false;
0N/A if (value > 6) return false;
0N/A return true;
0N/A }
0N/A
0N/A // Documented in Enumerated
0N/A //
0N/A protected Hashtable getIntTable() {
0N/A return EnumRowStatus.getRSIntTable();
0N/A }
0N/A
0N/A // Documented in Enumerated
0N/A //
0N/A protected Hashtable getStringTable() {
0N/A return EnumRowStatus.getRSStringTable();
0N/A }
0N/A
0N/A static final Hashtable getRSIntTable() {
0N/A return intTable ;
0N/A }
0N/A
0N/A static final Hashtable getRSStringTable() {
0N/A return stringTable ;
0N/A }
0N/A
0N/A // Initialize the mapping tables.
0N/A //
0N/A final static Hashtable<Integer, String> intTable =
0N/A new Hashtable<Integer, String>();
0N/A final static Hashtable<String, Integer> stringTable =
0N/A new Hashtable<String, Integer>();
0N/A static {
0N/A intTable.put(new Integer(0), "unspecified");
0N/A intTable.put(new Integer(3), "notReady");
0N/A intTable.put(new Integer(6), "destroy");
0N/A intTable.put(new Integer(2), "notInService");
0N/A intTable.put(new Integer(5), "createAndWait");
0N/A intTable.put(new Integer(1), "active");
0N/A intTable.put(new Integer(4), "createAndGo");
0N/A stringTable.put("unspecified", new Integer(0));
0N/A stringTable.put("notReady", new Integer(3));
0N/A stringTable.put("destroy", new Integer(6));
0N/A stringTable.put("notInService", new Integer(2));
0N/A stringTable.put("createAndWait", new Integer(5));
0N/A stringTable.put("active", new Integer(1));
0N/A stringTable.put("createAndGo", new Integer(4));
0N/A }
0N/A
0N/A
0N/A}