public interface Variable extends Cloneable, Comparable<Variable>, BERSerializable
Variable
interface defines common attributes of all SNMP
variables.
Before version 1.8, Variable has been an abstract class which has been
renamed to AbstractVariable
.
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID
This definition of a serialVersionUID for the Variable interface
has been made for backward compatibility with SNMP4J 1.7.x or earlier
serialized Variable instances.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Clones this variable.
|
int |
compareTo(Variable o) |
boolean |
equals(Object o) |
void |
fromSubIndex(OID subIndex,
boolean impliedLength)
Sets the value of this
Variable from the supplied (sub-)index. |
int |
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable.
|
String |
getSyntaxString()
Gets a textual description of this Variable.
|
int |
hashCode() |
boolean |
isDynamic()
Indicates whether this variable is dynamic.
|
boolean |
isException()
Checks whether this variable represents an exception like
noSuchObject, noSuchInstance, and endOfMibView.
|
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. |
decodeBER, encodeBER, getBERLength, getBERPayloadLength
static final long serialVersionUID
int compareTo(Variable o)
compareTo
in interface Comparable<Variable>
Object clone()
Variable
with the same value.int getSyntax()
boolean isException()
true
if the syntax of this variable is an instance of
Null
and its syntax equals one of the following:
String toString()
int toInt()
UnsupportedOperationException
- if an integer representation
does not exists for this Variable.long toLong()
UnsupportedOperationException
- if a long representation
does not exists for this Variable.String getSyntaxString()
OID toSubIndex(boolean impliedLength)
Variable
to a (sub-)index
value.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.UnsupportedOperationException
- if this variable cannot be used in an index.void fromSubIndex(OID subIndex, boolean impliedLength)
Variable
from the supplied (sub-)index.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.UnsupportedOperationException
- if this variable cannot be used in an index.boolean isDynamic()
BERSerializable.getBERLength()
for encoding enclosing SEQUENCES and the actual
encoding of the Variable itself with BERSerializable.encodeBER(java.io.OutputStream)
changes to the
value need to be blocked by synchronization.
In order to ensure proper synchronization if a Variable
is
dynamic, modifications of the variables content need to synchronize on
the Variable
instance. This can be achieved for the standard
SMI Variable implementations for example by
public static modifyVariable(Integer32 variable, int value) synchronize(variable) { variable.setValue(value); } }
true
if the variable might change its value between
two calls to BERSerializable.getBERLength()
and BERSerializable.encodeBER(java.io.OutputStream)
and
false
if the value is immutable or if its value does
not change while serialization because of measures taken by the
implementor (i.e. variable cloning).Copyright © 2019 SNMP4J.org. All rights reserved.