|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.snmp4j.smi.AbstractVariable
org.snmp4j.smi.SMIAddress
org.snmp4j.smi.IpAddress
public class IpAddress
The IpAddress
class represents an IPv4 address SNMP variable.
Field Summary | |
---|---|
static java.net.InetAddress |
ANY_IPADDRESS
|
Fields inherited from class org.snmp4j.smi.AbstractVariable |
---|
SMISYNTAXES_PROPERTIES |
Constructor Summary | |
---|---|
IpAddress()
Creates a 0.0.0.0 IP address. |
|
IpAddress(byte[] addressBytes)
Create an IP address from a raw IP address. |
|
IpAddress(java.net.InetAddress address)
Creates an IP address from an InetAddress |
|
IpAddress(java.lang.String address)
Create an IP address from an address string. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Clones this variable. |
int |
compareTo(java.lang.Object o)
|
void |
decodeBER(BERInputStream inputStream)
Decodes a Variable from an InputStream . |
void |
encodeBER(java.io.OutputStream outputStream)
Encodes a Variable to an OutputStream . |
boolean |
equals(java.lang.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). |
java.net.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(java.lang.String address)
Parses an IP address string and returns the corresponding IpAddress instance. |
boolean |
parseAddress(java.lang.String address)
Parses the address from the supplied string representation. |
void |
setAddress(byte[] rawValue)
|
void |
setInetAddress(java.net.InetAddress inetAddress)
|
void |
setValue(byte[] value)
Sets the value of this object from the supplied byte array. |
void |
setValue(java.lang.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. |
java.lang.String |
toString()
Gets a string representation of the variable. |
OID |
toSubIndex(boolean impliedLength)
Converts the value of this Variable to a (sub-)index
value. |
Methods inherited from class org.snmp4j.smi.AbstractVariable |
---|
createFromBER, createFromSyntax, getBERPayloadLength, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.net.InetAddress ANY_IPADDRESS
Constructor Detail |
---|
public IpAddress()
0.0.0.0
IP address.
public IpAddress(java.net.InetAddress address)
InetAddress
address
- an InetAddress
instance (must not necessarily be a IPv4
address).public IpAddress(java.lang.String address)
address
- an IP address String.Address.parseAddress(String address)
public IpAddress(byte[] addressBytes)
addressBytes
- the raw IP address in network byte order.Method Detail |
---|
public int getSyntax()
AbstractVariable
getSyntax
in interface Variable
getSyntax
in class AbstractVariable
public boolean isValid()
Address
Address
is a valid transport address.
isValid
in interface Address
true
if the address is valid, false
otherwise.public java.lang.String toString()
AbstractVariable
toString
in interface Variable
toString
in class AbstractVariable
public int hashCode()
hashCode
in interface Variable
hashCode
in class AbstractVariable
public static Address parse(java.lang.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(java.lang.String address)
Address
parseAddress
in interface Address
address
- 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(java.lang.Object o)
compareTo
in interface java.lang.Comparable
compareTo
in interface Variable
compareTo
in class AbstractVariable
public boolean equals(java.lang.Object o)
equals
in interface Variable
equals
in class AbstractVariable
public void decodeBER(BERInputStream inputStream) throws java.io.IOException
AbstractVariable
Variable
from an InputStream
.
decodeBER
in interface BERSerializable
decodeBER
in class AbstractVariable
inputStream
- an InputStream
containing a BER encoded byte stream.
java.io.IOException
- if the stream could not be decoded by using BER rules.public void encodeBER(java.io.OutputStream outputStream) throws java.io.IOException
AbstractVariable
Variable
to an OutputStream
.
encodeBER
in interface BERSerializable
encodeBER
in class AbstractVariable
outputStream
- an OutputStream
.
java.io.IOException
- if an error occurs while writing to the stream.public int getBERLength()
AbstractVariable
Variable
in bytes when encoded
according to the Basic Encoding Rules (BER).
getBERLength
in interface BERSerializable
getBERLength
in class AbstractVariable
public void setAddress(byte[] rawValue) throws java.net.UnknownHostException
java.net.UnknownHostException
public void setInetAddress(java.net.InetAddress inetAddress)
public java.net.InetAddress getInetAddress()
public java.lang.Object clone()
Variable
clone
in interface Variable
clone
in class AbstractVariable
Variable
with the same value.public int toInt()
AbstractVariable
toInt
in interface Variable
toInt
in class AbstractVariable
public long toLong()
AbstractVariable
toLong
in interface Variable
toLong
in class AbstractVariable
public OID toSubIndex(boolean impliedLength)
AbstractVariable
Variable
to a (sub-)index
value.
toSubIndex
in interface Variable
toSubIndex
in class AbstractVariable
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 fromSubIndex(OID subIndex, boolean impliedLength)
AbstractVariable
Variable
from the supplied (sub-)index.
fromSubIndex
in interface Variable
fromSubIndex
in class AbstractVariable
subIndex
- 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(java.lang.String value)
Address
IllegalArgumentException
runtime exception is thrown.
setValue
in interface Address
setValue
in interface AssignableFromString
value
- an address String.public void setValue(byte[] value)
AssignableFromByteArray
setValue
in interface AssignableFromByteArray
value
- a byte array.public byte[] toByteArray()
AssignableFromByteArray
toByteArray
in interface AssignableFromByteArray
|
Copyright 2005-2010 Frank Fock (SNMP4J.org) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |