Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jmx/snmp/SnmpNull.java
38924 views
/*1* Copyright (c) 1997, 2011, 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*/242526package com.sun.jmx.snmp;27282930/**31* Represents an SNMP null value.32* <p><b>This API is a Sun Microsystems internal API and is subject33* to change without notice.</b></p>34*/3536public class SnmpNull extends SnmpValue {37private static final long serialVersionUID = 1783782515994279177L;3839// CONSTRUCTORS40//-------------41/**42* Constructs a new <CODE>SnmpNull</CODE>.43*/44public SnmpNull() {45tag = NullTag ;46}4748/**49* Constructs a new <CODE>SnmpNull</CODE>.50* <BR>For mibgen private use only.51*/52public SnmpNull(String dummy) {53this();54}5556/**57* Constructs a new <CODE>SnmpNull</CODE> from the specified tag value.58* @param t The initialization value.59*/60public SnmpNull(int t) {61tag = t ;62}6364// PUBLIC METHODS65//---------------66/**67* Returns the tag value of this <CODE>SnmpNull</CODE>.68* @return The value.69*/70public int getTag() {71return tag ;72}7374/**75* Converts the <CODE>NULL</CODE> value to its ASN.1 <CODE>String</CODE> form.76* When the tag is not the universal one, it is preprended77* to the <CODE>String</CODE> form.78* @return The <CODE>String</CODE> representation of the value.79*/80public String toString() {81String result = "" ;82if (tag != 5) {83result += "[" + tag + "] " ;84}85result += "NULL" ;86switch(tag) {87case errNoSuchObjectTag :88result += " (noSuchObject)" ;89break ;9091case errNoSuchInstanceTag :92result += " (noSuchInstance)" ;93break ;9495case errEndOfMibViewTag :96result += " (endOfMibView)" ;97break ;98}99return result ;100}101102/**103* Converts the <CODE>NULL</CODE> value to its <CODE>SnmpOid</CODE> form.104* Normally, a <CODE>NULL</CODE> value cannot be used as an index value,105* this method triggers an exception.106* @return The OID representation of the value.107*/108public SnmpOid toOid() {109throw new IllegalArgumentException() ;110}111112/**113* Performs a clone action. This provides a workaround for the114* <CODE>SnmpValue</CODE> interface.115* @return The SnmpValue clone.116*/117final synchronized public SnmpValue duplicate() {118return (SnmpValue) clone() ;119}120121/**122* Clones the <CODE>SnmpNull</CODE> object, making a copy of its data.123* @return The object clone.124*/125final synchronized public Object clone() {126SnmpNull newclone = null ;127try {128newclone = (SnmpNull) super.clone() ;129newclone.tag = tag ;130} catch (CloneNotSupportedException e) {131throw new InternalError(e) ; // vm bug.132}133return newclone ;134}135136/**137* Returns a textual description of the type object.138* @return ASN.1 textual description.139*/140final public String getTypeName() {141return name ;142}143144/**145* Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchObject</CODE> value.146* @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchObjectTag},147* <CODE>false</CODE> otherwise.148*/149public boolean isNoSuchObjectValue() {150return (tag == SnmpDataTypeEnums.errNoSuchObjectTag);151}152153/**154* Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchInstance</CODE> value.155* @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchInstanceTag},156* <CODE>false</CODE> otherwise.157*/158public boolean isNoSuchInstanceValue() {159return (tag == SnmpDataTypeEnums.errNoSuchInstanceTag);160}161162/**163* Checks if this <CODE>SnmpNull</CODE> object corresponds to an <CODE>endOfMibView</CODE> value.164* @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errEndOfMibViewTag},165* <CODE>false</CODE> otherwise.166*/167public boolean isEndOfMibViewValue() {168return (tag == SnmpDataTypeEnums.errEndOfMibViewTag);169}170171// VARIABLES172//----------173/**174* Name of the type.175*/176final static String name = "Null" ;177178/**179* This is the tag of the NULL value. By default, it is the universal tag value.180*/181private int tag = 5 ;182}183184185