com.healthmarketscience.jackcess.impl
Class IndexImpl

java.lang.Object
  extended by com.healthmarketscience.jackcess.impl.IndexImpl
All Implemented Interfaces:
Index, Comparable<IndexImpl>

public class IndexImpl
extends Object
implements Index, Comparable<IndexImpl>

Access table (logical) index. Logical indexes are backed for IndexData, where one or more logical indexes could be backed by the same data.

Author:
Tim McCune

Nested Class Summary
static class IndexImpl.ForeignKeyReference
          Information about a foreign key reference defined in an index (when referential integrity should be enforced).
 
Nested classes/interfaces inherited from interface com.healthmarketscience.jackcess.Index
Index.Column
 
Field Summary
static byte FOREIGN_KEY_INDEX_TYPE
          index type for foreign key indexes
static byte PRIMARY_KEY_INDEX_TYPE
          index type for primary key indexes
 
Method Summary
 int compareTo(IndexImpl other)
           
 Object[] constructIndexRow(Map<String,?> 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.
 Object[] constructPartialIndexRow(Object filler, Map<String,?> row)
          Constructs an array of values appropriate for this index from the given column values, possibly only using a subset of the given values.
 Object[] constructPartialIndexRow(Object filler, String colName, Object value)
          Constructs an array of values appropriate for this index from the given column value, which must be the first column of the index.
 Object[] constructPartialIndexRowFromEntry(Object filler, Object... values)
          Constructs an array of values appropriate for this index from the given column values, possibly only providing a prefix subset of the index columns (at least one value must be provided).
 IndexData.EntryCursor cursor()
          Gets a new cursor for this index.
 IndexData.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.
 int getColumnCount()
           
 List<IndexData.ColumnDescriptor> getColumns()
           
 JetFormat getFormat()
           
 IndexData getIndexData()
           
 byte getIndexFlags()
           
 int getIndexNumber()
           
 String getName()
           
 PageChannel getPageChannel()
           
 IndexImpl.ForeignKeyReference getReference()
           
 IndexImpl getReferencedIndex()
           
 TableImpl 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 isRequired()
          Whether or not values are required for index columns.
 boolean isUnique()
          Whether or not index entries must be unique.
 CursorBuilder newCursor()
          Convenience method for constructing a new CursorBuilder for this Index.
 boolean shouldIgnoreNulls()
          Whether or not null values are actually recorded in the index.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PRIMARY_KEY_INDEX_TYPE

public static final byte PRIMARY_KEY_INDEX_TYPE
index type for primary key indexes

See Also:
Constant Field Values

FOREIGN_KEY_INDEX_TYPE

public static final byte FOREIGN_KEY_INDEX_TYPE
index type for foreign key indexes

See Also:
Constant Field Values
Method Detail

getIndexData

public IndexData getIndexData()

getTable

public TableImpl getTable()
Specified by:
getTable in interface Index

getFormat

public JetFormat getFormat()

getPageChannel

public PageChannel getPageChannel()

getIndexNumber

public int getIndexNumber()

getIndexFlags

public byte getIndexFlags()

getUniqueEntryCount

public int getUniqueEntryCount()

getUniqueEntryCountOffset

public int getUniqueEntryCountOffset()

getName

public String getName()
Specified by:
getName in interface Index

isPrimaryKey

public boolean isPrimaryKey()
Specified by:
isPrimaryKey in interface Index

isForeignKey

public boolean isForeignKey()
Specified by:
isForeignKey in interface Index

getReference

public IndexImpl.ForeignKeyReference getReference()

getReferencedIndex

public IndexImpl getReferencedIndex()
                             throws IOException
Specified by:
getReferencedIndex in interface Index
Returns:
the Index referenced by this Index's ForeignKeyReference (if it has one), otherwise null.
Throws:
IOException

shouldIgnoreNulls

public boolean shouldIgnoreNulls()
Description copied from interface: Index
Whether or not null values are actually recorded in the index.

Specified by:
shouldIgnoreNulls in interface Index

isUnique

public boolean isUnique()
Description copied from interface: Index
Whether or not index entries must be unique.

Some notes about uniqueness:

Specified by:
isUnique in interface Index

isRequired

public boolean isRequired()
Description copied from interface: Index
Whether or not values are required for index columns.

Specified by:
isRequired in interface Index

getColumns

public List<IndexData.ColumnDescriptor> getColumns()
Specified by:
getColumns in interface Index
Returns:
the Columns for this index (unmodifiable)

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface Index

newCursor

public CursorBuilder newCursor()
Description copied from interface: Index
Convenience method for constructing a new CursorBuilder for this Index.

Specified by:
newCursor in interface Index

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

cursor

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

Forces index initialization.

Throws:
IOException

cursor

public IndexData.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

constructPartialIndexRowFromEntry

public Object[] constructPartialIndexRowFromEntry(Object filler,
                                                  Object... values)
Constructs an array of values appropriate for this index from the given column values, possibly only providing a prefix subset of the index columns (at least one value must be provided). If a prefix entry is provided, any missing, trailing index entry values will use the given filler value.

Returns:
the appropriate sparse array of data
Throws:
IllegalArgumentException - if at least one value is not 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

constructPartialIndexRow

public Object[] constructPartialIndexRow(Object filler,
                                         String colName,
                                         Object value)
Constructs an array of values appropriate for this index from the given column value, which must be the first column of the index. Any missing, trailing index entry values will use the given filler value.

Returns:
the appropriate sparse array of data or null if no prefix list of columns for this index were provided

constructIndexRow

public Object[] constructIndexRow(Map<String,?> 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

constructPartialIndexRow

public Object[] constructPartialIndexRow(Object filler,
                                         Map<String,?> row)
Constructs an array of values appropriate for this index from the given column values, possibly only using a subset of the given values. A partial row can be created if one or more prefix column values are provided. If a prefix can be found, any missing, trailing index entry values will use the given filler value.

Returns:
the appropriate sparse array of data or null if no prefix list of columns for this index were provided

toString

public String toString()
Overrides:
toString in class Object

compareTo

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


Copyright © 2005–2017 Health Market Science. All rights reserved.