Class DataIndex<T extends java.lang.Comparable<T>>

java.lang.Object
mgui.datasources.DataIndex<T>
All Implemented Interfaces:
java.lang.Cloneable

public class DataIndex<T extends java.lang.Comparable<T>>
extends java.lang.Object
implements java.lang.Cloneable
Class to index specified fields in a table. Provides method to populate an index from a record set, and subsequently perform quick searching of the indexed field. Fields must be unique in order to be indexed.

NOTE: Record indices provided by DataIndex and handled by DataRecordSet start at zero, whereas JDBC's ResultSet starts at 1. This should be taken into consideration when working directly with ResultSets.

Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Constructor Summary

    Constructors
    Constructor Description
    DataIndex​(java.lang.String field_name)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.Object clone()  
    boolean isPopulated()
    Test whether this index is currently populated.
    void populate​(DataRecordSet record_set)
    Populates this index with data from recordset.
    int seek​(T seek_value)
    Seeks for seek_value in this index.
    void unpopulate()
    Unpopulate this index.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DataIndex

      public DataIndex​(java.lang.String field_name)
  • Method Details

    • isPopulated

      public boolean isPopulated()
      Test whether this index is currently populated.
      Returns:
    • unpopulate

      public void unpopulate()
      Unpopulate this index.
    • populate

      public void populate​(DataRecordSet record_set) throws DataSourceException
      Populates this index with data from recordset.
      Parameters:
      recordset -
      Throws:
      DataSourceException
    • seek

      public int seek​(T seek_value) throws DataSourceException
      Seeks for seek_value in this index.
      Parameters:
      seek_value -
      Returns:
      the index of the record containing seek_value, if found; null otherwise.
      Throws:
      DataSourceException - if this index is not currently populated
    • clone

      public java.lang.Object clone()
      Overrides:
      clone in class java.lang.Object