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, isExceptionpublic 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()
AbstractVariablegetSyntax in interface VariablegetSyntax in class AbstractVariablepublic boolean isValid()
AddressAddress is a valid transport address.true if the address is valid, false otherwise.public String toString()
AbstractVariabletoString in interface VariabletoString in class AbstractVariablepublic int hashCode()
hashCode in interface VariablehashCode in class AbstractVariablepublic int compareTo(Variable o)
compareTo in interface Comparable<Variable>compareTo in interface VariablecompareTo in class AbstractVariablepublic boolean equals(Object o)
equals in interface Variableequals in class AbstractVariablepublic void decodeBER(BERInputStream inputStream) throws IOException
AbstractVariableVariable from an InputStream.decodeBER in interface BERSerializabledecodeBER in class AbstractVariableinputStream - 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
AbstractVariableVariable to an OutputStream.encodeBER in interface BERSerializableencodeBER in class AbstractVariableoutputStream - an OutputStream.IOException - if an error occurs while writing to the stream.public int getBERLength()
AbstractVariableVariable in bytes when encoded
according to the Basic Encoding Rules (BER).getBERLength in interface BERSerializablegetBERLength in class AbstractVariablepublic 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)
AssignableFromByteArrayrawAddress - a byte array.public Object clone()
Variableclone in interface Variableclone in class AbstractVariableVariable with the same value.public int toInt()
AbstractVariabletoInt in interface VariabletoInt in class AbstractVariablepublic long toLong()
AbstractVariabletoLong in interface VariabletoLong in class AbstractVariablepublic OID toSubIndex(boolean impliedLength)
AbstractVariableVariable to a (sub-)index
value.toSubIndex in interface VariabletoSubIndex in class AbstractVariableimpliedLength - 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)
AbstractVariableVariable from the supplied (sub-)index.fromSubIndex in interface VariablefromSubIndex in class AbstractVariablesubIndex - 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()
AssignableFromByteArraypublic void setValue(String value)
AddressIllegalArgumentException 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 © 2016 SNMP4J.org. All Rights Reserved.