HOME

com.ireasoning.protocol.snmp
Class SnmpOctetString

java.lang.Object
  extended bycom.ireasoning.protocol.snmp.SnmpOctetString
All Implemented Interfaces:
Msg, Serializable, SnmpDataType
Direct Known Subclasses:
SnmpBits, SnmpDateAndTime, SnmpIpAddress, SnmpOpaque

public class SnmpOctetString
extends Object
implements SnmpDataType

This class represents Snmp OCTET STRING data type. The OCTET STRING type represents arbitrary binary or textual data.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.ireasoning.protocol.snmp.SnmpDataType
BITS, BITSTRING, COUNTER32, COUNTER64, END_OF_MIB_VIEW, END_OF_MIB_VIEW_OBJECT, GAUGE32, INTEGER, IPADDRESS, NO_SUCH_INSTANCE, NO_SUCH_INSTANCE_OBJECT, NO_SUCH_OBJECT, NO_SUCH_OBJECT_OBJECT, NULL, OCTETSTRING, OID, OPAQUE, PDU, SEQUENCE, SEQUENCEOF, serialVersionUID, TIMETICKS, UNSIGNED32, VARBIND
 
Fields inherited from interface com.ireasoning.protocol.Msg
ERROR_TYPE
 
Constructor Summary
SnmpOctetString()
          Constructs an empty SnmpOctetString object, whose toString() method should return "" just after construction.
SnmpOctetString(byte[] data)
          Constructs an SnmpOctetString object with the passed data.
SnmpOctetString(SnmpOctetString s)
          Makes a copy of passed in SnmpOctetString object
SnmpOctetString(String data)
          Constructs an SnmpOctetString object from passed data, whose toString() method should return a String equals to passed data just after construction.
 
Method Summary
static String convertPhysAddress(String addr)
          Converts passed physAddress to hex format.
 SnmpDataType copy()
          Makes a copy of itself
 int encode(com.ireasoning.protocol.snmp.SnmpEncoder encoder)
          For internal use
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
static byte[] getBytes(String text)
          Converts the passed String object, which is in hex format (The returned value of toHexString() method of this class, such as "0xAC 0x12 0xFF" ( or "0xAC 12 FF", or "0xAC12FF), each bytes separated by space), to byte array
 int getLength()
          Returns the number of bytes of this octet string
 int getType()
          Returns SnmpDataType.OCTETSTRING
 String getTypeString()
          Returns "OctetString"
 byte[] getValue()
          Returns byte array representation of this object
 int hashCode()
          Returns a hash code value for the object
 void setValue(byte[] v)
          Sets a new value
 String toHexString()
          Returns hex format of this string.
 String toPrintableString()
          Returns a String representation of this object.
 String toString()
          Returns a String representation of this object.
 String toString(String charsetName)
          Return a string decoded using the specified charset
 String toString2()
          Returns a java String representation, even if this object contains non-displayable character
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SnmpOctetString

public SnmpOctetString()
Constructs an empty SnmpOctetString object, whose toString() method should return "" just after construction.


SnmpOctetString

public SnmpOctetString(String data)
Constructs an SnmpOctetString object from passed data, whose toString() method should return a String equals to passed data just after construction.


SnmpOctetString

public SnmpOctetString(byte[] data)
Constructs an SnmpOctetString object with the passed data.


SnmpOctetString

public SnmpOctetString(SnmpOctetString s)
Makes a copy of passed in SnmpOctetString object

Method Detail

getLength

public int getLength()
Returns the number of bytes of this octet string

Returns:
The length of the octet string.

getType

public int getType()
Returns SnmpDataType.OCTETSTRING

Specified by:
getType in interface SnmpDataType
Returns:
the object data type

getTypeString

public String getTypeString()
Returns "OctetString"

Specified by:
getTypeString in interface SnmpDataType

toString

public String toString()
Returns a String representation of this object. If this object contains a non-displayable character, it will be automatically switch to hex format, that is, result is the same as toHexString() method.


toString2

public String toString2()
Returns a java String representation, even if this object contains non-displayable character

See Also:
toHexString()

toString

public String toString(String charsetName)
                throws UnsupportedEncodingException
Return a string decoded using the specified charset

Parameters:
charsetName - charsetName - The name of a supported charset
Throws:
UnsupportedEncodingException

toPrintableString

public String toPrintableString()
Returns a String representation of this object. Non-displayable character in it will be changed to '.'


toHexString

public String toHexString()
Returns hex format of this string. The result will be something like "0x00 0xBA ..."

See Also:
toString2(), toString()

copy

public SnmpDataType copy()
Description copied from interface: SnmpDataType
Makes a copy of itself

Specified by:
copy in interface SnmpDataType
Returns:
a deep copy of this object

getValue

public byte[] getValue()
Returns byte array representation of this object

Returns:
byte array representation of this object

setValue

public void setValue(byte[] v)
Sets a new value


encode

public int encode(com.ireasoning.protocol.snmp.SnmpEncoder encoder)
           throws SnmpEncodingException
Description copied from interface: SnmpDataType
For internal use

Specified by:
encode in interface SnmpDataType
Throws:
SnmpEncodingException

equals

public boolean equals(Object obj)
Description copied from interface: SnmpDataType
Indicates whether some other object is "equal to" this one.

Specified by:
equals in interface SnmpDataType

hashCode

public int hashCode()
Description copied from interface: SnmpDataType
Returns a hash code value for the object

Specified by:
hashCode in interface SnmpDataType

getBytes

public static byte[] getBytes(String text)
Converts the passed String object, which is in hex format (The returned value of toHexString() method of this class, such as "0xAC 0x12 0xFF" ( or "0xAC 12 FF", or "0xAC12FF), each bytes separated by space), to byte array

See Also:
toHexString()

convertPhysAddress

public static String convertPhysAddress(String addr)
Converts passed physAddress to hex format. For example, "00-A0-D1-61-01-B2" will be convert a String of bytes { 0x00, 0xA0, 0xD1, 0x61, 0x01, 0xB2}

Parameters:
addr - MAC address, space or '-' are allowed

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.