- java.lang.Object
-
- org.snmp4j.agent.mo.MOTableIndex
-
- All Implemented Interfaces:
MOTableIndexValidator
public class MOTableIndex extends Object implements MOTableIndexValidator
TheMOTableIndex
class represents a index definition of a conceptual table. An index always has to implement also theMOTableIndexValidator
interface for validation of index values for newly created rows.- Version:
- 1.0
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_INDEX_OID_LENGTH
-
Constructor Summary
Constructors Constructor Description MOTableIndex(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MOTableSubIndex
getIndex(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.MOTableIndexValidator
getValidator()
Gets the index validator (if present).boolean
isImpliedLength()
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.String
toString()
-
-
-
Field Detail
-
MAX_INDEX_OID_LENGTH
public static final int MAX_INDEX_OID_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MOTableIndex
public MOTableIndex(MOTableSubIndex[] subIndexes)
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
public 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.- 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 Detail
-
getIndex
public MOTableSubIndex getIndex(int index)
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
public MOTableIndexValidator getValidator()
Gets the index validator (if present).- Returns:
- the
MOTableIndexValidator
associated with this index ornull
.
-
setValidator
public void setValidator(MOTableIndexValidator validator)
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(org.snmp4j.smi.Variable[])
-
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:
getIndexValues(org.snmp4j.smi.OID)
-
-