java.lang.Object
org.snmp4j.agent.mo.MOTableIndex
- All Implemented Interfaces:
MOTableIndexValidator
The
MOTableIndex
class represents a index definition of a
conceptual table. An index always has to implement also the
MOTableIndexValidator
interface for validation of index values
for newly created rows.- Version:
- 1.0
- Author:
- Frank Fock
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMOTableIndex
(MOTableSubIndex[] subIndexes) Creates a index definition from an array of sub-index definitions.MOTableIndex
(MOTableSubIndex[] subIndexes, boolean impliedLength) Creates a index definition from an array of sub-index definitions where the last sub-index may have an implied length.MOTableIndex
(MOTableSubIndex[] subIndexes, boolean impliedLength, MOTableIndexValidator validator) Creates a index definition from an array of sub-index definitions where the last sub-index may have an implied length. -
Method Summary
Modifier and TypeMethodDescriptiongetIndex
(int index) Gets the sub-index definition at the specified index.org.snmp4j.smi.OID
getIndexOID
(org.snmp4j.smi.Variable[] indexValues) Gets the index OID from an array of index values.org.snmp4j.smi.OID[]
getIndexOIDs
(org.snmp4j.smi.OID index) Split a table index into an array of object IDs each representing the value of its corresponding index object.org.snmp4j.smi.Variable[]
getIndexValues
(org.snmp4j.smi.OID index) Gets the index values contained in an index OID.Gets the index validator (if present).boolean
boolean
isValidIndex
(org.snmp4j.smi.OID index) Checks whether an index OID is a valid index for this index definition or not.void
setValidator
(MOTableIndexValidator validator) Sets the index validator associated with this index definition.int
size()
Gets the number of sub-index definitions in this index definition.toString()
-
Field Details
-
MAX_INDEX_OID_LENGTH
public static final int MAX_INDEX_OID_LENGTH- See Also:
-
-
Constructor Details
-
MOTableIndex
Creates a index definition from an array of sub-index definitions.- Parameters:
subIndexes
- an array of sub-index definitions with at least one element.
-
MOTableIndex
Creates a index definition from an array of sub-index definitions where the last sub-index may have an implied length.- Parameters:
subIndexes
- an array of sub-index definitions with at least one element.impliedLength
- iftrue
the last sub-index has an implied length if at has a variable length at all.
-
MOTableIndex
public MOTableIndex(MOTableSubIndex[] subIndexes, boolean impliedLength, MOTableIndexValidator validator) Creates a index definition from an array of sub-index definitions where the last sub-index may have an implied length.- Parameters:
subIndexes
- an array of sub-index definitions with at least one element.impliedLength
- iftrue
the last sub-index has an implied length if at has a variable length at all.validator
- an index validator that is called whenever a new index value needs to validated.
-
-
Method Details
-
getIndex
Gets the sub-index definition at the specified index.- Parameters:
index
- a valid sub-index index (zero-based).- Returns:
- the
MOTableSubIndex
.
-
isImpliedLength
public boolean isImpliedLength() -
getValidator
Gets the index validator (if present).- Returns:
- the
MOTableIndexValidator
associated with this index ornull
.
-
setValidator
Sets the index validator associated with this index definition.- Parameters:
validator
- aMOTableIndexValidator
instance.
-
size
public int size()Gets the number of sub-index definitions in this index definition.- Returns:
- the sub-index count.
-
isValidIndex
public boolean isValidIndex(org.snmp4j.smi.OID index) Checks whether an index OID is a valid index for this index definition or not.- Specified by:
isValidIndex
in interfaceMOTableIndexValidator
- Parameters:
index
- an OID (possibly zero length).- Returns:
true
if the index is valid orfalse
otherwise.
-
getIndexOIDs
public org.snmp4j.smi.OID[] getIndexOIDs(org.snmp4j.smi.OID index) Split a table index into an array of object IDs each representing the value of its corresponding index object. For example if a table's index would be defined as INDEX { ifIndex, ipAddress } and the index given would be "1.127.0.0.1" the resulting array would be { "1", "127.0.0.1" }- Parameters:
index
- an OID denoting a table's index value.- Returns:
- an array of OID instances with the same size as returned by
size()
. If the given index is not a valid object IDnull
is returned.
-
getIndexValues
public org.snmp4j.smi.Variable[] getIndexValues(org.snmp4j.smi.OID index) Gets the index values contained in an index OID.- Parameters:
index
- the index OID.- Returns:
- an array of values representing the index.
- See Also:
-
getIndexOID
public org.snmp4j.smi.OID getIndexOID(org.snmp4j.smi.Variable[] indexValues) Gets the index OID from an array of index values.- Parameters:
indexValues
- an array of Variable instances that has to match the number and type of sub-indexes in this index.- Returns:
- the corresponding index OID.
- See Also:
-
toString
-