|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.snmp.mibs.LeafSyntax
This class represents the syntax of a leaf node in a MIB module. If the appropriate MIB is loaded, the LeafSyntax instance for an ObjectID could be obtained from the MibOperations object using the following method.
mibOperations.getLeafSyntax(SnmpOID);The LeafSyntax instance for a MIB Node can be obtained from the MibNode instance using the following method.
mibNode.getSyntax();
Once you have the LeafSyntax instance for a node, you can create new SNMP variables with the given syntax, check syntax rules on variables, and get more information on the syntax.
Field Summary |
Fields inherited from interface com.adventnet.snmp.mibs.mibparser.MIBConstants |
ACCESS_ACCESSIBLE_FOR_NOTIFY, ACCESS_NOT_ACCESSIBLE, ACCESS_NOT_IMPLEMENTED, ACCESS_READ_CREATE, ACCESS_READ_ONLY, ACCESS_READ_WRITE, ACCESS_WRITE_ONLY, accessStr, AGENT_CAPABILITIES, alphaStr, BITSTRING, COUNTER, COUNTER32, COUNTER64, GAUGE, GAUGE32, INTEGER, INTEGER32, IPADDRESS, macroStr, MODULE_COMPLIANCE, MODULE_IDENTITY, NETWORKADDRESS, NOTIFICATION_GROUP, NOTIFICATION_TYPE, NULL, numericStr, OBJECT_GROUP, OBJECT_IDENTIFIER, OBJECT_IDENTITY, OBJECT_TYPE, OCTETSTRING, OPAQUE, SEQUENCE, STATUS_CURRENT, STATUS_DEPRECATED, STATUS_MANDATORY, STATUS_OBSOLETE, STATUS_OPTIONAL, statusStr, TEXTUAL_CONVENTION, TIMETICKS, TRAP_TYPE, UNSIGNED32 |
Method Summary | |
boolean |
checkValue(int i)
Checks whether the integer value argument is in the defined range for this syntax definition. |
boolean |
checkValue(java.lang.String s)
Checks whether the String value argument is in the defined range for this syntax definition. |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
SnmpVar |
createVariable(java.lang.String value)
Instantiates and returns an SnmpVar of type specified by this Syntax. |
SnmpVar |
createVariable(java.lang.String value,
java.lang.String enc)
Instantiates and returns an SnmpVar of type specified by this Syntax with respect to the encoding scheme. |
java.util.Vector |
decodeInstanceString(java.lang.String instance,
java.util.Vector indexMibNodes)
Decodes an instance string based on the instance and indexMibNodes. |
int[] |
encodeInstanceString(java.util.Vector indexVector,
java.util.Vector indexMibNodes)
Encodes an instance string based on the indexVector and indexMibNodes. |
java.lang.String |
getDescription()
Returns the description of the syntax. |
int[] |
getEnumint()
Gets the values for each of the enumerated integer values |
java.lang.String[] |
getEnumlabels()
Gives all the labels present for an enumerated syntax. |
java.lang.String |
getEquivname()
Gets the equivalent SNMP type name. |
int |
getInt(java.lang.String s)
Gets the int value of the label argument. |
java.lang.String |
getLabel(int val)
Gets the label corresponding to the integer value argument. |
long |
getMax()
Gives the maximum value allowed for the syntaxes. |
long |
getMin()
Gives the minimum value allowed for all the syntaxes. |
java.lang.String |
getName()
Returns the name of this LeafSyntax instance. |
java.lang.String[] |
getRangeItems()
Gets the range constraints available for this syntax. |
int |
getSize()
Gives the maximum size restriction for this syntax. |
LeafSyntax |
getSyntax()
Gives the syntax for this leafSyntax Object. |
byte |
getType()
Retrieves the SNMP ASN.1 tag value for this syntax. |
boolean |
isConstrained()
Checks whether the syntax has some range/size limitations explicitly defined in the MIB. |
boolean |
isEnumerated()
Checks whether the syntax is enumerated. |
boolean |
isRanged()
Checks to see if this syntax has size or value limitations. |
java.lang.String |
toString()
Returns the syntax name for display purposes. |
java.lang.String |
toTagString()
Gives the detailed description of this syntax. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public java.lang.String getName()
public java.lang.String getDescription()
public byte getType()
public java.lang.String getEquivname()
In case of MultiLevel-TC, returns the syntax of base TC.
For example, if the syntax of TC "LevelB" is "LevelA"
whose syntax is OCTET STRING,
then this method will
return OCTET STRING.
public java.lang.String[] getEnumlabels()
For example, if the syntax is INTEGER { up(1), down(2), testing(3) }
then the String array contain the following values
"up", "down" and "testing"
If you want to get a particular enumerated label, then you can
use the method getLabel(int).
The method getEnumint() can be used to get the enumerated values
available for an enumerated syntax.
getLabel(int)
,
getEnumint()
public int[] getEnumint()
For example, if the syntax is INTEGER { up(1), down(2), testing(3) }
then the integer array contain the following values
'1', '2' and '3'
If you want to get a particular enumerated value, then you can use
the method getInt(String).
The method getEnumlabels() can be used to get the enumerated labels
available for an enumerated syntax.
getInt(java.lang.String)
,
#getEnumlables
public int getSize()
getMin()
,
getMax()
public long getMin()
For the enumerated syntaxes, returns the minimum
of the enumerated values.
For example, if the syntax is INTEGER { up(1), down(2), testing(3) }
this method will return 1.
getMax()
public long getMax()
For the enumerated syntaxes, returns the maximum
of the enumerated values.
For example, if the syntax is INTEGER { up(1), down(2), testing(3) }
this method will return 3.
getMin()
public SnmpVar createVariable(java.lang.String value, java.lang.String enc) throws SnmpException
value
- the string representation of the value.enc
- the string for the encoding scheme to be used.
SnmpException
- is thrown on format errors.createVariable(String)
public SnmpVar createVariable(java.lang.String value) throws SnmpException
Depending on the ASN.1 tag value of this syntax, the corresponding SnmpVar object will be created.
OCTET STRING/BITS SnmpString
INTEGER/Integer32 SnmpInt
Unsigned32 SnmpUnsignedInt
Counter/Counter32 SnmpCounter
Gauge/Gauge32 SnmpGauge
Counter64 SnmpCounter64
The input string we can give in Hex or binary format.
In hex format, the value is enclosed within the single quotes
and endswith "h" or "H".
for example, '64'h or'64'H
For the binary format, the value is enclosed with single quotes and endswith "b" or "B". for example, '01100100'b or '01100100'B The byte string can be set for the OCTET STRING, the value should be enclosed within the quotes and each octets should be separated by colon.
For exaple, if we want to set the byte[] value to OCTET STRING object '0a:0b:0c:0d:0e:0f' then this value set as the byte array value.
value
- the string representation of the value.
SnmpException
- is thrown on format errors.public java.lang.String toString()
toString
in class java.lang.Object
getName()
public java.lang.String toTagString()
public java.lang.String getLabel(int val)
val
- the integer value which ought to be one of the enumerations.
public int getInt(java.lang.String s)
s
- the string value which should be one of the enumerations.
public boolean checkValue(int i)
In case of enumerated syntax, if the input argument is any one of the enumerated value, then this method will return true.
For other syntaxes, if the value is between the maximum
and minimum values or if it is one of the maximum and
minimum values, then this will return true.
i
- the integer value.
public boolean checkValue(java.lang.String s)
NOTE : This method is supposed to be used for the enumerated syntax where the input is the any one of the enumerated label. When used for any other syntaxes, this method checks whether the length of the input String argument exceeds the maximum size of the syntax.
s
- the string value.
public boolean isConstrained()
For example, if a node is defined with a syntax INTEGER, eventhough
it has a standard/default range (-2147483648 .. 2147483647), this
method will return false as there is no range constraints explicitly
imposed on the syntax in the MIB.
public boolean isEnumerated()
public boolean isRanged()
By default all the basic integer types have constraints on
their values in terms of numeric ranges and hence this method
will return true for all the basic integer datatypes.
isEnumerated()
public int[] encodeInstanceString(java.util.Vector indexVector, java.util.Vector indexMibNodes) throws java.lang.NumberFormatException
The instance int array should be concatenated to the oid int array to get the complete oid. For example if the tcpConnTable has the following entry.
tcpConnState | tcpConnLocalAddress | tcpConnLocalPort | tcpConnRemAddress | tcpConnRemPort |
established(5) | 128.253.154.64 | 23 | 128.253.154.3 | 1111 |
In this case assuming you wish to obtain the instance corresponding to tcpConnRemAddress. The index for tcpConnTable and hence the indexNodes vector will contain nodes corresponding to tcpConnLocalAddress, tcpConnLocalPort, tcpConnRemAddress and tcpConnRemPort in that order. The indexVector will contain the following SnmpVar objects.
SnmpIpAddress corresponding to 128.253.154.64
SnmpInt corresponding to port 23
SnmpIpAddress corresponding to 128.253.154.3 and
SnmpInt corresponding to port 1111
These should be in this very order.
The return value in this case will contain the int array containing
128.253.154.64.23.128.253.154.3.1111, the subids forming components
of the array.
indexVector
- Vector of SnmpVar instances. Each instance should
correspond to the index component value.indexMibNodes
- Vector containing the nodes corresponding to the
index MibNodes.
java.lang.NumberFormatException
public java.util.Vector decodeInstanceString(java.lang.String instance, java.util.Vector indexMibNodes) throws java.lang.NumberFormatException
For the syntax OCTET STRING and OBJECT IDENTIFIER, the length value has to be prepended before the instance value, unless it is defined IMPLIED.
If the SIZE clause is present with fixed length, the length need not be prepended before the instance value.
For example, if the syntax of the index node is OCTET STRING and if String value is "test", then the instance String must be "4.116.101.115.116".
If the index node is IMPLIED or if the syntax has a fixed length as
defined in the MIB, then the length value need not be prepended and
the instance String can be either "116.101.115.116" or
"4.116.101.115.116".
instance
- the encoded instance StringindexMibNodes
- Vector containing the nodes corresponding to the index MibNodes.
throws
- NumberFormatException
java.lang.NumberFormatException
public LeafSyntax getSyntax()
The idea is that each LeafSyntax could be a Textual-Convention.
In such a cases the textual convention's syntax will be applicable.
However if the textual convention's syntax is another textual
convention then we have a case where it should be possible to derive
the syntax tree without going into a cyclic loop.
public java.lang.String[] getRangeItems()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- is thrown if the object's class
does not support the Cloneable interface.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |