public class SnmpIPAddress extends SnmpOctetString
This SnmpIPAddress is used to extend the Snmp Octet String SMI class. This is normally used to transmit IP Addresses with a length of 4 bytes.
Most of the management of the data is handled by the base class.
Modifier and Type | Field and Description |
---|---|
static byte |
ASNTYPE
Defines the ASN.1 type for this object.
|
(package private) static long |
serialVersionUID
Required for evolving serialization format.
|
Constructor and Description |
---|
SnmpIPAddress()
Constructs a default object with a
length of zero.
|
SnmpIPAddress(byte[] data)
Constructs an Application String with the
passed data.
|
SnmpIPAddress(java.net.InetAddress inetAddr)
Constructs a new instance of the class with the IP
Address recovered from the passed address object.
|
SnmpIPAddress(SnmpIPAddress second)
Copy constructor.
|
SnmpIPAddress(SnmpOctetString second)
Copy constructor based on the base class.
|
SnmpIPAddress(java.lang.String inetAddr)
Constructs a new instance of the class with the IP address
of the evaluated argument.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Create a new object that is a duplicate of the
current object.
|
java.net.InetAddress |
convertToIpAddress()
Converts the current Application String to
an IPv4Address object.
|
int |
decodeASN(byte[] buf,
int offset,
AsnEncoder encoder)
Decodes the ASN.1 octet string from the passed buffer.
|
SnmpSyntax |
duplicate()
Create a new object that is a duplicate of the
current object.
|
void |
setString(byte[] data)
Sets the internal string array so that it is
identical to the passed array.
|
void |
setString(java.lang.String data)
Sets the internal octet string equal to the
converted stirng via the method getBytes().
|
java.lang.String |
toString()
Returns the application string as a
IPv4 dotted decimal address
|
byte |
typeId()
Returns the ASN.1 type for this object.
|
assumeString, encodeASN, getLength, getString
static final long serialVersionUID
public static final byte ASNTYPE
public SnmpIPAddress()
public SnmpIPAddress(byte[] data)
data
- The application string to manage (UTF-8)java.security.InvalidParameterException
- Thrown if the passed
buffer is not exactly 4 octets in size.public SnmpIPAddress(SnmpIPAddress second)
second
- The object to copy.public SnmpIPAddress(SnmpOctetString second)
second
- The object to copyjava.security.InvalidParameterException
- Thrown if the passed
buffer is not exactly 4 octets in size.public SnmpIPAddress(java.net.InetAddress inetAddr)
inetAddr
- The internet address instance that
contains the IP Address.public SnmpIPAddress(java.lang.String inetAddr) throws SnmpBadConversionException
InetAddress
class and
the returned address is encoded in this instance.inetAddr
- The string encoded IP Address to encapsulate.SnmpBadConversionException
- Thrown if the string address
cannot be converted to an IP Address.public byte typeId()
typeId
in interface SnmpSyntax
typeId
in class SnmpOctetString
public SnmpSyntax duplicate()
duplicate
in interface SnmpSyntax
duplicate
in class SnmpOctetString
public java.lang.Object clone()
clone
in class SnmpOctetString
public void setString(byte[] data)
Sets the internal string array so that it is identical to the passed array. The array is actually copied so that changes to data after the construction of the object are not reflected in the SnmpOctetString Object.
If the buffer is not valid according to the SNMP SMI then an exception is thrown and the object is not modified.
setString
in class SnmpOctetString
data
- The new octet string data.java.security.InvalidParameterException
- Thrown if
the passed buffer is not valid against the SMI definition.public void setString(java.lang.String data)
Sets the internal octet string equal to the converted stirng via the method getBytes(). This may cause some data corruption since the conversion is platform specific.
If the buffer is not valid according to the SNMP SMI then an exception is thrown and the object is not modified.
setString
in class SnmpOctetString
data
- The new octet string data.java.security.InvalidParameterException
- Thrown if
the passed buffer is not valid against the SMI definition.String.getBytes()
public int decodeASN(byte[] buf, int offset, AsnEncoder encoder) throws AsnDecodingException
decodeASN
in interface SnmpSyntax
decodeASN
in class SnmpOctetString
buf
- The encode bufferoffset
- The offset byte to begin decodingencoder
- The decoder object.AsnDecodingException
- Thrown by the encoder if an error
occurs trying to decode the data buffer.public java.net.InetAddress convertToIpAddress() throws SnmpBadConversionException
SnmpBadConversionException
- Thrown if the length of the string
is invalid. Must be equal to fourpublic java.lang.String toString()
toString
in class SnmpOctetString
Generated by iurt on 2015.