public class TableImpl extends Object implements Table
Is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static class |
TableImpl.IndexFeature |
class |
TableImpl.RowState
Maintains the state of reading/updating a row of data.
|
Table.ColumnOrder| Modifier and Type | Field and Description |
|---|---|
static byte |
TYPE_SYSTEM
Table type code for system tables
|
static byte |
TYPE_USER
Table type code for user tables
|
| Modifier and Type | Method and Description |
|---|---|
static int |
addDataPageRow(ByteBuffer dataPage,
int rowSize,
JetFormat format,
int rowFlags)
Updates free space and row info for a new row of the given size in the
given data page.
|
Object[] |
addRow(Object... row)
Adds a single row to this table and writes it to disk.
|
<M extends Map<String,Object>> |
addRowFromMap(M row)
Calls
Table.asRow(java.util.Map<java.lang.String, ?>) on the given row map and passes the result to Table.addRow(java.lang.Object...). |
List<? extends Object[]> |
addRows(List<? extends Object[]> rows)
Add multiple rows to this table, only writing to disk after all
rows have been written, and every time a data page is filled.
|
<M extends Map<String,Object>> |
addRowsFromMaps(List<M> rows)
Calls
Table.asRow(java.util.Map<java.lang.String, ?>) on the given row maps and passes the results to
Table.addRows(java.util.List<? extends java.lang.Object[]>). |
Object[] |
asRow(Map<String,?> rowMap)
Converts a map of columnName -> columnValue to an array of row values
appropriate for a call to
Table.addRow(Object...). |
Object[] |
asRowWithRowId(Map<String,?> rowMap)
Converts a map of columnName -> columnValue to an array of row values
appropriate for a call to
addRow(Object...), where the generated
RowId will be an extra value at the end of the array. |
Object[] |
asUpdateRow(Map<String,?> rowMap)
Converts a map of columnName -> columnValue to an array of row values
appropriate for a call to
Cursor.updateCurrentRow(Object...). |
static short |
cleanRowStart(short rowStart) |
TableImpl.RowState |
createRowState() |
Row |
deleteRow(Row row)
Delete the given row.
|
RowId |
deleteRow(RowId rowId)
Delete the row with the given id.
|
void |
deleteRow(TableImpl.RowState rowState,
RowIdImpl rowId)
Delete the row for the given rowId.
|
String |
display() |
String |
display(long limit) |
IndexImpl |
findIndexForColumns(Collection<String> searchColumns,
TableImpl.IndexFeature feature) |
static short |
findRowEnd(ByteBuffer buffer,
int rowNum,
JetFormat format) |
static short |
findRowStart(ByteBuffer buffer,
int rowNum,
JetFormat format) |
int |
getApproximateOwnedPageCount()
Returns the approximate number of database pages owned by this
table and all related indexes (this number does not take into
account pages used for large OLE/MEMO fields).
|
ColumnImpl |
getColumn(String name) |
int |
getColumnCount() |
List<ColumnImpl> |
getColumns() |
LocalDateTime |
getCreatedDate() |
DatabaseImpl |
getDatabase() |
CursorImpl |
getDefaultCursor() |
ErrorHandler |
getErrorHandler()
Gets the currently configured ErrorHandler (always non-
null). |
IndexImpl |
getForeignKeyIndex(Table otherTable) |
JetFormat |
getFormat() |
IndexImpl |
getIndex(String name) |
List<IndexData> |
getIndexDatas() |
List<IndexImpl> |
getIndexes() |
int |
getLogicalIndexCount()
Only called by unit tests
|
int |
getMaxColumnCount() |
String |
getName() |
Row |
getNextRow() |
UsageMap.PageCursor |
getOwnedPagesCursor() |
PageChannel |
getPageChannel() |
IndexImpl |
getPrimaryKeyIndex() |
PropertyMap |
getProperties() |
PropertyMaps |
getPropertyMaps() |
RowImpl |
getRow(TableImpl.RowState rowState,
RowIdImpl rowId,
Collection<String> columnNames)
Reads some columns from the given row.
|
int |
getRowCount() |
static int |
getRowEndOffset(int rowNum,
JetFormat format) |
RowId |
getRowId(Object[] row) |
static int |
getRowSpaceUsage(int rowSize,
JetFormat format) |
static int |
getRowStartOffset(int rowNum,
JetFormat format) |
Object |
getRowValue(TableImpl.RowState rowState,
RowIdImpl rowId,
ColumnImpl column)
Reads a single column from the given row.
|
int |
getTableDefPageNumber() |
LocalDateTime |
getUpdatedDate()
Note: jackcess does not automatically update the modified date of a
Table.
|
boolean |
hasColumn(String name) |
boolean |
isAllowAutoNumberInsert()
Gets the currently configured auto number insert policy.
|
static boolean |
isDeletedRow(short rowStart) |
boolean |
isHidden()
Whether or not this table has been marked as hidden.
|
static boolean |
isOverflowRow(short rowStart) |
boolean |
isSystem()
Whether or not this table is a system (internal) table.
|
Iterator<Row> |
iterator()
Calls
Table.reset() on this table and returns a modifiable
Iterator which will iterate through all the rows of this table. |
CursorBuilder |
newCursor()
Convenience method for constructing a new CursorBuilder for this Table.
|
static ByteBuffer |
positionAtRowData(TableImpl.RowState rowState,
RowIdImpl rowId)
Sets the position and limit in a new buffer using the given rowState
according to the given row number and row end, following overflow row
pointers as necessary.
|
static ByteBuffer |
positionAtRowHeader(TableImpl.RowState rowState,
RowIdImpl rowId)
Sets a new buffer to the correct row header page using the given rowState
according to the given rowId.
|
void |
propertiesUpdated()
Invoked when new properties are saved.
|
void |
reset()
After calling this method,
Table.getNextRow() will return the first row
in the table, see Cursor.reset() (uses the default cursor). |
static boolean |
rowFitsOnDataPage(int rowLength,
ByteBuffer dataPage,
JetFormat format)
Returns
true if a row of the given size will fit on the given
data page, false otherwise. |
void |
setAllowAutoNumberInsert(Boolean allowAutoNumInsert)
Sets the new auto number insert policy for the Table.
|
void |
setErrorHandler(ErrorHandler newErrorHandler)
Sets a new ErrorHandler.
|
String |
toString() |
Row |
updateRow(Row row)
Update the given row.
|
Object[] |
updateRow(RowId rowId,
Object... row)
Update the row with the given id.
|
Object[] |
updateRow(TableImpl.RowState rowState,
RowIdImpl rowId,
Object... row)
Update the row for the given rowId.
|
<M extends Map<String,Object>> |
updateRowFromMap(TableImpl.RowState rowState,
RowIdImpl rowId,
M row) |
void |
updateValue(Column column,
RowId rowId,
Object value)
Update the given column's value for the given row id.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic static final byte TYPE_SYSTEM
public static final byte TYPE_USER
public String getName()
getName in interface TablegetName in interface TableDefinitionpublic boolean isHidden()
TableisHidden in interface TableisHidden in interface TableDefinitionpublic boolean isSystem()
TableisSystem in interface TableisSystem in interface TableDefinitionpublic int getMaxColumnCount()
public int getColumnCount()
getColumnCount in interface TablegetColumnCount in interface TableDefinitionpublic DatabaseImpl getDatabase()
getDatabase in interface TablegetDatabase in interface TableDefinitionpublic JetFormat getFormat()
public PageChannel getPageChannel()
public ErrorHandler getErrorHandler()
Tablenull).
This will be used to handle all errors unless overridden at the Cursor
level.getErrorHandler in interface Tablepublic void setErrorHandler(ErrorHandler newErrorHandler)
Tablenull, resets to using the
ErrorHandler configured at the Database level.setErrorHandler in interface Tablepublic int getTableDefPageNumber()
public boolean isAllowAutoNumberInsert()
TableisAllowAutoNumberInsert in interface TableDatabase.isAllowAutoNumberInsert()public void setAllowAutoNumberInsert(Boolean allowAutoNumInsert)
Tablenull,
resets to using the policy configured at the Database level.setAllowAutoNumberInsert in interface Tablepublic TableImpl.RowState createRowState()
public UsageMap.PageCursor getOwnedPagesCursor()
public int getApproximateOwnedPageCount()
To calculate the approximate number of bytes owned by a table:
int approxTableBytes = (table.getApproximateOwnedPageCount() *
table.getFormat().PAGE_SIZE);
public List<ColumnImpl> getColumns()
getColumns in interface TablegetColumns in interface TableDefinitionpublic ColumnImpl getColumn(String name)
getColumn in interface TablegetColumn in interface TableDefinitionpublic boolean hasColumn(String name)
public PropertyMap getProperties() throws IOException
getProperties in interface TablegetProperties in interface TableDefinitionIOExceptionpublic LocalDateTime getCreatedDate() throws IOException
getCreatedDate in interface TablegetCreatedDate in interface TableDefinitionIOExceptionpublic LocalDateTime getUpdatedDate() throws IOException
TablegetUpdatedDate in interface TablegetUpdatedDate in interface TableDefinitionIOExceptionpublic PropertyMaps getPropertyMaps() throws IOException
IOExceptionpublic void propertiesUpdated()
throws IOException
IOExceptionpublic List<IndexImpl> getIndexes()
getIndexes in interface TablegetIndexes in interface TableDefinitionpublic IndexImpl getIndex(String name)
getIndex in interface TablegetIndex in interface TableDefinitionpublic IndexImpl getPrimaryKeyIndex()
getPrimaryKeyIndex in interface TablegetPrimaryKeyIndex in interface TableDefinitionpublic IndexImpl getForeignKeyIndex(Table otherTable)
getForeignKeyIndex in interface TablegetForeignKeyIndex in interface TableDefinitionpublic List<IndexData> getIndexDatas()
public int getLogicalIndexCount()
public IndexImpl findIndexForColumns(Collection<String> searchColumns, TableImpl.IndexFeature feature)
public CursorImpl getDefaultCursor()
getDefaultCursor in interface Tablepublic CursorBuilder newCursor()
Tablepublic void reset()
TableTable.getNextRow() will return the first row
in the table, see Cursor.reset() (uses the default cursor).public Row deleteRow(Row row) throws IOException
TabledeleteRow in interface TableIOExceptionpublic RowId deleteRow(RowId rowId) throws IOException
IllegalStateException - if the given row is not validIOExceptionpublic void deleteRow(TableImpl.RowState rowState, RowIdImpl rowId) throws IOException
IOExceptionpublic Row getNextRow() throws IOException
getNextRow in interface Tabledefault cursor)IOExceptionpublic Object getRowValue(TableImpl.RowState rowState, RowIdImpl rowId, ColumnImpl column) throws IOException
IOExceptionpublic RowImpl getRow(TableImpl.RowState rowState, RowIdImpl rowId, Collection<String> columnNames) throws IOException
columnNames - Only column names in this collection will be returnedIOExceptionpublic static ByteBuffer positionAtRowHeader(TableImpl.RowState rowState, RowIdImpl rowId) throws IOException
IOExceptionpublic static ByteBuffer positionAtRowData(TableImpl.RowState rowState, RowIdImpl rowId) throws IOException
IOExceptionpublic Iterator<Row> iterator()
TableTable.reset() on this table and returns a modifiable
Iterator which will iterate through all the rows of this table. Use of
the Iterator follows the same restrictions as a call to
Table.getNextRow().
For more advanced iteration, use the default
cursor directly.
public Object[] asRow(Map<String,?> rowMap)
TableTable.addRow(Object...).public Object[] asRowWithRowId(Map<String,?> rowMap)
addRow(Object...), where the generated
RowId will be an extra value at the end of the array.ColumnImpl.RETURN_ROW_IDpublic Object[] asUpdateRow(Map<String,?> rowMap)
TableCursor.updateCurrentRow(Object...).asUpdateRow in interface Tablepublic RowId getRowId(Object[] row)
asRowWithRowId(java.util.Map<java.lang.String, ?>)public Object[] addRow(Object... row) throws IOException
TableTable.getColumns() method. This is by default the storage order of the
Columns in the database, however this order can be influenced by setting
the ColumnOrder via Database.setColumnOrder(com.healthmarketscience.jackcess.Table.ColumnOrder) prior to opening
the Table. The Table.asRow(java.util.Map<java.lang.String, ?>) method can be used to easily convert a row
Map into the appropriate row array for this Table.
Note, if this table has an auto-number column, the value generated will be put back into the given row array (assuming the given row array is at least as long as the number of Columns in this Table).
addRow in interface Tablerow - row values for a single row. the given row array will be
modified if this table contains an auto-number column,
otherwise it will not be modified.IOExceptionpublic <M extends Map<String,Object>> M addRowFromMap(M row) throws IOException
TableTable.asRow(java.util.Map<java.lang.String, ?>) on the given row map and passes the result to Table.addRow(java.lang.Object...).
Note, if this table has an auto-number column, the value generated will be put back into the given row map.
addRowFromMap in interface TableIOExceptionpublic List<? extends Object[]> addRows(List<? extends Object[]> rows) throws IOException
TableTable.addRow(java.lang.Object...) multiple times.
Note, if this table has an auto-number column, the values written will be put back into the given row arrays (assuming the given row array is at least as long as the number of Columns in this Table).
Most exceptions thrown from this method will be wrapped with a BatchUpdateException which gives useful information in the case of a
partially successful write.
addRows in interface Tablerows - List of Object[] row values. the rows will be modified if
this table contains an auto-number column, otherwise they
will not be modified.IOExceptionfor more details on row arrayspublic <M extends Map<String,Object>> List<M> addRowsFromMaps(List<M> rows) throws IOException
TableTable.asRow(java.util.Map<java.lang.String, ?>) on the given row maps and passes the results to
Table.addRows(java.util.List<? extends java.lang.Object[]>).
Note, if this table has an auto-number column, the values generated will be put back into the appropriate row maps.
Most exceptions thrown from this method will be wrapped with a BatchUpdateException which gives useful information in the case of a
partially successful write.
addRowsFromMaps in interface TableIOExceptionpublic Row updateRow(Row row) throws IOException
TableupdateRow in interface TableIOExceptionpublic Object[] updateRow(RowId rowId, Object... row) throws IOException
IllegalStateException - if the given row is not valid, or deleted.IOExceptionpublic void updateValue(Column column, RowId rowId, Object value) throws IOException
IllegalStateException - if the given row is not valid, or deleted.IOExceptionpublic <M extends Map<String,Object>> M updateRowFromMap(TableImpl.RowState rowState, RowIdImpl rowId, M row) throws IOException
IOExceptionpublic Object[] updateRow(TableImpl.RowState rowState, RowIdImpl rowId, Object... row) throws IOException
IOExceptionpublic int getRowCount()
getRowCount in interface Tablepublic String display() throws IOException
IOExceptionpublic String display(long limit) throws IOException
limit - Maximum number of rows to displayIOExceptionpublic static int addDataPageRow(ByteBuffer dataPage, int rowSize, JetFormat format, int rowFlags)
public static boolean isDeletedRow(short rowStart)
public static boolean isOverflowRow(short rowStart)
public static short cleanRowStart(short rowStart)
public static short findRowStart(ByteBuffer buffer, int rowNum, JetFormat format)
public static int getRowStartOffset(int rowNum,
JetFormat format)
public static short findRowEnd(ByteBuffer buffer, int rowNum, JetFormat format)
public static int getRowEndOffset(int rowNum,
JetFormat format)
public static int getRowSpaceUsage(int rowSize,
JetFormat format)
public static boolean rowFitsOnDataPage(int rowLength,
ByteBuffer dataPage,
JetFormat format)
true if a row of the given size will fit on the given
data page, false otherwise.Copyright © 2005–2025 OpenHMS. All rights reserved.