APIdia Launch Partner
Top Description Inners Fields Constructors Methods
io.github.spannm.jackcess.impl

public final Class IndexImpl

extends Object
implements Index, Comparable<IndexImpl>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, io.github.spannm.jackcess.Index
Imports
io.github.spannm.jackcess.CursorBuilder, .Index, .IndexBuilder, io.github.spannm.jackcess.util.ToStringBuilder, java.io.IOException, java.nio.ByteBuffer, java.util.Collections, .List, .Map, java.util.logging.Logger

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 and Inner Type Summary

Modifier and TypeClass and Description
public static class
IndexImpl.ForeignKeyReference

Information about a foreign key reference defined in an index (when referential integrity should be enforced).

Field Summary

Modifier and TypeField and Description
private static final byte
CASCADE_DELETES_FLAG

flag for indicating that deletes should cascade in a foreign key index

private static final byte
CASCADE_NULL_FLAG

flag for indicating that deletes should cascade a null in a foreign key index

private static final byte
CASCADE_UPDATES_FLAG

flag for indicating that updates should cascade in a foreign key index

private final IndexData
data

the actual data backing this index (more than one index may be backed by the same data

pack-priv static final byte
FK_PRIMARY_TABLE_TYPE

index table type for the "primary" table in a foreign key index

pack-priv static final byte
FK_SECONDARY_TABLE_TYPE

index table type for the "secondary" table in a foreign key index

public static final byte
FOREIGN_KEY_INDEX_TYPE

index type for foreign key indexes

private final int
indexNumber

0-based index number

private final byte
indexType

the type of the index

private static final int
INVALID_INDEX_NUMBER

indicate an invalid index number for foreign key field

pack-priv static final Logger
private String
name

Index name

public static final byte
PRIMARY_KEY_INDEX_TYPE

index type for primary key indexes

private final IndexImpl.ForeignKeyReference
reference

foreign key reference info, if any

Constructor Summary

AccessConstructor and Description
pack-priv
IndexImpl(ByteBuffer tableBuffer, List<IndexData> indexDatas, JetFormat format)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(IndexImpl other)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public Object[]

Returns:

the appropriate sparse array of data or null if not all columns for this index were provided
constructIndexRow
(String colName, Object value)

Constructs an array of values appropriate for this index from the given column value.

public Object[]

Returns:

the appropriate sparse array of data or null if not all columns for this index were provided
constructIndexRow
(Map<String, ?> row)

Constructs an array of values appropriate for this index from the given column values.

public Object[]

Returns:

the appropriate sparse array of data
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.

public Object[]

Returns:

the appropriate sparse array of data or null if no prefix list of columns for this index were provided
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.

public Object[]

Returns:

the appropriate sparse array of data or null if no prefix list of columns for this index were provided
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.

public Object[]

Returns:

the appropriate sparse array of data
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).

public IndexData.EntryCursor
cursor()

Gets a new cursor for this index.

public IndexData.EntryCursor
cursor(Object[]
the first row of data for the cursor, or null for the first entry
startRow
,
boolean
whether or not startRow is inclusive or exclusive
startInclusive
,
Object[]
the last row of data for the cursor, or null for the last entry
endRow
,
boolean
whether or not endRow is inclusive or exclusive
endInclusive
)

Gets a new cursor for this index, narrowed to the range defined by the given startRow and endRow.

public int
getColumnCount()

Implements io.github.spannm.jackcess.Index.getColumnCount.

Returns the number of columns covered by this index.

public List<IndexData.ColumnDescriptor>
getColumns()

Implements io.github.spannm.jackcess.Index.getColumns.

Returns the Columns for this index (unmodifiable).

public JetFormat
public IndexData
public byte
public int
public String
getName()

Implements io.github.spannm.jackcess.Index.getName.

Returns the name of this index.

public PageChannel
public IndexImpl.ForeignKeyReference
public IndexImpl
getReferencedIndex()

Implements io.github.spannm.jackcess.Index.getReferencedIndex.

Returns the Index referenced by this Index's ForeignKeyReference (if it has one), otherwise null.

public TableImpl
getTable()

Implements io.github.spannm.jackcess.Index.getTable.

Returns the table to which this index belongs.

public int
public int
public void
initialize()

Forces initialization of this index (actual parsing of index pages).

public boolean
isForeignKey()

Implements io.github.spannm.jackcess.Index.isForeignKey.

Returns true if this index backs a foreign key relationship.

public boolean
isInitialized()

Whether or not the complete index state has been read.

public boolean
isPrimaryKey()

Implements io.github.spannm.jackcess.Index.isPrimaryKey.

Returns true if this index is the primary key index for its table.

public boolean
isRequired()

Implements io.github.spannm.jackcess.Index.isRequired.

Whether or not values are required for index columns.

public boolean
isUnique()

Implements io.github.spannm.jackcess.Index.isUnique.

Whether or not index entries must be unique.

public CursorBuilder
newCursor()

