Package mgui.datasources
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.Objectclone()booleanisPopulated()Test whether this index is currently populated.voidpopulate(DataRecordSet record_set)Populates this index with data fromrecordset.intseek(T seek_value)Seeks forseek_valuein this index.voidunpopulate()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
Populates this index with data fromrecordset.- Parameters:
recordset-- Throws:
DataSourceException
-
seek
Seeks forseek_valuein this index.- Parameters:
seek_value-- Returns:
- the index of the record containing
seek_value, if found;nullotherwise. - Throws:
DataSourceException- if this index is not currently populated
-
clone
public java.lang.Object clone()- Overrides:
clonein classjava.lang.Object
-