public class GenericAddress extends SMIAddress
GenericAddress
implements the decorator and factory
design pattern to provide a generic address type.
To register address types other than the default, set the system property
ADDRESS_TYPES_PROPERTIES
before calling the parse(java.lang.String)
method
for the first time.
Modifier and Type | Field and Description |
---|---|
static String |
ADDRESS_TYPES_PROPERTIES |
static String |
TYPE_IP
Default address type identifier for an IpAddress.
|
static String |
TYPE_TCP
Default address type identifier for a TcpAddress.
|
static String |
TYPE_TLS
Default address type identifier for an TlsAddress.
|
static String |
TYPE_UDP
Default address type identifier for an UpdAddress.
|
SMISYNTAXES_PROPERTIES
Constructor and Description |
---|
GenericAddress() |
GenericAddress(SMIAddress address) |
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. |
Address |
getAddress() |
int |
getBERLength()
Returns the length of this
Variable in bytes when encoded
according to the Basic Encoding Rules (BER). |
int |
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable.
|
static String |
getTDomainPrefix(Class<? extends Address> addressClass)
Gets the transport domain prefix string (lowercase) for a supplied
Address class. |
int |
hashCode() |
boolean |
isValid()
Checks whether this
Address is a valid transport address. |
static Address |
parse(String address)
Parses a given transport protocol dependent address string into an
Address instance that is subsumed by this
GenericAddress object. |
boolean |
parseAddress(String address)
Parse an address form the supplied string.
|
void |
setAddress(SMIAddress address) |
void |
setValue(byte[] rawAddress)
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, isException
public static final String TYPE_UDP
public static final String TYPE_TCP
public static final String TYPE_IP
public static final String TYPE_TLS
public static final String ADDRESS_TYPES_PROPERTIES
public GenericAddress()
public GenericAddress(SMIAddress address)
public int getSyntax()
AbstractVariable
getSyntax
in interface Variable
getSyntax
in class AbstractVariable
public boolean isValid()
Address
Address
is a valid transport address.true
if the address is valid, false
otherwise.public String toString()
AbstractVariable
toString
in interface Variable
toString
in class AbstractVariable
public int hashCode()
hashCode
in interface Variable
hashCode
in class AbstractVariable
public int compareTo(Variable o)
compareTo
in interface Comparable<Variable>
compareTo
in interface Variable
compareTo
in class AbstractVariable
public boolean equals(Object o)
equals
in interface Variable
equals
in class AbstractVariable
public void decodeBER(BERInputStream inputStream) throws IOException
AbstractVariable
Variable
from an InputStream
.decodeBER
in interface BERSerializable
decodeBER
in class AbstractVariable
inputStream
- 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
AbstractVariable
Variable
to an OutputStream
.encodeBER
in interface BERSerializable
encodeBER
in class AbstractVariable
outputStream
- an OutputStream
.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(SMIAddress address)
public Address getAddress()
public static Address parse(String address)
Address
instance that is subsumed by this
GenericAddress
object.address
- an address string with a leading type specifier as defined in the
"address.properties". The format is "type:address"
where
the format of address
depends on type
.
Valid values for type
are, for example, "udp" and "tcp".Address
instance of the address classes specified
in "address.properties" whose type ID matched the specified ID in
address
. If address
cannot be parsed,
null
is returned.IllegalArgumentException
- if the address type indicator supplied is not know.public boolean parseAddress(String address)
address
- an address string known by the GenericAddress.parse(String address)
public void setValue(byte[] rawAddress)
AssignableFromByteArray
rawAddress
- a byte array.public 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 byte[] toByteArray()
AssignableFromByteArray
public void setValue(String value)
Address
IllegalArgumentException
runtime exception is thrown.value
- an address String.public static String getTDomainPrefix(Class<? extends Address> addressClass)
Address
class.addressClass
- an implementation class of Address
.addressClass
has been registered with a domain prefix, null
otherwise.Copyright © 2024 SNMP4J.org. All rights reserved.