com.adventnet.snmp.snmp2
Class SnmpIpv6Address

java.lang.Object
  extended by com.adventnet.snmp.snmp2.SnmpVar
      extended by com.adventnet.snmp.snmp2.SnmpIpv6Address
All Implemented Interfaces:
java.io.Serializable

public class SnmpIpv6Address
extends SnmpVar

Class of SNMP Ipv6Address Variable - Sub-class of SnmpVar. This class can be used to created a SnmpVar object of OCTET STRING TC such as Ipv6Address, InetAddress and InetAddressIPv6. It also has methods to retrieve the value in different forms(eg. String, byte). Value is stored as String of length 16 with each lower byte corresponding to the raw IPV6 address.

See Also:
Serialized Form

Field Summary
(package private)  java.lang.String address
           
(package private)  byte[] byteValue
           
(package private)  int count
           
static java.lang.String enc
          The Standard encoding string on which all encoding will be done.
(package private)  int indexCounter
           
(package private)  java.lang.String[] octetsValue
          Variabe Declration
(package private) static byte[] s_emptyString
           
(package private)  java.lang.String value
           
(package private)  java.lang.String zeroValue
           
 
Fields inherited from class com.adventnet.snmp.snmp2.SnmpVar
Type, varbindErrorVal
 
Constructor Summary
SnmpIpv6Address(byte[] address)
          Constructs a new SnmpIpv6Address by accepting the raw IP address - 16 bytes or 4 bytes for Ipv6Adderess/InetAddress datatype.
SnmpIpv6Address(java.lang.String ipv6Address)
          Constructs a new SnmpIpv6Address with the specified host name or IP address as a string.
SnmpIpv6Address(java.lang.String ipv6Address, java.lang.String enc)
          Constructs a new SnmpIpv6Address with the specified host name or IP address as a string.
 
Method Summary
static SnmpVar createVariable(java.lang.String value, byte type)
          Creates a new SnmpVar object with the specified value and of type SnmpAPI.STRING.
(package private)  int encode(byte[] buff, int space)
          ASN encoder
 java.lang.Object getVarObject()
          Returns the value of this SnmpIpv6Address object as a printable string object.
static java.lang.String Ipv6bToString(byte[] byteValue)
          A converter from raw IP address (byte[]) to string.
(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 toString()
          To convert the value of this SnmpString object to a printable ipv6Address format
 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
getError, getNumericValueAsString, getType, getTypeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

s_emptyString

static final byte[] s_emptyString

value

java.lang.String value

byteValue

byte[] byteValue

enc

public static java.lang.String enc
The Standard encoding string on which all encoding will be done. This will refer to SnmpAPI for the encoding string.


octetsValue

java.lang.String[] octetsValue
Variabe Declration


zeroValue

java.lang.String zeroValue

indexCounter

int indexCounter

count

int count

address

java.lang.String address
Constructor Detail

SnmpIpv6Address

public SnmpIpv6Address(java.lang.String ipv6Address)
Constructs a new SnmpIpv6Address with the specified host name or IP address as a string. This does not throw any exceptions. To ensure that a valid IpAddress is created, always try to use a colon format ipv6 address. Supplying host name to this constructor could result in delays caused by DNS lookups and in case a failure occurs then the toValue will return a null. If DNS lookups returns ipaddress as ipv4, it will create SnmpIpv6Address instance as with ipv4Address. If a 'null' parameter is passed as an argument to this constructor, then the object will be initialized with the IP-address "0000:0000:0000:0000:0000:0000:0000:0000".

Parameters:
ipv6Address - host name or IP address as a string.

SnmpIpv6Address

public SnmpIpv6Address(java.lang.String ipv6Address,
                       java.lang.String enc)
Constructs a new SnmpIpv6Address with the specified host name or IP address as a string. This does not throw any exceptions. To ensure that a valid IpAddress is created, always try to use a colon format ipv6 address. Supplying host name to this constructor could result in delays caused by DNS lookups and in case a failure occurs then the toValue will return a null. If DNS lookups returns ipaddress as ipv4, it will create SnmpIpv6Address instance as with ipv4Address. If a 'null' parameter is passed as an argument to this constructor, then the object will be initialized with the IP-address "0000:0000:0000:0000:0000:0000:0000:0000".

Parameters:
ipv6Address - host name or IP address as a string.
enc - The string for the encoding scheme to be used.

SnmpIpv6Address

public SnmpIpv6Address(byte[] address)
Constructs a new SnmpIpv6Address by accepting the raw IP address - 16 bytes or 4 bytes for Ipv6Adderess/InetAddress datatype.

Parameters:
address - raw IPv6 address - 16 bytes/ 4 bytes
Method Detail

newInstance

static SnmpVar newInstance(byte[] b)
Factory method for decode

Parameters:
b - The bytearray return The snmp variable

getVarObject

public java.lang.Object getVarObject()
Returns the value of this SnmpIpv6Address object as a printable string object. This method is the same as toValue()

Specified by:
getVarObject in class SnmpVar
Returns:
the value of SnmpIpv6Address object as a printable string.

toValue

public java.lang.Object toValue()
Returns the value of this SnmpString object as a printable string object. This method is the same as toString()

Specified by:
toValue in class SnmpVar
Returns:
the value of SnmpIpv6Address object as a printable string.

toBytes

public byte[] toBytes()
To return the value of this SnmpString object as raw bytes. To avoid any kind of problems with String encoding, one can use this method to retrive the value. Similarly one can use the new SnmpString(byte[]) for creating new SnmpString object. With these methods none of the String encoding routines in java is used. Instead it uses the bytes directly.

Specified by:
toBytes in class SnmpVar
Returns:
The value of this SnmpIpv6Address as byte value.

encode

int encode(byte[] buff,
           int space)
     throws java.lang.ArrayIndexOutOfBoundsException
ASN encoder

Specified by:
encode in class SnmpVar
Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

toString

public java.lang.String toString()
To convert the value of this SnmpString object to a printable ipv6Address format

Specified by:
toString in class SnmpVar
Returns:
the value of SnmpString object as a printable string.

Ipv6bToString

public static java.lang.String Ipv6bToString(byte[] byteValue)
A converter from raw IP address (byte[]) to string. This takes the IP address as a byte[] and returns as a string in the form x:x:x:x:x:x:x:x .

Parameters:
rawIpAddr - The IP Address as a byte[].
Returns:
The value of the IPAddress as a string in the form x:x:x:x:x:x:x:x .

toTagString

public 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:. For e.g if the SnmpString has the value 3f fe 0b 00 0c 18 1f ff 02 d0 70 ff fe 00 29 c0, then this method will return - STRING: 3ffe:b00:c18:1fff:2d0:70ff:fe00:29c0. If the SnmpString has the value of 7F 00 00 01, then this method will return STRING - 127.0.0.1

Specified by:
toTagString in class SnmpVar
Returns:
the value of SnmpString object as a printable string where the type is tagged before the value with a Tag - STRING: ipv6Address value.

createVariable

public static SnmpVar createVariable(java.lang.String value,
                                     byte type)
                              throws SnmpException
Creates a new SnmpVar object with the specified value and of type SnmpAPI.STRING.

Parameters:
value - String value for creating a new SnmpVar object.
type - SnmpAPI.STRING type (a constant from SnmpAPI) for creating a new SnmpVar object.
Returns:
the SnmpVar object created.
Throws:
SnmpException - is thrown when the type is other than SnmpAPI.STRING.