|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.healthmarketscience.jackcess.impl.TableImpl
public class TableImpl
A single database table
Is not thread-safe.
| Nested Class Summary | |
|---|---|
static class |
TableImpl.IndexFeature
|
class |
TableImpl.RowState
Maintains the state of reading/updating a row of data. |
protected static class |
TableImpl.WriteRowState
Maintains state for writing a new row of data. |
| Nested classes/interfaces inherited from interface com.healthmarketscience.jackcess.Table |
|---|
Table.ColumnOrder |
| Field Summary | |
|---|---|
static byte |
TYPE_SYSTEM
Table type code for system tables |
static byte |
TYPE_USER
Table type code for user tables |
| Constructor Summary | |
|---|---|
protected |
TableImpl(boolean testing,
List<ColumnImpl> columns)
Only used by unit tests |
protected |
TableImpl(DatabaseImpl database,
ByteBuffer tableBuffer,
int pageNumber,
String name,
int flags)
|
| Method Summary | ||
|---|---|---|
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. |
|
|
addRowFromMap(M row)
Calls Table.asRow(java.util.Map 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. |
|
|
addRowsFromMaps(List<M> rows)
Calls Table.asRow(java.util.Map 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)
|
|
protected ByteBuffer |
createRow(Object[] rowArray,
ByteBuffer buffer)
|
|
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()
|
|
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 |
|
protected TempPageHolder |
getLongValueBuffer()
|
|
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()
|
|
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. |
|
protected ColumnImpl |
mutateAddColumn(TableUpdater mutator)
Writes a column defined by the given TableUpdater to this table. |
|
protected IndexImpl |
mutateAddIndex(TableUpdater mutator)
Writes a index defined by the given TableUpdater to this table. |
|
protected IndexData |
mutateAddIndexData(TableUpdater mutator)
Writes a index defined by the given TableUpdater to 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 |
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. |
|
|
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. |
|
protected static void |
writeTableDefinition(TableCreator creator)
Writes a new table defined by the given TableCreator to the database. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final byte TYPE_SYSTEM
public static final byte TYPE_USER
| Constructor Detail |
|---|
protected TableImpl(boolean testing,
List<ColumnImpl> columns)
throws IOException
IOException
protected TableImpl(DatabaseImpl database,
ByteBuffer tableBuffer,
int pageNumber,
String name,
int flags)
throws IOException
database - database which owns this tabletableBuffer - Buffer to read the table withpageNumber - Page number of the table definitionname - Table name
IOException| Method Detail |
|---|
public String getName()
getName in interface Tablepublic boolean isHidden()
Table
isHidden in interface Tablepublic boolean isSystem()
Table
isSystem in interface Tablepublic int getMaxColumnCount()
public int getColumnCount()
getColumnCount in interface Tablepublic DatabaseImpl getDatabase()
getDatabase in interface Tablepublic 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()
Table
isAllowAutoNumberInsert 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);
protected TempPageHolder getLongValueBuffer()
public List<ColumnImpl> getColumns()
getColumns in interface Tablepublic ColumnImpl getColumn(String name)
getColumn in interface Tablepublic boolean hasColumn(String name)
public PropertyMap getProperties()
throws IOException
getProperties in interface TableIOException
public PropertyMaps getPropertyMaps()
throws IOException
IOExceptionpublic List<IndexImpl> getIndexes()
getIndexes in interface Tablepublic IndexImpl getIndex(String name)
getIndex in interface Tablepublic IndexImpl getPrimaryKeyIndex()
getPrimaryKeyIndex in interface Tablepublic IndexImpl getForeignKeyIndex(Table otherTable)
getForeignKeyIndex in interface Tablepublic List<IndexData> getIndexDatas()
public int getLogicalIndexCount()
public IndexImpl findIndexForColumns(Collection<String> searchColumns,
TableImpl.IndexFeature feature)
public CursorImpl getDefaultCursor()
getDefaultCursor in interface Tablepublic CursorBuilder newCursor()
Table
newCursor in interface Tablepublic void reset()
TableTable.getNextRow() will return the first row
in the table, see Cursor.reset() (uses the default cursor).
reset in interface Table
public Row deleteRow(Row row)
throws IOException
Table
deleteRow in interface TableIOException
public RowId deleteRow(RowId rowId)
throws IOException
IllegalStateException - if the given row is not valid
IOException
public void deleteRow(TableImpl.RowState rowState,
RowIdImpl rowId)
throws IOException
IOException
public Row getNextRow()
throws IOException
getNextRow in interface Tabledefault cursor)
IOException
public Object getRowValue(TableImpl.RowState rowState,
RowIdImpl rowId,
ColumnImpl column)
throws IOException
IOException
public RowImpl getRow(TableImpl.RowState rowState,
RowIdImpl rowId,
Collection<String> columnNames)
throws IOException
columnNames - Only column names in this collection will be returned
IOException
public static ByteBuffer positionAtRowHeader(TableImpl.RowState rowState,
RowIdImpl rowId)
throws IOException
IOException
public 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.
iterator in interface Tableiterator in interface Iterable<Row>
protected static void writeTableDefinition(TableCreator creator)
throws IOException
IOException
protected ColumnImpl mutateAddColumn(TableUpdater mutator)
throws IOException
IOException
protected IndexData mutateAddIndexData(TableUpdater mutator)
throws IOException
IOException
protected IndexImpl mutateAddIndex(TableUpdater mutator)
throws IOException
IOExceptionpublic Object[] asRow(Map<String,?> rowMap)
TableTable.addRow(Object...).
asRow in interface Tablepublic 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)
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) 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.
IOException
public <M extends Map<String,Object>> M addRowFromMap(M row)
throws IOException
TableTable.asRow(java.util.Map) 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 TableIOException
public 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 arrays
public <M extends Map<String,Object>> List<M> addRowsFromMaps(List<M> rows)
throws IOException
TableTable.asRow(java.util.Map) 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 TableIOException
public Row updateRow(Row row)
throws IOException
Table
updateRow in interface TableIOException
public Object[] updateRow(RowId rowId,
Object... row)
throws IOException
IllegalStateException - if the given row is not valid, or deleted.
IOException
public void updateValue(Column column,
RowId rowId,
Object value)
throws IOException
IllegalStateException - if the given row is not valid, or deleted.
IOException
public <M extends Map<String,Object>> M updateRowFromMap(TableImpl.RowState rowState,
RowIdImpl rowId,
M row)
throws IOException
IOException
public Object[] updateRow(TableImpl.RowState rowState,
RowIdImpl rowId,
Object... row)
throws IOException
IOException
protected ByteBuffer createRow(Object[] rowArray,
ByteBuffer buffer)
throws IOException
IOExceptionpublic int getRowCount()
getRowCount in interface Tablepublic String toString()
toString in class Object
public String display()
throws IOException
IOException
public String display(long limit)
throws IOException
limit - Maximum number of rows to display
IOException
public 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)
throws IOException
true if a row of the given size will fit on the given
data page, false otherwise.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||