org.snmp4j.smi
Class TransportIpAddress

java.lang.Object
  extended by org.snmp4j.smi.AbstractVariable
      extended by org.snmp4j.smi.SMIAddress
          extended by org.snmp4j.smi.IpAddress
              extended by org.snmp4j.smi.TransportIpAddress
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, BERSerializable, Address, AssignableFromByteArray, AssignableFromString, Variable
Direct Known Subclasses:
TcpAddress, UdpAddress

public abstract class TransportIpAddress
extends IpAddress

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:
Serialized Form

Field Summary
protected  int port
           
 
Fields inherited from class org.snmp4j.smi.IpAddress
ANY_IPADDRESS
 
Fields inherited from class org.snmp4j.smi.AbstractVariable
SMISYNTAXES_PROPERTIES
 
Constructor Summary
TransportIpAddress()
           
 
Method Summary
 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)
           
 int getBERLength()
          Returns the length of this Variable in bytes when encoded according to the Basic Encoding Rules (BER).
 int getBERPayloadLength()
          Returns the length of the payload of this BERSerializable object in bytes when encoded according to the Basic Encoding Rules (BER).
 int getPort()
           
 int getSyntax()
          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 this Address is a valid transport address.
static Address parse(java.lang.String address)
           
 boolean parseAddress(java.lang.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.
 java.lang.String toString()
          Gets a string representation of the variable.
 
Methods inherited from class org.snmp4j.smi.IpAddress
clone, fromSubIndex, getInetAddress, setAddress, setInetAddress, setValue, setValue, toByteArray, toInt, toLong, toSubIndex
 
Methods inherited from class org.snmp4j.smi.AbstractVariable
createFromBER, createFromSyntax, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

port

protected int port
Constructor Detail

TransportIpAddress

public TransportIpAddress()
Method Detail

getPort

public int getPort()

setPort

public void setPort(int port)

isValid

public boolean isValid()
Description copied from interface: Address
Checks whether this Address is a valid transport address.

Specified by:
isValid in interface Address
Overrides:
isValid in class IpAddress
Returns:
true if the address is valid, false otherwise.

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
Specified by:
compareTo in interface Variable
Overrides:
compareTo in class IpAddress

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface Variable
Overrides:
equals in class IpAddress

parseAddress

public boolean parseAddress(java.lang.String address)
Description copied from interface: Address
Parses the address from the supplied string representation.

Specified by:
parseAddress in interface Address
Overrides:
parseAddress in class IpAddress
Parameters:
address - a String representation of this address.
Returns:
true if address could be successfully parsed and has been assigned to this address object, false otherwise.

parse

public static Address parse(java.lang.String address)

toString

public java.lang.String toString()
Description copied from class: AbstractVariable
Gets a string representation of the variable.

Specified by:
toString in interface Variable
Overrides:
toString in class IpAddress
Returns:
a string representation of the variable's value.

hashCode

public int hashCode()
Specified by:
hashCode in interface Variable
Overrides:
hashCode in class IpAddress

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: AbstractVariable
Decodes a Variable from an InputStream.

Specified by:
decodeBER in interface BERSerializable
Overrides:
decodeBER in class IpAddress
Parameters:
inputStream - an InputStream containing 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.IOException
Description copied from class: AbstractVariable
Encodes a Variable to an OutputStream.

Specified by:
encodeBER in interface BERSerializable
Overrides:
encodeBER in class IpAddress
Parameters:
outputStream - an OutputStream.
Throws:
java.io.IOException - if an error occurs while writing to the stream.

getBERLength

public int getBERLength()
Description copied from class: AbstractVariable
Returns the length of this Variable in bytes when encoded according to the Basic Encoding Rules (BER).

Specified by:
getBERLength in interface BERSerializable
Overrides:
getBERLength in class IpAddress
Returns:
the BER encoded length of this variable.

getBERPayloadLength

public int getBERPayloadLength()
Description copied from interface: BERSerializable
Returns the length of the payload of this BERSerializable object in bytes when encoded according to the Basic Encoding Rules (BER).

Specified by:
getBERPayloadLength in interface BERSerializable
Overrides:
getBERPayloadLength in class AbstractVariable
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.

Specified by:
getSyntax in interface Variable
Overrides:
getSyntax in class IpAddress
Returns:
an integer value < 128 for regular SMI objects and a value >= 128 for exception values like noSuchObject, noSuchInstance, and endOfMibView.

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.