jdk/src/share/classes/com/sun/jmx/snmp/SnmpNull.java
author sherman
Tue, 30 Aug 2011 11:53:11 -0700
changeset 10419 12c063b39232
parent 5506 202f599c92aa
child 14342 8435a30053c1
permissions -rw-r--r--
7084245: Update usages of InternalError to use exception chaining Summary: to use new InternalError constructor with cause chainning Reviewed-by: alanb, ksrini, xuelei, neugens Contributed-by: sebastian.sickelmann@gmx.de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package com.sun.jmx.snmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Represents an SNMP null value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p><b>This API is a Sun Microsystems internal API  and is subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * to change without notice.</b></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class SnmpNull extends SnmpValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    private static final long serialVersionUID = 1783782515994279177L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    // CONSTRUCTORS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    //-------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * Constructs a new <CODE>SnmpNull</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    public SnmpNull() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        tag = NullTag ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * Constructs a new <CODE>SnmpNull</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * <BR>For mibgen private use only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public SnmpNull(String dummy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        this();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * Constructs a new <CODE>SnmpNull</CODE> from the specified tag value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @param t The initialization value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public SnmpNull(int t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        tag = t ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // PUBLIC METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    //---------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Returns the tag value of this <CODE>SnmpNull</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @return The value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public int getTag() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        return tag ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Converts the <CODE>NULL</CODE> value to its ASN.1 <CODE>String</CODE> form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * When the tag is not the universal one, it is preprended
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * to the <CODE>String</CODE> form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @return The <CODE>String</CODE> representation of the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        String result = "" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (tag != 5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            result += "[" + tag + "] " ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        result += "NULL" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        switch(tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        case errNoSuchObjectTag :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            result += " (noSuchObject)" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            break ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        case errNoSuchInstanceTag :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            result += " (noSuchInstance)" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            break ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        case errEndOfMibViewTag :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            result += " (endOfMibView)" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            break ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        return result ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Converts the <CODE>NULL</CODE> value to its <CODE>SnmpOid</CODE> form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Normally, a <CODE>NULL</CODE> value cannot be used as an index value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * this method triggers an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @return The OID representation of the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public SnmpOid toOid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        throw new IllegalArgumentException() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Performs a clone action. This provides a workaround for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * <CODE>SnmpValue</CODE> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @return The SnmpValue clone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    final synchronized public SnmpValue duplicate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        return (SnmpValue) clone() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Clones the <CODE>SnmpNull</CODE> object, making a copy of its data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @return The object clone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    final synchronized public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        SnmpNull  newclone = null ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            newclone = (SnmpNull) super.clone() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            newclone.tag = tag ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        } catch (CloneNotSupportedException e) {
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
   132
            throw new InternalError(e) ; // vm bug.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        return newclone ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Returns a textual description of the type object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return ASN.1 textual description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    final public String getTypeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return name ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchObject</CODE> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchObjectTag},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <CODE>false</CODE> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public boolean isNoSuchObjectValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return (tag == SnmpDataTypeEnums.errNoSuchObjectTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchInstance</CODE> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchInstanceTag},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * <CODE>false</CODE> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public boolean isNoSuchInstanceValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return (tag == SnmpDataTypeEnums.errNoSuchInstanceTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Checks if this <CODE>SnmpNull</CODE> object corresponds to an <CODE>endOfMibView</CODE> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errEndOfMibViewTag},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * <CODE>false</CODE> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public boolean isEndOfMibViewValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return (tag == SnmpDataTypeEnums.errEndOfMibViewTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    // VARIABLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    //----------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Name of the type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    final static String name = "Null" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * This is the tag of the NULL value. By default, it is the universal tag value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    private int tag = 5 ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
}