- java.lang.Object
-
- org.snmp4j.agent.mo.snmp.RowCount
-
- All Implemented Interfaces:
Cloneable,Comparable<org.snmp4j.smi.Variable>,org.snmp4j.asn1.BERSerializable,org.snmp4j.smi.Variable
public class RowCount extends Object implements org.snmp4j.smi.Variable
TheRowCountclass implements aVariablethat 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, aGauge32instance with the row count of the source table will be created.- Since:
- 3.2.1
- Author:
- Frank Fock
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Clones this variable.intcompareTo(org.snmp4j.smi.Variable o)voiddecodeBER(org.snmp4j.asn1.BERInputStream inputStream)Decodes aVariablefrom anInputStream.voidencodeBER(OutputStream outputStream)Encodes aVariableto anOutputStream.voidfromSubIndex(org.snmp4j.smi.OID subIndex, boolean impliedLength)Sets the value of thisVariablefrom the supplied (sub-)index.intgetBERLength()Returns the length of thisBERSerializableobject in bytes when encoded according to the Basic Encoding Rules (BER).intgetBERPayloadLength()Returns the length of the payload of thisBERSerializableobject in bytes when encoded according to the Basic Encoding Rules (BER).intgetSyntax()Gets the ASN.1 syntax identifier value of this SNMP variable.StringgetSyntaxString()Gets a textual description of this Variable.longgetValue()Gets the number of rows in the associated table as unsigned long value.booleanisDynamic()Indicates whether this variable is dynamic.booleanisException()Checks whether this variable represents an exception like noSuchObject, noSuchInstance, and endOfMibView.inttoInt()Returns an integer representation of this variable if such a representation exists.longtoLong()Returns a long representation of this variable if such a representation exists.org.snmp4j.smi.OIDtoSubIndex(boolean impliedLength)Converts the value of thisVariableto a (sub-)index value.
-
-
-
Method Detail
-
getValue
public long getValue()
Gets the number of rows in the associated table as unsigned long value.- Returns:
- the number of rows in the associated table (greater or equal to zero). Zero is returned if a
nulltable is associated.
-
compareTo
public int compareTo(org.snmp4j.smi.Variable o)
- Specified by:
compareToin interfaceComparable<org.snmp4j.smi.Variable>- Specified by:
compareToin interfaceorg.snmp4j.smi.Variable
-
clone
public Object clone()
Clones this variable. Cloning can be used by the SNMP4J API to better support concurrency by creating a clone for internal processing. The content of this object is independent to the content of the clone. Thus, changes to the clone will have no effect to this object.
-
getSyntax
public int getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable.- Specified by:
getSyntaxin interfaceorg.snmp4j.smi.Variable- Returns:
- an integer value < 128 for regular SMI objects and a value >= 128 for exception values like noSuchObject, noSuchInstance, and endOfMibView.
-
isException
public boolean isException()
Checks whether this variable represents an exception like noSuchObject, noSuchInstance, and endOfMibView.- Specified by:
isExceptionin interfaceorg.snmp4j.smi.Variable- Returns:
trueif the syntax of this variable is an instance ofNulland its syntax equals one of the following:SMIConstants.EXCEPTION_NO_SUCH_OBJECTSMIConstants.EXCEPTION_NO_SUCH_INSTANCESMIConstants.EXCEPTION_END_OF_MIB_VIEW
-
toInt
public int toInt()
Returns an integer representation of this variable if such a representation exists.- Specified by:
toIntin interfaceorg.snmp4j.smi.Variable- Returns:
- an integer value (if the native representation of this variable would be a long, then the long value will be casted to int).
- Throws:
UnsupportedOperationException- if an integer representation does not exists for this Variable.
-
toLong
public long toLong()
Returns a long representation of this variable if such a representation exists.- Specified by:
toLongin interfaceorg.snmp4j.smi.Variable- Returns:
- a long value.
- Throws:
UnsupportedOperationException- if a long representation does not exists for this Variable.
-
getSyntaxString
public String getSyntaxString()
Gets a textual description of this Variable.- Specified by:
getSyntaxStringin interfaceorg.snmp4j.smi.Variable- Returns:
- a textual description like 'Integer32' as used in the Structure of Management Information (SMI) modules. '?' is returned if the syntax is unknown.
-
toSubIndex
public org.snmp4j.smi.OID toSubIndex(boolean impliedLength)
Converts the value of thisVariableto a (sub-)index value.- Specified by:
toSubIndexin interfaceorg.snmp4j.smi.Variable- Parameters:
impliedLength- specifies if the sub-index has an implied length. This parameter applies to variable length variables only (e.g.OctetStringandOID). For other variables it has no effect.- Returns:
- an OID that represents this value as an (sub-)index.
- Throws:
UnsupportedOperationException- if this variable cannot be used in an index.
-
fromSubIndex
public void fromSubIndex(org.snmp4j.smi.OID subIndex, boolean impliedLength)Sets the value of thisVariablefrom the supplied (sub-)index.- Specified by:
fromSubIndexin interfaceorg.snmp4j.smi.Variable- Parameters:
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.OctetStringandOID). For other variables it has no effect.- Throws:
UnsupportedOperationException- if this variable cannot be used in an index.
-
isDynamic
public boolean isDynamic()
Indicates whether this variable is dynamic. If a variable is dynamic, precautions have to be taken when a Variable is serialized using BER encoding, because between determining the length withgetBERLength()for encoding enclosing SEQUENCES and the actual encoding of the Variable itself withencodeBER(java.io.OutputStream)changes to the value need to be blocked by synchronization. In order to ensure proper synchronization if aVariableis dynamic, modifications of the variables content need to synchronize on theVariableinstance. This can be achieved for the standard SMI Variable implementations for example bypublic static modifyVariable(Integer32 variable, int value) synchronize(variable) { variable.setValue(value); } }- Specified by:
isDynamicin interfaceorg.snmp4j.smi.Variable- Returns:
truebecause the variable might change its value between two calls togetBERLength()andencodeBER(java.io.OutputStream).
-
getBERLength
public int getBERLength()
Returns the length of thisBERSerializableobject in bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERLengthin interfaceorg.snmp4j.asn1.BERSerializable- Returns:
- the BER encoded length of this variable.
-
getBERPayloadLength
public int getBERPayloadLength()
Returns the length of the payload of thisBERSerializableobject in bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERPayloadLengthin interfaceorg.snmp4j.asn1.BERSerializable- Returns:
- the BER encoded length of this variable.
-
decodeBER
public void decodeBER(org.snmp4j.asn1.BERInputStream inputStream) throws IOExceptionDecodes aVariablefrom anInputStream.- Specified by:
decodeBERin interfaceorg.snmp4j.asn1.BERSerializable- Parameters:
inputStream- anInputStreamcontaining a BER encoded byte stream.- Throws:
IOException- if the stream could not be decoded by using BER rules.
-
encodeBER
public void encodeBER(OutputStream outputStream) throws IOException
Encodes aVariableto anOutputStream.- Specified by:
encodeBERin interfaceorg.snmp4j.asn1.BERSerializable- Parameters:
outputStream- anOutputStream.- Throws:
IOException- if an error occurs while writing to the stream.
-
-