Class MOTableIndex

java.lang.Object
org.snmp4j.agent.mo.MOTableIndex
All Implemented Interfaces:
MOTableIndexValidator

public class MOTableIndex extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Type
    Method
    Description
    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.
    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
    Sets the index validator associated with this index definition.
    int
    Gets the number of sub-index definitions in this index definition.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • 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 - if true 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 - if true 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

      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 or null.
    • setValidator

      public void setValidator(MOTableIndexValidator validator)
      Sets the index validator associated with this index definition.
      Parameters:
      validator - a MOTableIndexValidator 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 interface MOTableIndexValidator
      Parameters:
      index - an OID (possibly zero length).
      Returns:
      true if the index is valid or false 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 ID null 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

      public String toString()
      Overrides:
      toString in class Object