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