com.healthmarketscience.jackcess
Class Index

java.lang.Object
  extended by com.healthmarketscience.jackcess.Index
All Implemented Interfaces:
Comparable<Index>
Direct Known Subclasses:
BigIndex, SimpleIndex

public abstract class Index
extends Object
implements Comparable<Index>

Access table index

Author:
Tim McCune

Nested Class Summary
static class Index.ColumnDescriptor
          Information about the columns in an index.
static class Index.Entry
          A single leaf entry in an index (points to a single row)
 class Index.EntryCursor
          Utility class to traverse the entries in the Index.
static class Index.EntryType
          type attributes for Entries which simplify comparisons
 
Field Summary
static Index.Entry FIRST_ENTRY
          special entry which is less than any other entry
static Index.Entry LAST_ENTRY
          special entry which is greater than any other entry
 
Method Summary
 void addRow(Object[] row, RowId rowId)
          Adds a row to this index
 int compareTo(Index other)
           
 Object[] constructIndexRow(Map<String,Object> row)
          Constructs an array of values appropriate for this index from the given column values.
 Object[] constructIndexRow(String colName, Object value)
          Constructs an array of values appropriate for this index from the given column value.
 Object[] constructIndexRowFromEntry(Object... values)
          Constructs an array of values appropriate for this index from the given column values, expected to match the columns for this index.
 Index.EntryCursor cursor()
          Gets a new cursor for this index.
 Index.EntryCursor cursor(Object[] startRow, boolean startInclusive, Object[] endRow, boolean endInclusive)
          Gets a new cursor for this index, narrowed to the range defined by the given startRow and endRow.
 void deleteRow(Object[] row, RowId rowId)
          Removes a row from this index
 List<Index.ColumnDescriptor> getColumns()
          Returns the Columns for this index (unmodifiable)
 JetFormat getFormat()
           
 byte getIndexFlags()
           
 int getIndexNumber()
           
 String getName()
           
 PageChannel getPageChannel()
           
 Table getTable()
           
 int getUniqueEntryCount()
           
 int getUniqueEntryCountOffset()
           
 void initialize()
          Forces initialization of this index (actual parsing of index pages).
 boolean isForeignKey()
           
 boolean isInitialized()
          Whether or not the complete index state has been read.
 boolean isPrimaryKey()
           
 boolean isUnique()
          Whether or not index entries must be unique.
 void read(ByteBuffer tableBuffer, List<Column> availableColumns)
          Read the index info from a tableBuffer
 void setIndexNumber(int indexNumber)
           
 void setIndexType(byte indexType)
           
 void setName(String name)
           
 boolean shouldIgnoreNulls()
          Whether or not null values are actually recorded in the index.
 String toString()
           
 void update()
          Writes the current index state to the database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRST_ENTRY

public static final Index.Entry FIRST_ENTRY
special entry which is less than any other entry


LAST_ENTRY

public static final Index.Entry LAST_ENTRY
special entry which is greater than any other entry

Method Detail

getTable

public Table getTable()

getFormat

public JetFormat getFormat()

getPageChannel

public PageChannel getPageChannel()

setIndexNumber

public void setIndexNumber(int indexNumber)

getIndexNumber

public int getIndexNumber()

setIndexType

public void setIndexType(byte indexType)

getIndexFlags

public byte getIndexFlags()

getUniqueEntryCount

public int getUniqueEntryCount()

getUniqueEntryCountOffset

public int getUniqueEntryCountOffset()

getName

public String getName()

setName

public void setName(String name)

isPrimaryKey

public boolean isPrimaryKey()

isForeignKey

public boolean isForeignKey()

shouldIgnoreNulls

public boolean shouldIgnoreNulls()
Whether or not null values are actually recorded in the index.


isUnique

public boolean isUnique()
Whether or not index entries must be unique.

Some notes about uniqueness:


getColumns

public List<Index.ColumnDescriptor> getColumns()
Returns the Columns for this index (unmodifiable)


isInitialized

public boolean isInitialized()
Whether or not the complete index state has been read.


initialize

public void initialize()
                throws IOException
Forces initialization of this index (actual parsing of index pages). normally, the index will not be initialized until the entries are actually needed.

Throws:
IOException

update

public void update()
            throws IOException
Writes the current index state to the database.

Forces index initialization.

Throws:
IOException

read

public void read(ByteBuffer tableBuffer,
                 List<Column> availableColumns)
          throws IOException
Read the index info from a tableBuffer

Parameters:
tableBuffer - table definition buffer to read from initial info
availableColumns - Columns that this index may use
Throws:
IOException

addRow

public void addRow(Object[] row,
                   RowId rowId)
            throws IOException
Adds a row to this index

Forces index initialization.

Parameters:
row - Row to add
rowId - rowId of the row to be added
Throws:
IOException

deleteRow

public void deleteRow(Object[] row,
                      RowId rowId)
               throws IOException
Removes a row from this index

Forces index initialization.

Parameters:
row - Row to remove
rowId - rowId of the row to be removed
Throws:
IOException

cursor

public Index.EntryCursor cursor()
                         throws IOException
Gets a new cursor for this index.

Forces index initialization.

Throws:
IOException

cursor

public Index.EntryCursor cursor(Object[] startRow,
                                boolean startInclusive,
                                Object[] endRow,
                                boolean endInclusive)
                         throws IOException
Gets a new cursor for this index, narrowed to the range defined by the given startRow and endRow.

Forces index initialization.

Parameters:
startRow - the first row of data for the cursor, or null for the first entry
startInclusive - whether or not startRow is inclusive or exclusive
endRow - the last row of data for the cursor, or null for the last entry
endInclusive - whether or not endRow is inclusive or exclusive
Throws:
IOException

constructIndexRowFromEntry

public Object[] constructIndexRowFromEntry(Object... values)
Constructs an array of values appropriate for this index from the given column values, expected to match the columns for this index.

Returns:
the appropriate sparse array of data
Throws:
IllegalArgumentException - if the wrong number of values are provided

constructIndexRow

public Object[] constructIndexRow(String colName,
                                  Object value)
Constructs an array of values appropriate for this index from the given column value.

Returns:
the appropriate sparse array of data or null if not all columns for this index were provided

constructIndexRow

public Object[] constructIndexRow(Map<String,Object> row)
Constructs an array of values appropriate for this index from the given column values.

Returns:
the appropriate sparse array of data or null if not all columns for this index were provided

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Index other)
Specified by:
compareTo in interface Comparable<Index>


Copyright ? 2005-2008 Health Market Science. All Rights Reserved.