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.
|
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(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(String inetAddr)
Constructs a new instance of the class with the IP address of the
evaluated argument.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Create a new object that is a duplicate of the current object.
|
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(String data)
Sets the internal octet string equal to the converted stirng via the
method getBytes().
|
static InetAddress |
toInetAddress(SnmpIPAddress val) |
String |
toString()
Returns the application string as a IPv4 dotted decimal address
|
byte |
typeId()
Returns the ASN.1 type for this object.
|
assumeString, encodeASN, equals, getLength, getString, hashCode, toDisplayString, toHexString
public static final byte ASNTYPE
public SnmpIPAddress()
public SnmpIPAddress(byte[] data)
data
- The application string to manage (UTF-8)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 copyInvalidParameterException
- Thrown if the passed buffer is not exactly 4 octets in size.public SnmpIPAddress(InetAddress inetAddr)
inetAddr
- The internet address instance that contains the IP Address.public SnmpIPAddress(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 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.InvalidParameterException
- Thrown if the passed buffer is not valid against the SMI
definition.public void setString(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.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 InetAddress convertToIpAddress()
RuntimeException
- Thrown if the length of the string is invalid. Must be equal to four.public String toString()
toString
in class SnmpOctetString
public static InetAddress toInetAddress(SnmpIPAddress val)
Copyright © 2021. All rights reserved.