|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.adventnet.snmp.snmp2.SnmpVar
com.adventnet.snmp.snmp2.SnmpString
public class SnmpString
Class of SNMP String Variable - Sub-class of SnmpVar. This class can be used to create an SnmpVar object of type SnmpString. It also has methods to retrieve the value in different forms(eg. String, byte). Some Notes : A hex string can also be specified in the constructor of this object. To do so just enclose the string within single quotes with each byte separated by a colon. For example for 0x09a2bec3 use new SnmpString("'09:a2:be:c3'").
All the String encoding will be done based on the encoding set in the SnmpAPI. The default encoding string will be ISO8859_1 which is the standard one. To avoid any kind of problems with String encoding, one can also use the new SnmpString(byte[] b) for creating and toBytes() method for retrieving the values of SnmpVar objects. With these methods none of the String encoding routines in java is used. Instead it uses the bytes directly.
| Field Summary | |
|---|---|
(package private) byte[] |
byteValue
|
static java.lang.String |
enc
The Standard encoding string on which all encoding will be done. |
(package private) static byte[] |
s_emptyString
|
(package private) java.lang.String |
value
|
| Fields inherited from class com.adventnet.snmp.snmp2.SnmpVar |
|---|
Type, varbindErrorVal |
| Constructor Summary | |
|---|---|
protected |
SnmpString()
Constuctor to keep subclasses happy |
|
SnmpString(byte[] b)
Constructs a new SnmpString with the specified byte array of octect string. |
|
SnmpString(java.lang.String s)
Constructs a new SnmpString with initial value = s . |
|
SnmpString(java.lang.String s,
java.lang.String enc)
Constructs a new SnmpString with initial value = s and encoding enc. |
| Method Summary | |
|---|---|
(package private) int |
encode(byte[] buff,
int space)
ASN encoder |
boolean |
equals(java.lang.Object obj)
Returns true if both the SnmpString objects are equal. |
java.lang.String |
getNumericValueAsString()
This method will throw UnsupportedOperationException since this is not a numeric data type. |
java.lang.Object |
getVarObject()
Returns the value of this SnmpString object as a printable string object. |
(package private) static SnmpVar |
newInstance(byte[] b)
Factory method for decode |
byte[] |
toBytes()
To return the value of this SnmpString object as raw bytes. |
java.lang.String |
toByteString()
To convert the value of this SnmpString object to a printable HEX string. |
java.lang.String |
toString()
To convert the value of this SnmpString object to a printable string |
java.lang.String |
toTagString()
To convert the value of this SnmpString object to a printable string where the type is tagged before the value with a tag STRING:. |
java.lang.Object |
toValue()
Returns the value of this SnmpString object as a printable string object. |
| Methods inherited from class com.adventnet.snmp.snmp2.SnmpVar |
|---|
createVariable, getError, getType, getTypeString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
static final byte[] s_emptyString
java.lang.String value
byte[] byteValue
public static java.lang.String enc
| Constructor Detail |
|---|
protected SnmpString()
public SnmpString(java.lang.String s)
s - The string value for creating a new SnmpString object.
public SnmpString(java.lang.String s,
java.lang.String enc)
s - The value for this SnmpString object.enc - The string for the encoding scheme to be used.public SnmpString(byte[] b)
b - The byte array of octet string| Method Detail |
|---|
static SnmpVar newInstance(byte[] b)
b - The bytearray
return The snmp variablepublic java.lang.Object getVarObject()
getVarObject in class SnmpVarpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the SnmpString object which is to be checked for equality.
public java.lang.Object toValue()
toValue in class SnmpVarpublic java.lang.String toString()
toString in class SnmpVarpublic java.lang.String toTagString()
toTagString in class SnmpVarpublic java.lang.String toByteString()
public byte[] toBytes()
toBytes in class SnmpVarpublic java.lang.String getNumericValueAsString()
getNumericValueAsString in class SnmpVarjava.lang.UnsupportedOperationException - Since this
is not a numeric data type.
int encode(byte[] buff,
int space)
throws java.lang.ArrayIndexOutOfBoundsException
encode in class SnmpVarbuff - The buffer into which the value is to be encodedspace - The number of free bytes in the buffer
java.lang.ArrayIndexOutOfBoundsException - When there is
insufficient space in buffer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||