public class RowCount extends Object implements org.snmp4j.smi.Variable
RowCount
class implements a Variable
that counts the rows of a table and returns the number
of rows as value. This class is a dynamic Variable, which means it needs to be cloned when serialized.
When cloned, a Gauge32
instance with the row count of the source table will be created.Constructor and Description |
---|
RowCount()
Creates a
RowCount which returns zero always. |
RowCount(MOTable moTable)
Creates a row counting
Gauge32 variable for the specified MOTable . |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Clones this variable.
|
int |
compareTo(org.snmp4j.smi.Variable o) |
void |
decodeBER(org.snmp4j.asn1.BERInputStream inputStream)
Decodes a
Variable from an InputStream . |
void |
encodeBER(OutputStream outputStream)
Encodes a
Variable to an OutputStream . |
void |
fromSubIndex(org.snmp4j.smi.OID subIndex,
boolean impliedLength)
Sets the value of this
Variable from the supplied (sub-)index. |
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). |
int |
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable.
|
String |
getSyntaxString()
Gets a textual description of this Variable.
|
long |
getValue()
Gets the number of rows in the associated table as unsigned long value.
|
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.
|
org.snmp4j.smi.OID |
toSubIndex(boolean impliedLength)
Converts the value of this
Variable to a (sub-)index value. |
public RowCount()
RowCount
which returns zero always.public long getValue()
null
table is associated.public int compareTo(org.snmp4j.smi.Variable o)
compareTo
in interface Comparable<org.snmp4j.smi.Variable>
compareTo
in interface org.snmp4j.smi.Variable
public Object clone()
public int getSyntax()
getSyntax
in interface org.snmp4j.smi.Variable
public boolean isException()
isException
in interface org.snmp4j.smi.Variable
true
if the syntax of this variable is an instance of Null
and its syntax equals one of
the following:
SMIConstants.EXCEPTION_NO_SUCH_OBJECT
SMIConstants.EXCEPTION_NO_SUCH_INSTANCE
SMIConstants.EXCEPTION_END_OF_MIB_VIEW
public int toInt()
toInt
in interface org.snmp4j.smi.Variable
UnsupportedOperationException
- if an integer representation does not exists for this Variable.public long toLong()
toLong
in interface org.snmp4j.smi.Variable
UnsupportedOperationException
- if a long representation does not exists for this Variable.public String getSyntaxString()
getSyntaxString
in interface org.snmp4j.smi.Variable
public org.snmp4j.smi.OID toSubIndex(boolean impliedLength)
Variable
to a (sub-)index value.toSubIndex
in interface org.snmp4j.smi.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.UnsupportedOperationException
- if this variable cannot be used in an index.public void fromSubIndex(org.snmp4j.smi.OID subIndex, boolean impliedLength)
Variable
from the supplied (sub-)index.fromSubIndex
in interface org.snmp4j.smi.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.UnsupportedOperationException
- if this variable cannot be used in an index.public boolean isDynamic()
getBERLength()
for encoding enclosing SEQUENCES and the actual encoding of the Variable itself with 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); } }
isDynamic
in interface org.snmp4j.smi.Variable
true
because the variable might change its value between two calls to getBERLength()
and
encodeBER(java.io.OutputStream)
.public int getBERLength()
BERSerializable
object in bytes when encoded according to the Basic
Encoding Rules (BER).getBERLength
in interface org.snmp4j.asn1.BERSerializable
public int getBERPayloadLength()
BERSerializable
object in bytes when encoded according to
the Basic Encoding Rules (BER).getBERPayloadLength
in interface org.snmp4j.asn1.BERSerializable
public void decodeBER(org.snmp4j.asn1.BERInputStream inputStream) throws IOException
Variable
from an InputStream
.decodeBER
in interface org.snmp4j.asn1.BERSerializable
inputStream
- 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
Variable
to an OutputStream
.encodeBER
in interface org.snmp4j.asn1.BERSerializable
outputStream
- an OutputStream
.IOException
- if an error occurs while writing to the stream.Copyright © 2019 SNMP4J.org. All rights reserved.