public interface Table extends Iterable<Row>, TableDefinition
Database
instance. The Table instance provides access to the table
metadata as well as the table data. There are basic data operations on the
Table interface (i.e. iterator()
addRow(java.lang.Object...)
, updateRow(com.healthmarketscience.jackcess.Row)
and deleteRow(com.healthmarketscience.jackcess.Row)
), but for advanced search and data manipulation a
Cursor
instance should be used. New Tables can be created using a
TableBuilder
. The Joiner
utility can be used to traverse
table relationships (e.g. find rows in another table based on a foreign-key
relationship).
A Table instance is not thread-safe (see Database
for more
thread-safety details).
Modifier and Type | Interface and Description |
---|---|
static class |
Table.ColumnOrder
enum which controls the ordering of the columns in a table.
|
Modifier and Type | Method and Description |
---|---|
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
asRow(java.util.Map<java.lang.String, ?>) on the given row map and passes the result to 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
asRow(java.util.Map<java.lang.String, ?>) on the given row maps and passes the results to
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
addRow(Object...) . |
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...) . |
Row |
deleteRow(Row row)
Delete the given row.
|
Column |
getColumn(String name) |
int |
getColumnCount() |
List<? extends Column> |
getColumns() |
LocalDateTime |
getCreatedDate() |
Database |
getDatabase() |
Cursor |
getDefaultCursor() |
ErrorHandler |
getErrorHandler()
Gets the currently configured ErrorHandler (always non-
null ). |
Index |
getForeignKeyIndex(Table otherTable) |
Index |
getIndex(String name) |
List<? extends Index> |
getIndexes() |
String |
getName() |
Row |
getNextRow() |
Index |
getPrimaryKeyIndex() |
PropertyMap |
getProperties() |
int |
getRowCount() |
LocalDateTime |
getUpdatedDate()
Note: jackcess does not automatically update the modified date of a
Table.
|
boolean |
isAllowAutoNumberInsert()
Gets the currently configured auto number insert policy.
|
boolean |
isHidden()
Whether or not this table has been marked as hidden.
|
boolean |
isSystem()
Whether or not this table is a system (internal) table.
|
Iterator<Row> |
iterator()
Calls
reset() on this table and returns a modifiable
Iterator which will iterate through all the rows of this table. |
default OleBlob.Builder |
newBlob()
Convenience method for constructing a new OleBlob.Builder.
|
CursorBuilder |
newCursor()
Convenience method for constructing a new CursorBuilder for this Table.
|
void |
reset()
After calling this method,
getNextRow() will return the first row
in the table, see Cursor.reset() (uses the default cursor ). |
void |
setAllowAutoNumberInsert(Boolean allowAutoNumInsert)
Sets the new auto number insert policy for the Table.
|
void |
setErrorHandler(ErrorHandler newErrorHandler)
Sets a new ErrorHandler.
|
default Stream<Row> |
stream() |
Row |
updateRow(Row row)
Update the given row.
|
forEach, spliterator
String getName()
getName
in interface TableDefinition
boolean isHidden()
isHidden
in interface TableDefinition
boolean isSystem()
isSystem
in interface TableDefinition
int getColumnCount()
getColumnCount
in interface TableDefinition
Database getDatabase()
getDatabase
in interface TableDefinition
ErrorHandler getErrorHandler()
null
).
This will be used to handle all errors unless overridden at the Cursor
level.void setErrorHandler(ErrorHandler newErrorHandler)
null
, resets to using the
ErrorHandler configured at the Database level.boolean isAllowAutoNumberInsert()
Database.isAllowAutoNumberInsert()
void setAllowAutoNumberInsert(Boolean allowAutoNumInsert)
null
,
resets to using the policy configured at the Database level.List<? extends Column> getColumns()
getColumns
in interface TableDefinition
Column getColumn(String name)
getColumn
in interface TableDefinition
PropertyMap getProperties() throws IOException
getProperties
in interface TableDefinition
IOException
LocalDateTime getCreatedDate() throws IOException
getCreatedDate
in interface TableDefinition
IOException
LocalDateTime getUpdatedDate() throws IOException
getUpdatedDate
in interface TableDefinition
IOException
List<? extends Index> getIndexes()
getIndexes
in interface TableDefinition
Index getIndex(String name)
getIndex
in interface TableDefinition
IllegalArgumentException
- if there is no index with the given nameIndex getPrimaryKeyIndex()
getPrimaryKeyIndex
in interface TableDefinition
IllegalArgumentException
- if there is no primary key index on this
tableIndex getForeignKeyIndex(Table otherTable)
getForeignKeyIndex
in interface TableDefinition
IllegalArgumentException
- if there is no relationship between this
table and the given tableObject[] asRow(Map<String,?> rowMap)
addRow(Object...)
.Object[] asUpdateRow(Map<String,?> rowMap)
Cursor.updateCurrentRow(Object...)
.int getRowCount()
Object[] addRow(Object... row) throws IOException
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 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).
row
- 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.IOException
<M extends Map<String,Object>> M addRowFromMap(M row) throws IOException
asRow(java.util.Map<java.lang.String, ?>)
on the given row map and passes the result to 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.
IOException
List<? extends Object[]> addRows(List<? extends Object[]> rows) throws IOException
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.
rows
- List of Object[] row values. the rows will be modified if
this table contains an auto-number column, otherwise they
will not be modified.IOException
for more details on row arrays
<M extends Map<String,Object>> List<M> addRowsFromMaps(List<M> rows) throws IOException
asRow(java.util.Map<java.lang.String, ?>)
on the given row maps and passes the results to
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.
IOException
Row updateRow(Row row) throws IOException
IllegalStateException
- if the given row is not valid, or deleted.IOException
Row deleteRow(Row row) throws IOException
IllegalStateException
- if the given row is not validIOException
Iterator<Row> iterator()
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
getNextRow()
.
For more advanced iteration, use the default
cursor
directly.
iterator
in interface Iterable<Row>
RuntimeIOException
- if an IOException is thrown by one of the
operations, the actual exception will be contained withinvoid reset()
getNextRow()
will return the first row
in the table, see Cursor.reset()
(uses the default cursor
).Row getNextRow() throws IOException
default cursor
)IOException
Cursor getDefaultCursor()
CursorBuilder newCursor()
default OleBlob.Builder newBlob()
Copyright © 2005–2024 OpenHMS. All rights reserved.