- java.lang.Object
-
- org.snmp4j.smi.AbstractVariable
-
- org.snmp4j.smi.SMIAddress
-
- org.snmp4j.smi.IpAddress
-
- org.snmp4j.smi.TransportIpAddress
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<Variable>,BERSerializable,Address,AssignableFromByteArray,AssignableFromString,Variable
- Direct Known Subclasses:
TcpAddress,UdpAddress
public abstract class TransportIpAddress extends IpAddress
TheTransportIpAddressis the abstract base class for all transport addresses on top of IP network addresses.- Version:
- 1.5
- Author:
- Frank Fock
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intport-
Fields inherited from class org.snmp4j.smi.AbstractVariable
SMISYNTAXES_PROPERTIES
-
Fields inherited from class org.snmp4j.smi.IpAddress
ANY_IPADDRESS
-
-
Constructor Summary
Constructors Constructor Description TransportIpAddress()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Variable o)voiddecodeBER(BERInputStream inputStream)Decodes aVariablefrom anBERInputStream.voidencodeBER(java.io.OutputStream outputStream)Encodes aVariableto anOutputStream.booleanequals(java.lang.Object o)intgetBERLength()Returns the length of thisVariablein bytes when encoded according to the Basic Encoding Rules (BER).intgetBERPayloadLength()Returns the length of the payload of thisBERSerializableobject in bytes when encoded according to the Basic Encoding Rules (BER).intgetPort()intgetSyntax()Gets the ASN.1 syntax identifier value of this SNMP variable.byte[]getValue()Returns the address value as a byte array.inthashCode()booleanisValid()Checks whether thisAddressis a valid transport address.static Addressparse(java.lang.String address)booleanparseAddress(java.lang.String address)Parses the address from the supplied string representation.voidsetPort(int port)voidsetTransportAddress(OctetString transportAddress)Sets this transport address from an OcetString containing the address value in format as specified by the TRANSPORT-ADDRESS-MIB.java.lang.StringtoString()Gets a string representation of the variable.-
Methods inherited from class org.snmp4j.smi.AbstractVariable
createFromBER, createFromSyntax, equal, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException
-
Methods inherited from interface org.snmp4j.smi.Address
isTransportCompatible
-
Methods inherited from class org.snmp4j.smi.IpAddress
clone, fromSubIndex, getInetAddress, setAddress, setInetAddress, setValue, setValue, toByteArray, toInt, toLong, toSubIndex
-
-
-
-
Method Detail
-
getPort
public int getPort()
-
setPort
public void setPort(int port)
-
isValid
public boolean isValid()
Description copied from interface:AddressChecks whether thisAddressis a valid transport address.
-
compareTo
public int compareTo(Variable o)
-
equals
public boolean equals(java.lang.Object o)
-
parseAddress
public boolean parseAddress(java.lang.String address)
Description copied from interface:AddressParses the address from the supplied string representation.- Specified by:
parseAddressin interfaceAddress- Overrides:
parseAddressin classIpAddress- Parameters:
address- a String representation of this address.- Returns:
trueifaddresscould be successfully parsed and has been assigned to this address object,falseotherwise.
-
parse
public static Address parse(java.lang.String address)
-
toString
public java.lang.String toString()
Description copied from class:AbstractVariableGets a string representation of the variable.
-
hashCode
public int hashCode()
-
setTransportAddress
public void setTransportAddress(OctetString transportAddress) throws java.net.UnknownHostException
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:
java.net.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
public void decodeBER(BERInputStream inputStream) throws java.io.IOException
Description copied from class:AbstractVariableDecodes aVariablefrom anBERInputStream.- Specified by:
decodeBERin interfaceBERSerializable- Overrides:
decodeBERin classIpAddress- Parameters:
inputStream- anBERInputStreamcontaining a BER encoded byte stream.- Throws:
java.io.IOException- if the stream could not be decoded by using BER rules.
-
encodeBER
public void encodeBER(java.io.OutputStream outputStream) throws java.io.IOExceptionDescription copied from class:AbstractVariableEncodes aVariableto anOutputStream.- Specified by:
encodeBERin interfaceBERSerializable- Overrides:
encodeBERin classIpAddress- Parameters:
outputStream- anOutputStream.- Throws:
java.io.IOException- if an error occurs while writing to the stream.
-
getBERLength
public int getBERLength()
Description copied from class:AbstractVariableReturns the length of thisVariablein bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERLengthin interfaceBERSerializable- Overrides:
getBERLengthin classIpAddress- Returns:
- the BER encoded length of this variable.
-
getBERPayloadLength
public int getBERPayloadLength()
Description copied from interface:BERSerializableReturns the length of the payload of thisBERSerializableobject in bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERPayloadLengthin interfaceBERSerializable- Overrides:
getBERPayloadLengthin classAbstractVariable- Returns:
- the BER encoded length of this variable.
-
getSyntax
public int getSyntax()
Description copied from class:AbstractVariableGets the ASN.1 syntax identifier value of this SNMP variable.
-
-