|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.snmp4j.smi.AbstractVariable
public abstract class AbstractVariable
The Variable
abstract class is the base class for all SNMP
variables.
All derived classes need to be registered with their SMI BER type in the
smisyntaxes.properties
so that the
createFromBER(BERInputStream inputStream)
method
is able to decode a variable from a BER encoded stream.
To register additional syntaxes, set the system property
SMISYNTAXES_PROPERTIES
before decoding a Variable for the first
time. The path of the property file must be accessible from the classpath
and it has to be specified relative to the Variable
class.
Field Summary | |
---|---|
static java.lang.String |
SMISYNTAXES_PROPERTIES
|
Constructor Summary | |
---|---|
AbstractVariable()
The abstract Variable class serves as the base class for all
specific SNMP syntax types. |
Method Summary | |
---|---|
abstract java.lang.Object |
clone()
Clones this variable. |
abstract int |
compareTo(java.lang.Object o)
|
static Variable |
createFromBER(BERInputStream inputStream)
Creates a Variable from a BER encoded InputStream . |
static Variable |
createFromSyntax(int smiSyntax)
Creates a Variable from the supplied SMI syntax identifier. |
abstract void |
decodeBER(BERInputStream inputStream)
Decodes a Variable from an InputStream . |
abstract void |
encodeBER(java.io.OutputStream outputStream)
Encodes a Variable to an OutputStream . |
abstract boolean |
equals(java.lang.Object o)
|
abstract void |
fromSubIndex(OID subIndex,
boolean impliedLength)
Sets the value of this Variable from the supplied (sub-)index. |
abstract int |
getBERLength()
Returns the length of this Variable 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). |
abstract int |
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable. |
static int |
getSyntaxFromString(java.lang.String syntaxString)
Returns the BER syntax ID for the supplied syntax string (as returned by getSyntaxString(int) ). |
java.lang.String |
getSyntaxString()
Gets a textual description of this Variable. |
static java.lang.String |
getSyntaxString(int syntax)
Gets a textual description of the supplied syntax type. |
abstract int |
hashCode()
|
boolean |
isDynamic()
Indicates whether this variable is dynamic, which means that it might change its value while it is being (BER) serialized. |
boolean |
isException()
Checks whether this variable represents an exception like noSuchObject, noSuchInstance, and endOfMibView. |
abstract int |
toInt()
Returns an integer representation of this variable if such a representation exists. |
abstract long |
toLong()
Returns a long representation of this variable if such a representation exists. |
abstract java.lang.String |
toString()
Gets a string representation of the variable. |
abstract OID |
toSubIndex(boolean impliedLength)
Converts the value of this Variable to a (sub-)index
value. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SMISYNTAXES_PROPERTIES
Constructor Detail |
---|
public AbstractVariable()
Variable
class serves as the base class for all
specific SNMP syntax types.
Method Detail |
---|
public abstract boolean equals(java.lang.Object o)
equals
in interface Variable
equals
in class java.lang.Object
public abstract int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
compareTo
in interface Variable
public abstract int hashCode()
hashCode
in interface Variable
hashCode
in class java.lang.Object
public abstract int getBERLength()
Variable
in bytes when encoded
according to the Basic Encoding Rules (BER).
getBERLength
in interface BERSerializable
public int getBERPayloadLength()
BERSerializable
BERSerializable
object
in bytes when encoded according to the Basic Encoding Rules (BER).
getBERPayloadLength
in interface BERSerializable
public abstract void decodeBER(BERInputStream inputStream) throws java.io.IOException
Variable
from an InputStream
.
decodeBER
in interface BERSerializable
inputStream
- an InputStream
containing a BER encoded byte stream.
java.io.IOException
- if the stream could not be decoded by using BER rules.public abstract void encodeBER(java.io.OutputStream outputStream) throws java.io.IOException
Variable
to an OutputStream
.
encodeBER
in interface BERSerializable
outputStream
- an OutputStream
.
java.io.IOException
- if an error occurs while writing to the stream.public static Variable createFromBER(BERInputStream inputStream) throws java.io.IOException
Variable
from a BER encoded InputStream
.
Subclasses of Variable
are registered using the properties file
smisyntaxes.properties
in this package. The properties are
read when this method is called first.
inputStream
- an BERInputStream
containing a BER encoded byte stream.
Variable
.
java.io.IOException
public static Variable createFromSyntax(int smiSyntax)
Variable
from the supplied SMI syntax identifier.
Subclasses of Variable
are registered using the properties
file smisyntaxes.properties
in this package. The properties
are read when this method is called for the first time.
smiSyntax
- an SMI syntax identifier of the registered types, which is typically
defined by SMIConstants
.
Variable
variable instance of the supplied SMI syntax.public abstract int getSyntax()
getSyntax
in interface Variable
public boolean isException()
isException
in interface Variable
true
if the syntax of this variable is an instance of
Null
and its syntax equals one of the following:
public abstract java.lang.String toString()
toString
in interface Variable
toString
in class java.lang.Object
public abstract int toInt()
toInt
in interface Variable
java.lang.UnsupportedOperationException
- if an integer representation
does not exists for this Variable.public abstract long toLong()
toLong
in interface Variable
java.lang.UnsupportedOperationException
- if a long representation
does not exists for this Variable.public abstract java.lang.Object clone()
Variable
clone
in interface Variable
clone
in class java.lang.Object
Variable
with the same value.public static java.lang.String getSyntaxString(int syntax)
syntax
- the BER code of the syntax.
syntax
as used in the Structure of Management Information (SMI) modules.
'?' is returned if the supplied syntax is unknown.public final java.lang.String getSyntaxString()
getSyntaxString
in interface Variable
public static int getSyntaxFromString(java.lang.String syntaxString)
getSyntaxString(int)
).
syntaxString
- the textual representation of the syntax.
public abstract OID toSubIndex(boolean impliedLength)
Variable
to a (sub-)index
value.
toSubIndex
in interface Variable
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.
java.lang.UnsupportedOperationException
- if this variable cannot be used in an index.public abstract void fromSubIndex(OID subIndex, boolean impliedLength)
Variable
from the supplied (sub-)index.
fromSubIndex
in interface Variable
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.
java.lang.UnsupportedOperationException
- if this variable cannot be used in an index.public boolean isDynamic()
PDU
with PDU.add(VariableBinding)
. By cloning the value, it is
ensured that there are no inconsistent changes between determining the
length with getBERLength()
for encoding enclosing SEQUENCES and
the actual encoding of the Variable itself with encodeBER(java.io.OutputStream)
.
isDynamic
in interface Variable
false
by default. Derived classes may override this
if implementing dynamic Variable
instances.
|
Copyright 2005-2010 Frank Fock (SNMP4J.org) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |