public class VariableBinding extends Object implements Serializable, BERSerializable, Cloneable
VariableBinding is an association of a object instance
identifier (OID) and the instance's value (Variable).| Constructor and Description |
|---|
VariableBinding()
Creates a variable binding with a zero length OID and a
Null value. |
VariableBinding(OID oid)
Creates a variable binding with the supplied object instance identifier
and a
Null value. |
VariableBinding(OID oid,
String variableText)
Creates a variable binding with the supplied OID and a text value.
|
VariableBinding(OID oid,
Variable variable)
Creates a variable binding with the supplied OID and value.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone() |
static VariableBinding[] |
createFromOIDs(OID[] oids)
Create an array of
VariableBindings based on the
provided OIDs. |
void |
decodeBER(BERInputStream inputStream)
Decodes a
Variable from an InputStream. |
void |
encodeBER(OutputStream outputStream)
Encodes a
Variable to an OutputStream. |
boolean |
equals(Object o) |
int |
getBERLength()
Returns the length of this
BERSerializable object
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). |
OID |
getOid()
Gets the object instance identifier of the variable binding.
|
int |
getSyntax()
Gets the syntax of the variable bindings value.
|
Variable |
getVariable()
Gets the value of the variable binding.
|
int |
hashCode() |
boolean |
isException()
Returns whether the variable bindings value has an exception syntax.
|
void |
setOid(OID oid)
Sets the object instance identifier for the variable binding.
|
void |
setVariable(Variable variable)
Sets the value of the variable binding.
|
String |
toString()
Gets a string representation of this variable binding using the
VariableTextFormat configured by SNMP4JSettings. |
String |
toValueString()
Gets a string representation of this variable binding's value using the
VariableTextFormat configured by SNMP4JSettings. |
public VariableBinding()
Null value.public VariableBinding(OID oid)
Null value.oid - the OID for the new variable binding.public VariableBinding(OID oid, Variable variable)
oid - the OID for the new variable binding (must not be null).variable - the value for the new variable binding (must not be null).public VariableBinding(OID oid, String variableText) throws ParseException
VariableTextFormat set by
SNMP4JSettings.setVariableTextFormat(org.snmp4j.util.VariableTextFormat).
The default SimpleVariableTextFormat does not support
this operation. To be able to use this constructor, use the SmiManager
of SNMP4J-SMI instead.oid - the OID of the new variable binding.variableText - the textual representation of a Variable of the syntax defined for oid
by a MIB specification.ParseException - if the variableText cannot be parsed or oid's syntax is unknown.public OID getOid()
OID.public void setOid(OID oid)
oid - an OID (must not be null) that is cloned when added to
this binding.public void setVariable(Variable variable)
variable - a Variable (must not be null) that is cloned
when added to this binding.public Variable getVariable()
Variable instance.public final int getSyntax()
SMIConstants).public boolean isException()
true if the syntax of this variable is an instance of
Null and its syntax equals one of the following:
Variablepublic final int getBERPayloadLength()
BERSerializableBERSerializable object
in bytes when encoded according to the Basic Encoding Rules (BER).getBERPayloadLength in interface BERSerializablepublic final int getBERLength()
BERSerializableBERSerializable object
in bytes when encoded according to the Basic Encoding Rules (BER).getBERLength in interface BERSerializablepublic final void decodeBER(BERInputStream inputStream) throws IOException
BERSerializableVariable from an InputStream.decodeBER in interface BERSerializableinputStream - an InputStream containing a BER encoded byte stream.IOException - if the stream could not be decoded by using BER rules.public final void encodeBER(OutputStream outputStream) throws IOException
BERSerializableVariable to an OutputStream.encodeBER in interface BERSerializableoutputStream - an OutputStream.IOException - if an error occurs while writing to the stream.public String toString()
VariableTextFormat configured by SNMP4JSettings.public String toValueString()
VariableTextFormat configured by SNMP4JSettings.<Variable>.public static VariableBinding[] createFromOIDs(OID[] oids)
VariableBindings based on the
provided OIDs.oids - an array of OIDs (must not be null).VariableBindings where each
the n-th binding's OID is the n-th OID out of
oids.Copyright © 2016 SNMP4J.org. All Rights Reserved.