Class 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
    • 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 - 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 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 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(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)