0N/A/*
2362N/A * Copyright (c) 1997, 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/A
0N/Apackage com.sun.jmx.snmp;
0N/A
0N/A
0N/A
0N/A/**
0N/A * Represents an SNMP null value.
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 SnmpNull extends SnmpValue {
0N/A private static final long serialVersionUID = 1783782515994279177L;
0N/A
0N/A // CONSTRUCTORS
0N/A //-------------
0N/A /**
0N/A * Constructs a new <CODE>SnmpNull</CODE>.
0N/A */
0N/A public SnmpNull() {
0N/A tag = NullTag ;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new <CODE>SnmpNull</CODE>.
0N/A * <BR>For mibgen private use only.
0N/A */
0N/A public SnmpNull(String dummy) {
0N/A this();
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new <CODE>SnmpNull</CODE> from the specified tag value.
0N/A * @param t The initialization value.
0N/A */
0N/A public SnmpNull(int t) {
0N/A tag = t ;
0N/A }
0N/A
0N/A // PUBLIC METHODS
0N/A //---------------
0N/A /**
0N/A * Returns the tag value of this <CODE>SnmpNull</CODE>.
0N/A * @return The value.
0N/A */
0N/A public int getTag() {
0N/A return tag ;
0N/A }
0N/A
0N/A /**
0N/A * Converts the <CODE>NULL</CODE> value to its ASN.1 <CODE>String</CODE> form.
0N/A * When the tag is not the universal one, it is preprended
0N/A * to the <CODE>String</CODE> form.
0N/A * @return The <CODE>String</CODE> representation of the value.
0N/A */
0N/A public String toString() {
0N/A String result = "" ;
0N/A if (tag != 5) {
0N/A result += "[" + tag + "] " ;
0N/A }
0N/A result += "NULL" ;
0N/A switch(tag) {
0N/A case errNoSuchObjectTag :
0N/A result += " (noSuchObject)" ;
0N/A break ;
0N/A
0N/A case errNoSuchInstanceTag :
0N/A result += " (noSuchInstance)" ;
0N/A break ;
0N/A
0N/A case errEndOfMibViewTag :
0N/A result += " (endOfMibView)" ;
0N/A break ;
0N/A }
0N/A return result ;
0N/A }
0N/A
0N/A /**
0N/A * Converts the <CODE>NULL</CODE> value to its <CODE>SnmpOid</CODE> form.
0N/A * Normally, a <CODE>NULL</CODE> value cannot be used as an index value,
0N/A * this method triggers an exception.
0N/A * @return The OID representation of the value.
0N/A */
0N/A public SnmpOid toOid() {
0N/A throw new IllegalArgumentException() ;
0N/A }
0N/A
0N/A /**
0N/A * Performs a clone action. This provides a workaround for the
0N/A * <CODE>SnmpValue</CODE> interface.
0N/A * @return The SnmpValue clone.
0N/A */
0N/A final synchronized public SnmpValue duplicate() {
0N/A return (SnmpValue) clone() ;
0N/A }
0N/A
0N/A /**
0N/A * Clones the <CODE>SnmpNull</CODE> object, making a copy of its data.
0N/A * @return The object clone.
0N/A */
0N/A final synchronized public Object clone() {
0N/A SnmpNull newclone = null ;
0N/A try {
0N/A newclone = (SnmpNull) super.clone() ;
0N/A newclone.tag = tag ;
0N/A } catch (CloneNotSupportedException e) {
0N/A throw new InternalError() ; // vm bug.
0N/A }
0N/A return newclone ;
0N/A }
0N/A
0N/A /**
0N/A * Returns a textual description of the type object.
0N/A * @return ASN.1 textual description.
0N/A */
0N/A final public String getTypeName() {
0N/A return name ;
0N/A }
0N/A
0N/A /**
0N/A * Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchObject</CODE> value.
0N/A * @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchObjectTag},
0N/A * <CODE>false</CODE> otherwise.
0N/A */
0N/A public boolean isNoSuchObjectValue() {
0N/A return (tag == SnmpDataTypeEnums.errNoSuchObjectTag);
0N/A }
0N/A
0N/A /**
0N/A * Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchInstance</CODE> value.
0N/A * @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchInstanceTag},
0N/A * <CODE>false</CODE> otherwise.
0N/A */
0N/A public boolean isNoSuchInstanceValue() {
0N/A return (tag == SnmpDataTypeEnums.errNoSuchInstanceTag);
0N/A }
0N/A
0N/A /**
0N/A * Checks if this <CODE>SnmpNull</CODE> object corresponds to an <CODE>endOfMibView</CODE> value.
0N/A * @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errEndOfMibViewTag},
0N/A * <CODE>false</CODE> otherwise.
0N/A */
0N/A public boolean isEndOfMibViewValue() {
0N/A return (tag == SnmpDataTypeEnums.errEndOfMibViewTag);
0N/A }
0N/A
0N/A // VARIABLES
0N/A //----------
0N/A /**
0N/A * Name of the type.
0N/A */
0N/A final static String name = "Null" ;
0N/A
0N/A /**
0N/A * This is the tag of the NULL value. By default, it is the universal tag value.
0N/A */
0N/A private int tag = 5 ;
0N/A}