Implements io.github.spannm.jackcess.Index.newCursor.

Convenience method for constructing a new CursorBuilder for this Index.

pack-priv void
public boolean
shouldIgnoreNulls()

Implements io.github.spannm.jackcess.Index.shouldIgnoreNulls.

Whether or not null values are actually recorded in the index.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private String
private static String
pack-priv static void
pack-priv static void
writeDefinitions(TableCreator
description of the indexes to write
creator
,
ByteBuffer
Buffer to write to
buffer
)

Writes the logical index definitions into a table definition buffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CASCADE_DELETES_FLAGback to summary
private static final byte CASCADE_DELETES_FLAG

flag for indicating that deletes should cascade in a foreign key index

CASCADE_NULL_FLAGback to summary
private static final byte CASCADE_NULL_FLAG

flag for indicating that deletes should cascade a null in a foreign key index

CASCADE_UPDATES_FLAGback to summary
private static final byte CASCADE_UPDATES_FLAG

flag for indicating that updates should cascade in a foreign key index

databack to summary
private final IndexData data

the actual data backing this index (more than one index may be backed by the same data

FK_PRIMARY_TABLE_TYPEback to summary
pack-priv static final byte FK_PRIMARY_TABLE_TYPE

index table type for the "primary" table in a foreign key index

FK_SECONDARY_TABLE_TYPEback to summary
pack-priv static final byte FK_SECONDARY_TABLE_TYPE

index table type for the "secondary" table in a foreign key index

FOREIGN_KEY_INDEX_TYPEback to summary
public static final byte FOREIGN_KEY_INDEX_TYPE

index type for foreign key indexes

indexNumberback to summary
private final int indexNumber

0-based index number

indexTypeback to summary
private final byte indexType

the type of the index

INVALID_INDEX_NUMBERback to summary
private static final int INVALID_INDEX_NUMBER

indicate an invalid index number for foreign key field

LOGGERback to summary
pack-priv static final Logger LOGGER
nameback to summary
private String name

Index name

PRIMARY_KEY_INDEX_TYPEback to summary
public static final byte PRIMARY_KEY_INDEX_TYPE

index type for primary key indexes

referenceback to summary
private final IndexImpl.ForeignKeyReference reference

foreign key reference info, if any

Constructor Detail

IndexImplback to summary
pack-priv IndexImpl(ByteBuffer tableBuffer, List<IndexData> indexDatas, JetFormat format)

Method Detail

compareToback to summary
public int compareTo(IndexImpl other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Annotations
@Override
constructIndexRowback to summary
public Object[] constructIndexRow(String colName, Object value)

Constructs an array of values appropriate for this index from the given column value.

Returns:Object[]

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

constructIndexRowback to summary
public Object[] constructIndexRow(Map<String, ?> row)

Constructs an array of values appropriate for this index from the given column values.

Returns:Object[]

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

constructIndexRowFromEntryback to summary
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:Object[]

the appropriate sparse array of data

Exceptions
IllegalArgumentException:
if the wrong number of values are provided
constructPartialIndexRowback to summary
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:Object[]

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

constructPartialIndexRowback to summary
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:Object[]

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

constructPartialIndexRowFromEntryback to summary
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:Object[]

the appropriate sparse array of data

Exceptions
IllegalArgumentException:
if at least one value is not provided
cursorback to summary
public IndexData.EntryCursor cursor() throws IOException

Gets a new cursor for this index.

Forces index initialization.

cursorback to summary
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:Object[]

the first row of data for the cursor, or null for the first entry

startInclusive:boolean

whether or not startRow is inclusive or exclusive

endRow:Object[]

the last row of data for the cursor, or null for the last entry

endInclusive:boolean

whether or not endRow is inclusive or exclusive

getColumnCountback to summary
public int getColumnCount()

Implements io.github.spannm.jackcess.Index.getColumnCount.

Doc from io.github.spannm.jackcess.Index.getColumnCount.

Returns the number of columns covered by this index.

Annotations
@Override
getColumnsback to summary
public List<IndexData.ColumnDescriptor> getColumns()

Implements io.github.spannm.jackcess.Index.getColumns.

Doc from io.github.spannm.jackcess.Index.getColumns.

Returns the Columns for this index (unmodifiable).

Annotations
@Override
getFormatback to summary
public JetFormat getFormat()
getIndexDataback to summary
public IndexData getIndexData()
getIndexFlagsback to summary
public byte getIndexFlags()
getIndexNumberback to summary
public int getIndexNumber()
getNameback to summary
public String getName()

Implements io.github.spannm.jackcess.Index.getName.

Doc from io.github.spannm.jackcess.Index.getName.

Returns the name of this index.

Annotations
@Override
getPageChannelback to summary
public PageChannel getPageChannel()
getReferenceback to summary
public IndexImpl.ForeignKeyReference getReference()
getReferencedIndexback to summary
public IndexImpl getReferencedIndex() throws IOException

Implements io.github.spannm.jackcess.Index.getReferencedIndex.

Doc from io.github.spannm.jackcess.Index.getReferencedIndex.

Returns the Index referenced by this Index's ForeignKeyReference (if it has one), otherwise null.

Annotations
@Override
getTableback to summary
public TableImpl getTable()

Implements io.github.spannm.jackcess.Index.getTable.

Doc from io.github.spannm.jackcess.Index.getTable.

Returns the table to which this index belongs.

Annotations
@Override
getUniqueEntryCountback to summary
public int getUniqueEntryCount()
getUniqueEntryCountOffsetback to summary
public int getUniqueEntryCountOffset()
initializeback to summary
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.

isForeignKeyback to summary
public boolean isForeignKey()

Implements io.github.spannm.jackcess.Index.isForeignKey.

Doc from io.github.spannm.jackcess.Index.isForeignKey.

Returns true if this index backs a foreign key relationship.

Annotations
@Override
isInitializedback to summary
public boolean isInitialized()

Whether or not the complete index state has been read.

isPrimaryKeyback to summary
public boolean isPrimaryKey()

Implements io.github.spannm.jackcess.Index.isPrimaryKey.

Doc from io.github.spannm.jackcess.Index.isPrimaryKey.

Returns true if this index is the primary key index for its table.

Annotations
@Override
isRequiredback to summary
public boolean isRequired()

Implements io.github.spannm.jackcess.Index.isRequired.

Doc from io.github.spannm.jackcess.Index.isRequired.

Whether or not values are required for index columns.

Annotations
@Override
isUniqueback to summary
public boolean isUnique()

Implements io.github.spannm.jackcess.Index.isUnique.

Doc from io.github.spannm.jackcess.Index.isUnique.

Whether or not index entries must be unique.

Some notes about uniqueness:

  • Access does not seem to consider multiple null entries invalid for a unique index
  • text indexes collapse case, and Access seems to compare only the index entry bytes, therefore two strings which differ only in case will violate the unique constraint
Annotations
@Override
newCursorback to summary
public CursorBuilder newCursor()

Implements io.github.spannm.jackcess.Index.newCursor.

Doc from io.github.spannm.jackcess.Index.newCursor.

Convenience method for constructing a new CursorBuilder for this Index.

Annotations
@Override
setNameback to summary
pack-priv void setName(String name)
shouldIgnoreNullsback to summary
public boolean shouldIgnoreNulls()

Implements io.github.spannm.jackcess.Index.shouldIgnoreNulls.

Doc from io.github.spannm.jackcess.Index.shouldIgnoreNulls.

Whether or not null values are actually recorded in the index.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
withErrorContextback to summary
private String withErrorContext(String msg)
withErrorContextback to summary
private static String withErrorContext(String msg, DatabaseImpl db, String idxName)
writeDefinitionback to summary
pack-priv static void writeDefinition(TableMutator mutator, IndexBuilder idx, ByteBuffer buffer)
writeDefinitionsback to summary
pack-priv static void writeDefinitions(TableCreator creator, ByteBuffer buffer)

Writes the logical index definitions into a table definition buffer.

Parameters
creator:TableCreator

description of the indexes to write

buffer:ByteBuffer

Buffer to write to

io.github.spannm.jackcess.impl back to summary

public Class IndexImpl.ForeignKeyReference

extends Object
Class Inheritance

Information about a foreign key reference defined in an index (when referential integrity should be enforced).

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private final boolean
private final int
private final int
private final byte

Constructor Summary

AccessConstructor and Description
public
ForeignKeyReference(byte tableType, int otherIndexNumber, int otherTablePageNumber, boolean cascadeUpdates, boolean cascadeDeletes, boolean cascadeNull)

Method Summary

Modifier and TypeMethod and Description
public int
public int
public byte
public boolean
public boolean
public boolean
public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cascadeDeletesback to summary
private final boolean cascadeDeletes
cascadeNullback to summary
private final boolean cascadeNull
cascadeUpdatesback to summary
private final boolean cascadeUpdates
otherIndexNumberback to summary
private final int otherIndexNumber
otherTablePageNumberback to summary
private final int otherTablePageNumber
tableTypeback to summary
private final byte tableType

Constructor Detail

ForeignKeyReferenceback to summary
public ForeignKeyReference(byte tableType, int otherIndexNumber, int otherTablePageNumber, boolean cascadeUpdates, boolean cascadeDeletes, boolean cascadeNull)

Method Detail

getOtherIndexNumberback to summary
public int getOtherIndexNumber()
getOtherTablePageNumberback to summary
public int getOtherTablePageNumber()
getTableTypeback to summary
public byte getTableType()
isCascadeDeletesback to summary
public boolean isCascadeDeletes()
isCascadeNullOnDeleteback to summary
public boolean isCascadeNullOnDelete()
isCascadeUpdatesback to summary
public boolean isCascadeUpdates()
isPrimaryTableback to summary
public boolean isPrimaryTable()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override