java.lang.Object
org.snmp4j.smi.AbstractVariable
org.snmp4j.smi.SMIAddress
org.snmp4j.smi.IpAddress
org.snmp4j.smi.TransportIpAddress
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Variable>
,BERSerializable
,Address
,AssignableFromByteArray
,AssignableFromString
,Variable
- Direct Known Subclasses:
TcpAddress
,UdpAddress
The
TransportIpAddress
is the abstract base class for all
transport addresses on top of IP network addresses.- Version:
- 1.5
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields inherited from class org.snmp4j.smi.IpAddress
ANY_IPADDRESS
Fields inherited from class org.snmp4j.smi.AbstractVariable
SMISYNTAXES_PROPERTIES
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
void
decodeBER
(BERInputStream inputStream) Decodes aVariable
from anBERInputStream
.void
encodeBER
(OutputStream outputStream) Encodes aVariable
to anOutputStream
.boolean
int
Returns the length of thisVariable
in bytes when encoded according to the Basic Encoding Rules (BER).int
Returns the length of the payload of thisBERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER).int
getPort()
int
Gets the ASN.1 syntax identifier value of this SNMP variable.byte[]
getValue()
Returns the address value as a byte array.int
hashCode()
boolean
isValid()
Checks whether thisAddress
is a valid transport address.static Address
boolean
parseAddress
(String address) Parses the address from the supplied string representation.void
setPort
(int port) void
setTransportAddress
(OctetString transportAddress) Sets this transport address from an OcetString containing the address value in format as specified by the TRANSPORT-ADDRESS-MIB.toString()
Gets a string representation of the variable.Methods inherited from class org.snmp4j.smi.IpAddress
clone, fromSubIndex, getFamily, getInetAddress, getSocketAddress, setAddress, setInetAddress, setValue, setValue, toByteArray, toInt, toLong, toSubIndex
Methods inherited from class org.snmp4j.smi.AbstractVariable
createFromBER, createFromSyntax, equal, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.snmp4j.smi.Address
isTransportCompatible
-
Field Details
-
port
protected int port
-
-
Constructor Details
-
TransportIpAddress
public TransportIpAddress()
-
-
Method Details
-
getPort
public int getPort() -
setPort
public void setPort(int port) -
isValid
public boolean isValid()Description copied from interface:Address
Checks whether thisAddress
is a valid transport address. -
compareTo
-
equals
-
parseAddress
Description copied from interface:Address
Parses the address from the supplied string representation.- Specified by:
parseAddress
in interfaceAddress
- Overrides:
parseAddress
in classIpAddress
- Parameters:
address
- a String representation of this address.- Returns:
true
ifaddress
could be successfully parsed and has been assigned to this address object,false
otherwise.
-
parse
-
toString
Description copied from class:AbstractVariable
Gets a string representation of the variable. -
hashCode
public int hashCode() -
setTransportAddress
Sets this transport address from an OcetString containing the address value in format as specified by the TRANSPORT-ADDRESS-MIB.- Parameters:
transportAddress
- an OctetString containing the IP address bytes and the two port bytes in network byte order.- Throws:
UnknownHostException
- if the address is invalid.
-
getValue
public byte[] getValue()Returns the address value as a byte array.- Returns:
- a byte array with IP address bytes and two additional bytes containing the port in network byte order. If the address is a zoned (scoped) IP address, four additional bytes with the scope ID are returned between address and port bytes.
- Since:
- 1.5
-
decodeBER
Description copied from class:AbstractVariable
Decodes aVariable
from anBERInputStream
.- Specified by:
decodeBER
in interfaceBERSerializable
- Overrides:
decodeBER
in classIpAddress
- Parameters:
inputStream
- anBERInputStream
containing a BER encoded byte stream.- Throws:
IOException
- if the stream could not be decoded by using BER rules.
-
encodeBER
Description copied from class:AbstractVariable
Encodes aVariable
to anOutputStream
.- Specified by:
encodeBER
in interfaceBERSerializable
- Overrides:
encodeBER
in classIpAddress
- Parameters:
outputStream
- anOutputStream
.- Throws:
IOException
- if an error occurs while writing to the stream.
-
getBERLength
public int getBERLength()Description copied from class:AbstractVariable
Returns the length of thisVariable
in bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERLength
in interfaceBERSerializable
- Overrides:
getBERLength
in classIpAddress
- Returns:
- the BER encoded length of this variable.
-
getBERPayloadLength
public int getBERPayloadLength()Description copied from interface:BERSerializable
Returns the length of the payload of thisBERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERPayloadLength
in interfaceBERSerializable
- Overrides:
getBERPayloadLength
in classAbstractVariable
- Returns:
- the BER encoded length of this variable.
-
getSyntax
public int getSyntax()Description copied from class:AbstractVariable
Gets the ASN.1 syntax identifier value of this SNMP variable.
-