public class IpAddress extends SMIAddress implements AssignableFromByteArray
IpAddress class represents an IPv4 address SNMP variable.| Modifier and Type | Field and Description |
|---|---|
static InetAddress |
ANY_IPADDRESS |
SMISYNTAXES_PROPERTIES| Constructor and Description |
|---|
IpAddress()
Creates a
0.0.0.0 IP address. |
IpAddress(byte[] addressBytes)
Create an IP address from a raw IP address.
|
IpAddress(InetAddress address)
Creates an IP address from an
InetAddress |
IpAddress(String address)
Create an IP address from an address string.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Clones this variable.
|
int |
compareTo(Variable o) |
void |
decodeBER(BERInputStream inputStream)
Decodes a
Variable from an InputStream. |
void |
encodeBER(OutputStream outputStream)
Encodes a
Variable to an OutputStream. |
boolean |
equals(Object o) |
void |
fromSubIndex(OID subIndex,
boolean impliedLength)
Sets the value of this
Variable from the supplied (sub-)index. |
int |
getBERLength()
Returns the length of this
Variable in bytes when encoded
according to the Basic Encoding Rules (BER). |
InetAddress |
getInetAddress() |
int |
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable.
|
int |
hashCode() |
boolean |
isValid()
Checks whether this
Address is a valid transport address. |
static Address |
parse(String address)
Parses an IP address string and returns the corresponding
IpAddress instance. |
boolean |
parseAddress(String address)
Parses the address from the supplied string representation.
|
void |
setAddress(byte[] rawValue) |
void |
setInetAddress(InetAddress inetAddress) |
void |
setValue(byte[] value)
Sets the value of this object from the supplied byte array.
|
void |
setValue(String value)
Sets the address value from the supplied String.
|
byte[] |
toByteArray()
Returns the value of this object as a byte array.
|
int |
toInt()
Returns an integer representation of this variable if
such a representation exists.
|
long |
toLong()
Returns a long representation of this variable if
such a representation exists.
|
String |
toString()
Gets a string representation of the variable.
|
OID |
toSubIndex(boolean impliedLength)
Converts the value of this
Variable to a (sub-)index
value. |
createFromBER, createFromSyntax, equal, getBERPayloadLength, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isExceptionpublic static final InetAddress ANY_IPADDRESS
public IpAddress()
0.0.0.0 IP address.public IpAddress(InetAddress address)
InetAddressaddress - an InetAddress instance (must not necessarily be a IPv4
address).public IpAddress(String address)
address - an IP address String.Address.parseAddress(String address)public IpAddress(byte[] addressBytes)
addressBytes - the raw IP address in network byte order.public int getSyntax()
AbstractVariablegetSyntax in interface VariablegetSyntax in class AbstractVariablepublic boolean isValid()
AddressAddress is a valid transport address.public String toString()
AbstractVariabletoString in interface VariabletoString in class AbstractVariablepublic int hashCode()
hashCode in interface VariablehashCode in class AbstractVariablepublic static Address parse(String address)
IpAddress instance.address - an IP address string which may be a host name or a numerical IP address.IpAddress instance or null if
address cannot not be parsed.Address.parseAddress(String address)public boolean parseAddress(String address)
AddressparseAddress in interface Addressaddress - a String representation of this address.true if address could be successfully
parsed and has been assigned to this address object, false
otherwise.public int compareTo(Variable o)
compareTo in interface Comparable<Variable>compareTo in interface VariablecompareTo in class AbstractVariablepublic boolean equals(Object o)
equals in interface Variableequals in class AbstractVariablepublic void decodeBER(BERInputStream inputStream) throws IOException
AbstractVariableVariable from an InputStream.decodeBER in interface BERSerializabledecodeBER in class AbstractVariableinputStream - an InputStream containing a BER encoded byte stream.IOException - if the stream could not be decoded by using BER rules.public void encodeBER(OutputStream outputStream) throws IOException
AbstractVariableVariable to an OutputStream.encodeBER in interface BERSerializableencodeBER in class AbstractVariableoutputStream - an OutputStream.IOException - if an error occurs while writing to the stream.public int getBERLength()
AbstractVariableVariable in bytes when encoded
according to the Basic Encoding Rules (BER).getBERLength in interface BERSerializablegetBERLength in class AbstractVariablepublic void setAddress(byte[] rawValue)
throws UnknownHostException
UnknownHostExceptionpublic void setInetAddress(InetAddress inetAddress)
public InetAddress getInetAddress()
public Object clone()
Variableclone in interface Variableclone in class AbstractVariableVariable with the same value.public int toInt()
AbstractVariabletoInt in interface VariabletoInt in class AbstractVariablepublic long toLong()
AbstractVariabletoLong in interface VariabletoLong in class AbstractVariablepublic OID toSubIndex(boolean impliedLength)
AbstractVariableVariable to a (sub-)index
value.toSubIndex in interface VariabletoSubIndex in class AbstractVariableimpliedLength - specifies if the sub-index has an implied length. This parameter applies
to variable length variables only (e.g. OctetString and
OID). For other variables it has no effect.public void fromSubIndex(OID subIndex, boolean impliedLength)
AbstractVariableVariable from the supplied (sub-)index.fromSubIndex in interface VariablefromSubIndex in class AbstractVariablesubIndex - the sub-index OID.impliedLength - specifies if the sub-index has an implied length. This parameter applies
to variable length variables only (e.g. OctetString and
OID). For other variables it has no effect.public void setValue(String value)
AddressIllegalArgumentException runtime exception is thrown.setValue in interface AddresssetValue in interface AssignableFromStringvalue - an address String.public void setValue(byte[] value)
AssignableFromByteArraysetValue in interface AssignableFromByteArrayvalue - a byte array.public byte[] toByteArray()
AssignableFromByteArraytoByteArray in interface AssignableFromByteArrayCopyright © 2016 SNMP4J.org. All Rights Reserved.