snmp
Class SNMPOctetString

java.lang.Object
  extended bysnmp.SNMPObject
      extended bysnmp.SNMPOctetString
Direct Known Subclasses:
SNMPBitString, SNMPIPAddress, SNMPNSAPAddress

public class SNMPOctetString
extends SNMPObject

Class representing a general string of octets.


Field Summary
protected  byte[] data
           
protected  byte tag
           
 
Constructor Summary
SNMPOctetString()
          Create a zero-length octet string.
SNMPOctetString(byte[] enc)
          Create an octet string from the supplied byte array.
SNMPOctetString(java.lang.String stringData)
          Create an octet string from the bytes of the supplied String.
 
Method Summary
 boolean equals(java.lang.Object other)
          Checks the embedded arrays for equality.
protected  void extractFromBEREncoding(byte[] enc)
           
protected  byte[] getBEREncoding()
          Returns the BER encoding for the octet string.
 java.lang.Object getValue()
          Return the array of raw bytes.
 int hashCode()
          Generates a hash value so SNMP Octet String subclasses can be used in Hashtables.
 void setValue(java.lang.Object data)
          Used to set the value from a byte array.
 java.lang.String toHexString()
          Returns a space-separated hex string corresponding to the raw bytes.
 java.lang.String toString()
          Returns a String constructed from the raw bytes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected byte[] data

tag

protected byte tag
Constructor Detail

SNMPOctetString

public SNMPOctetString()
Create a zero-length octet string.


SNMPOctetString

public SNMPOctetString(java.lang.String stringData)
Create an octet string from the bytes of the supplied String.


SNMPOctetString

public SNMPOctetString(byte[] enc)
Create an octet string from the supplied byte array. The array may be either user-supplied, or part of a retrieved BER encoding. Note that the BER encoding of the data of an octet string is just the raw bytes.

Method Detail

getValue

public java.lang.Object getValue()
Return the array of raw bytes.

Specified by:
getValue in class SNMPObject

setValue

public void setValue(java.lang.Object data)
              throws SNMPBadValueException
Used to set the value from a byte array.

Specified by:
setValue in class SNMPObject
Throws:
SNMPBadValueException - Indicates an incorrect object type supplied.

getBEREncoding

protected byte[] getBEREncoding()
Returns the BER encoding for the octet string. Note the the "value" part of the BER type,length,value triple is just the sequence of raw bytes.

Specified by:
getBEREncoding in class SNMPObject

extractFromBEREncoding

protected void extractFromBEREncoding(byte[] enc)

equals

public boolean equals(java.lang.Object other)
Checks the embedded arrays for equality.

Overrides:
equals in class SNMPObject

hashCode

public int hashCode()
Generates a hash value so SNMP Octet String subclasses can be used in Hashtables.

Overrides:
hashCode in class SNMPObject

toString

public java.lang.String toString()
Returns a String constructed from the raw bytes. If the bytes contain non-printable ASCII characters, tant pis! (Though it's fun when the bell rings!)

Specified by:
toString in class SNMPObject

toHexString

public java.lang.String toHexString()
Returns a space-separated hex string corresponding to the raw bytes.