|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.snmp4j.smi.AbstractVariable
org.snmp4j.smi.VariantVariable
public class VariantVariable
The VariantVariable provides a decorator for any type
of Variable instance, to be able to intercept or monitor variable
value modification by using a VariantVariableCallback.
This class will work for implementations that use getSyntax()
method to determine the variables syntax. However "instanceof" will not
work.
In contrast to the native Variable implementations,
VariantVariable can be modified dynamically (i.e. while
a PDU is being BER encoded where this variable has been added to) without
causing BER encoding errors.
| Field Summary |
|---|
| Fields inherited from class org.snmp4j.smi.AbstractVariable |
|---|
SMISYNTAXES_PROPERTIES |
| Constructor Summary | |
|---|---|
VariantVariable(Variable initialVariable)
Creates a variant variable wrapping the specified value. |
|
VariantVariable(Variable initialVariable,
VariantVariableCallback callback)
Creates a variant variable wrapping the specified value and a callback that monitors value modifications. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Clones this variable. |
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)
|
void |
fromSubIndex(OID subIndex,
boolean impliedLength)
Sets the value of this Variable from the supplied (sub-)index. |
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. |
Variable |
getVariable()
Returns the typed variable that holds the wrapped value. |
int |
hashCode()
|
boolean |
isDynamic()
Indicates whether this variable is dynamic, which means that it might change its value while it is being (BER) serialized. |
void |
setValue(byte[] value)
Sets the value of this object from the supplied byte array. |
void |
setValue(int value)
|
void |
setValue(long value)
|
void |
setValue(OctetString value)
|
void |
setValue(java.lang.String value)
|
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. |
java.lang.String |
toString()
Gets a string representation of the variable. |
OID |
toSubIndex(boolean impliedLength)
Converts the value of this Variable to a (sub-)index
value. |
protected void |
updateVariable()
|
protected void |
variableUpdated()
|
| Methods inherited from class org.snmp4j.smi.AbstractVariable |
|---|
createFromBER, createFromSyntax, getBERPayloadLength, getSyntaxFromString, getSyntaxString, getSyntaxString, isException |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public VariantVariable(Variable initialVariable)
initialVariable - a Variable.
public VariantVariable(Variable initialVariable,
VariantVariableCallback callback)
initialVariable - a Variable.callback - a callback handler that is called before the value is to be modified
and after it has been modified.| Method Detail |
|---|
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.ComparablecompareTo in interface VariablecompareTo in class AbstractVariableprotected void updateVariable()
protected void variableUpdated()
public void decodeBER(BERInputStream inputStream)
throws java.io.IOException
AbstractVariableVariable from an InputStream.
decodeBER in interface BERSerializabledecodeBER in class AbstractVariableinputStream - an InputStream containing a BER encoded byte stream.
java.io.IOException - if the stream could not be decoded by using BER rules.
public void encodeBER(java.io.OutputStream outputStream)
throws java.io.IOException
AbstractVariableVariable to an OutputStream.
encodeBER in interface BERSerializableencodeBER in class AbstractVariableoutputStream - an OutputStream.
java.io.IOException - if an error occurs while writing to the stream.
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 int getBERLength()
AbstractVariableVariable in bytes when encoded
according to the Basic Encoding Rules (BER).
getBERLength in interface BERSerializablegetBERLength in class AbstractVariablepublic int getSyntax()
AbstractVariable
getSyntax in interface VariablegetSyntax in class AbstractVariablepublic int toInt()
AbstractVariable
toInt in interface AssignableFromIntegertoInt in interface VariabletoInt in class AbstractVariablepublic long toLong()
AbstractVariable
toLong in interface AssignableFromLongtoLong in interface VariabletoLong in class AbstractVariablepublic byte[] toByteArray()
AssignableFromByteArray
toByteArray in interface AssignableFromByteArraypublic 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 boolean equals(java.lang.Object o)
equals in interface Variableequals in class AbstractVariablepublic int hashCode()
hashCode in interface VariablehashCode in class AbstractVariablepublic java.lang.String toString()
AbstractVariable
toString in interface VariabletoString in class AbstractVariablepublic java.lang.Object clone()
Variable
clone in interface Variableclone in class AbstractVariableVariable with the same value.public void setValue(int value)
setValue in interface AssignableFromIntegerpublic void setValue(long value)
setValue in interface AssignableFromLongpublic void setValue(OctetString value)
public void setValue(byte[] value)
AssignableFromByteArray
setValue in interface AssignableFromByteArrayvalue - a byte array.public void setValue(java.lang.String value)
setValue in interface AssignableFromStringpublic Variable getVariable()
public boolean isDynamic()
AbstractVariablePDU
with PDU.add(VariableBinding). By cloning the value, it is
ensured that there are no inconsistent changes between determining the
length with AbstractVariable.getBERLength() for encoding enclosing SEQUENCES and
the actual encoding of the Variable itself with AbstractVariable.encodeBER(java.io.OutputStream).
isDynamic in interface VariableisDynamic in class AbstractVariablefalse by default. Derived classes may override this
if implementing dynamic Variable instances.
|
Copyright 2003-2009 Frank Fock and Jochen Katz (SNMP4J.org) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||