Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jmx/snmp/EnumRowStatus.java
38924 views
/*1* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.jmx.snmp;2627import java.io.Serializable;28import java.util.Hashtable;293031/**32* This class is an internal class which is used to represent RowStatus33* codes as defined in RFC 2579.34*35* It defines an additional code, <i>unspecified</i>, which is36* implementation specific, and is used to identify37* unspecified actions (when for instance the RowStatus variable38* is not present in the varbind list) or uninitialized values.39*40* mibgen does not generate objects of this class but any variable41* using the RowStatus textual convention can be converted into an42* object of this class thanks to the43* <code>EnumRowStatus(Enumerated valueIndex)</code> constructor.44*45* <p><b>This API is a Sun Microsystems internal API and is subject46* to change without notice.</b></p>47**/4849public class EnumRowStatus extends Enumerated implements Serializable {50private static final long serialVersionUID = 8966519271130162420L;5152/**53* This value is SNMP Runtime implementation specific, and is used to identify54* unspecified actions (when for instance the RowStatus variable55* is not present in the varbind list) or uninitialized values.56*/57public final static int unspecified = 0;5859/**60* This value corresponds to the <i>active</i> RowStatus, as defined in61* RFC 2579 from SMIv2:62* <ul>63* <i>active</i> indicates that the conceptual row is available for64* use by the managed device;65* </ul>66*/67public final static int active = 1;6869/**70* This value corresponds to the <i>notInService</i> RowStatus, as71* defined in RFC 2579 from SMIv2:72* <ul>73* <i>notInService</i> indicates that the conceptual74* row exists in the agent, but is unavailable for use by75* the managed device; <i>notInService</i> has76* no implication regarding the internal consistency of77* the row, availability of resources, or consistency with78* the current state of the managed device;79* </ul>80**/81public final static int notInService = 2;8283/**84* This value corresponds to the <i>notReady</i> RowStatus, as defined85* in RFC 2579 from SMIv2:86* <ul>87* <i>notReady</i> indicates that the conceptual row88* exists in the agent, but is missing information89* necessary in order to be available for use by the90* managed device (i.e., one or more required columns in91* the conceptual row have not been instantiated);92* </ul>93*/94public final static int notReady = 3;9596/**97* This value corresponds to the <i>createAndGo</i> RowStatus,98* as defined in RFC 2579 from SMIv2:99* <ul>100* <i>createAndGo</i> is supplied by a management101* station wishing to create a new instance of a102* conceptual row and to have its status automatically set103* to active, making it available for use by the managed104* device;105* </ul>106*/107public final static int createAndGo = 4;108109/**110* This value corresponds to the <i>createAndWait</i> RowStatus,111* as defined in RFC 2579 from SMIv2:112* <ul>113* <i>createAndWait</i> is supplied by a management114* station wishing to create a new instance of a115* conceptual row (but not make it available for use by116* the managed device);117* </ul>118*/119public final static int createAndWait = 5;120121/**122* This value corresponds to the <i>destroy</i> RowStatus, as defined in123* RFC 2579 from SMIv2:124* <ul>125* <i>destroy</i> is supplied by a management station126* wishing to delete all of the instances associated with127* an existing conceptual row.128* </ul>129*/130public final static int destroy = 6;131132/**133* Build an <code>EnumRowStatus</code> from an <code>int</code>.134* @param valueIndex should be either 0 (<i>unspecified</i>), or one of135* the values defined in RFC 2579.136* @exception IllegalArgumentException if the given137* <code>valueIndex</code> is not valid.138**/139public EnumRowStatus(int valueIndex)140throws IllegalArgumentException {141super(valueIndex);142}143144/**145* Build an <code>EnumRowStatus</code> from an <code>Enumerated</code>.146* @param valueIndex should be either 0 (<i>unspecified</i>), or one of147* the values defined in RFC 2579.148* @exception IllegalArgumentException if the given149* <code>valueIndex</code> is not valid.150**/151public EnumRowStatus(Enumerated valueIndex)152throws IllegalArgumentException {153this(valueIndex.intValue());154}155156/**157* Build an <code>EnumRowStatus</code> from a <code>long</code>.158* @param valueIndex should be either 0 (<i>unspecified</i>), or one of159* the values defined in RFC 2579.160* @exception IllegalArgumentException if the given161* <code>valueIndex</code> is not valid.162**/163public EnumRowStatus(long valueIndex)164throws IllegalArgumentException {165this((int)valueIndex);166}167168/**169* Build an <code>EnumRowStatus</code> from an <code>Integer</code>.170* @param valueIndex should be either 0 (<i>unspecified</i>), or one of171* the values defined in RFC 2579.172* @exception IllegalArgumentException if the given173* <code>valueIndex</code> is not valid.174**/175public EnumRowStatus(Integer valueIndex)176throws IllegalArgumentException {177super(valueIndex);178}179180/**181* Build an <code>EnumRowStatus</code> from a <code>Long</code>.182* @param valueIndex should be either 0 (<i>unspecified</i>), or one of183* the values defined in RFC 2579.184* @exception IllegalArgumentException if the given185* <code>valueIndex</code> is not valid.186**/187public EnumRowStatus(Long valueIndex)188throws IllegalArgumentException {189this(valueIndex.longValue());190}191192/**193* Build an <code>EnumRowStatus</code> with <i>unspecified</i> value.194**/195public EnumRowStatus()196throws IllegalArgumentException {197this(unspecified);198}199200/**201* Build an <code>EnumRowStatus</code> from a <code>String</code>.202* @param x should be either "unspecified", or one of203* the values defined in RFC 2579 ("active", "notReady", etc...)204* @exception IllegalArgumentException if the given String205* <code>x</code> is not valid.206**/207public EnumRowStatus(String x)208throws IllegalArgumentException {209super(x);210}211212/**213* Build an <code>EnumRowStatus</code> from an <code>SnmpInt</code>.214* @param valueIndex should be either 0 (<i>unspecified</i>), or one of215* the values defined in RFC 2579.216* @exception IllegalArgumentException if the given217* <code>valueIndex</code> is not valid.218**/219public EnumRowStatus(SnmpInt valueIndex)220throws IllegalArgumentException {221this(valueIndex.intValue());222}223224/**225* Build an SnmpValue from this object.226*227* @exception IllegalArgumentException if this object holds an228* <i>unspecified</i> value.229* @return an SnmpInt containing this object value.230**/231public SnmpInt toSnmpValue()232throws IllegalArgumentException {233if (value == unspecified)234throw new235IllegalArgumentException("`unspecified' is not a valid SNMP value.");236return new SnmpInt(value);237}238239/**240* Check that the given <code>value</code> is valid.241*242* Valid values are:243* <ul><li><i>unspecified(0)</i></li>244* <li><i>active(1)</i></li>245* <li><i>notInService(2)</i></li>246* <li><i>notReady(3)</i></li>247* <li><i>createAndGo(4)</i></li>248* <li><i>createAndWait(5)</i></li>249* <li><i>destroy(6)</i></li>250* </ul>251*252**/253static public boolean isValidValue(int value) {254if (value < 0) return false;255if (value > 6) return false;256return true;257}258259// Documented in Enumerated260//261@Override262protected Hashtable<Integer, String> getIntTable() {263return EnumRowStatus.getRSIntTable();264}265266// Documented in Enumerated267//268@Override269protected Hashtable<String, Integer> getStringTable() {270return EnumRowStatus.getRSStringTable();271}272273static Hashtable<Integer, String> getRSIntTable() {274return intTable ;275}276277static Hashtable<String, Integer> getRSStringTable() {278return stringTable ;279}280281// Initialize the mapping tables.282//283final static Hashtable<Integer, String> intTable = new Hashtable<>();284final static Hashtable<String, Integer> stringTable = new Hashtable<>();285static {286intTable.put(new Integer(0), "unspecified");287intTable.put(new Integer(3), "notReady");288intTable.put(new Integer(6), "destroy");289intTable.put(new Integer(2), "notInService");290intTable.put(new Integer(5), "createAndWait");291intTable.put(new Integer(1), "active");292intTable.put(new Integer(4), "createAndGo");293stringTable.put("unspecified", new Integer(0));294stringTable.put("notReady", new Integer(3));295stringTable.put("destroy", new Integer(6));296stringTable.put("notInService", new Integer(2));297stringTable.put("createAndWait", new Integer(5));298stringTable.put("active", new Integer(1));299stringTable.put("createAndGo", new Integer(4));300}301302303}304305306