snmp
Class SNMPOctetString

java.lang.Object
  |
  +--snmp.SNMPObject
        |
        +--snmp.SNMPOctetString
Direct Known Subclasses:
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
protected  void extractFromBEREncoding(byte[] enc)
           
 byte[] getBEREncoding()
          Returns the BER encoding for the octet string.
 java.lang.Object getValue()
          Return the array of raw bytes.
 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, equals, finalize, getClass, hashCode, 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.
Overrides:
getValue in class SNMPObject

setValue

public void setValue(java.lang.Object data)
              throws SNMPBadValueException
Used to set the value from a byte array.
Overrides:
setValue in class SNMPObject
Throws:
SNMPBadValueException - Indicates an incorrect object type supplied.

getBEREncoding

public 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.
Overrides:
getBEREncoding in class SNMPObject

extractFromBEREncoding

protected void extractFromBEREncoding(byte[] enc)

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!)
Overrides:
toString in class SNMPObject

toHexString

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