Class SqlJetTable
- java.lang.Object
-
- org.tmatesoft.sqljet.core.internal.table.SqlJetTable
-
- All Implemented Interfaces:
ISqlJetTable
public class SqlJetTable extends java.lang.Object implements ISqlJetTable
Implementation ofISqlJetTable.
-
-
Constructor Summary
Constructors Constructor Description SqlJetTable(SqlJetDb db, ISqlJetBtree btree, java.lang.String tableName, boolean write)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear table.SqlJetDbgetDataBase()Get database connection.ISqlJetTableDefgetDefinition()Get table's schema definition.ISqlJetIndexDefgetIndexDef(java.lang.String name)Get definition of index by name.java.util.Set<ISqlJetIndexDef>getIndexesDefs()Returns definitions of indices used in this table.java.util.Set<java.lang.String>getIndexesNames()Get table indexes names.java.lang.StringgetPrimaryKeyIndexName()Returns name of primary key index.longinsert(java.lang.Object... values)Add new record to the table with specified values.longinsertByFieldNames(java.util.Map<java.lang.String,java.lang.Object> values)Insert record by values by names of fields.longinsertByFieldNamesOr(SqlJetConflictAction onConflict, java.util.Map<java.lang.String,java.lang.Object> values)Insert record by values by names of fields.longinsertOr(SqlJetConflictAction onConflict, java.lang.Object... values)Add new record to the table with specified values.longinsertWithRowId(long rowId, java.lang.Object... values)Inserts record at specified rowId.longinsertWithRowIdOr(SqlJetConflictAction onConflict, long rowId, java.lang.Object... values)Inserts record at specified rowId.ISqlJetCursorlookup(java.lang.String indexName, java.lang.Object... key)Open cursor for records which have found by key on index.ISqlJetCursoropen()Open cursor for all table records.ISqlJetCursororder(java.lang.String indexName)Open cursors which sorts table by index.ISqlJetCursorscope(java.lang.String indexName, java.lang.Object[] firstKey, java.lang.Object[] lastKey)Open cursor which restricts table to some scope of index values.ISqlJetCursorscope(java.lang.String indexName, SqlJetScope scope)Open cursor which restricts table to some scope of index values.
-
-
-
Constructor Detail
-
SqlJetTable
public SqlJetTable(SqlJetDb db, ISqlJetBtree btree, java.lang.String tableName, boolean write) throws SqlJetException
- Throws:
SqlJetException
-
-
Method Detail
-
getDataBase
public SqlJetDb getDataBase()
Description copied from interface:ISqlJetTableGet database connection.- Specified by:
getDataBasein interfaceISqlJetTable- Returns:
- the database connection.
-
getPrimaryKeyIndexName
public java.lang.String getPrimaryKeyIndexName() throws SqlJetExceptionDescription copied from interface:ISqlJetTableReturns name of primary key index. For tables with INTEGER PRIMARY KEY and tables without primary key it returns null. This method could be used inISqlJetTable.lookup(String, Object...),ISqlJetTable.scope(String, Object[], Object[])orISqlJetTable.order(String)methods at first parameter.- Specified by:
getPrimaryKeyIndexNamein interfaceISqlJetTable- Returns:
- the primaryKeyIndex name of index or null if table haven't primary key or have INTEGER PRIMARY KEY.
- Throws:
SqlJetException
-
getDefinition
public ISqlJetTableDef getDefinition() throws SqlJetException
Description copied from interface:ISqlJetTableGet table's schema definition.- Specified by:
getDefinitionin interfaceISqlJetTable- Throws:
SqlJetException
-
getIndexesDefs
public java.util.Set<ISqlJetIndexDef> getIndexesDefs() throws SqlJetException
Description copied from interface:ISqlJetTableReturns definitions of indices used in this table.- Specified by:
getIndexesDefsin interfaceISqlJetTable- Returns:
- definitions of indices used in this table.
- Throws:
SqlJetException
-
getIndexesNames
public java.util.Set<java.lang.String> getIndexesNames() throws SqlJetExceptionDescription copied from interface:ISqlJetTableGet table indexes names.- Specified by:
getIndexesNamesin interfaceISqlJetTable- Returns:
- names of table indexes.
- Throws:
SqlJetException
-
getIndexDef
public ISqlJetIndexDef getIndexDef(java.lang.String name) throws SqlJetException
Description copied from interface:ISqlJetTableGet definition of index by name.- Specified by:
getIndexDefin interfaceISqlJetTable- Parameters:
name- name of index.- Returns:
- definition of index.
- Throws:
SqlJetException
-
open
public ISqlJetCursor open() throws SqlJetException
Description copied from interface:ISqlJetTableOpen cursor for all table records.
Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.
- Specified by:
openin interfaceISqlJetTable- Returns:
- cursor for all table records.
- Throws:
SqlJetException
-
lookup
public ISqlJetCursor lookup(java.lang.String indexName, java.lang.Object... key) throws SqlJetException
Description copied from interface:ISqlJetTableOpen cursor for records which have found by key on index.
If indexName is NULL then primary key will be used.
Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.
- Specified by:
lookupin interfaceISqlJetTable- Parameters:
indexName- Name of the searched index. If null then primary key will be used.key- Key for the index lookup.- Returns:
- cursor for records which have found by key on index.
- Throws:
SqlJetException
-
insert
public long insert(java.lang.Object... values) throws SqlJetExceptionDescription copied from interface:ISqlJetTableAdd new record to the table with specified values.
Values must be specified by position in table structure. If table have INTEGER PRIMARY KEY column then this column could be null and in this case it value will be defined automatically.
If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.
All relevant indexes are updated automatically.
Returns ROWID of inserted record.
Can be used without of active transaction, in this case method begins and ends own internal transaction.
- Specified by:
insertin interfaceISqlJetTable- Parameters:
values- Values for the new record.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
insertByFieldNames
public long insertByFieldNames(java.util.Map<java.lang.String,java.lang.Object> values) throws SqlJetExceptionDescription copied from interface:ISqlJetTableInsert record by values by names of fields.
If table have INTEGER PRIMARY KEY column then this column could be null or even not specified and in this case it value will be defined automatically.
The ROWID of record could be passed by any of this names: ROWID, _ROWID_, OID. ROWID could be specified even if table haven't INTEGER PRIMARY KEY column.
All relevant indexes are updated automatically.
Returns ROWID of inserted record.
Can be used without of active transaction, in this case method begins and ends own internal transaction.
- Specified by:
insertByFieldNamesin interfaceISqlJetTable- Parameters:
values- map of field names with values.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
insertWithRowId
public long insertWithRowId(long rowId, java.lang.Object... values) throws SqlJetExceptionDescription copied from interface:ISqlJetTableInserts record at specified rowId. If rowId is 0 then it generates new rowId.
If table has INTEGER PRIMARY KEY column and rowId isn't 0 then value for this field will be ignored and could be specified just as null. If table has INTEGER PRIMARY KEY column and rowId is 0 then value for this field used as rowId.
If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.
All relevant indexes are updated automatically.
Returns ROWID of inserted record.
Can be used without of active transaction, in this case method begins and ends own internal transaction.
- Specified by:
insertWithRowIdin interfaceISqlJetTable- Parameters:
rowId- ROWID of record.values- Values for the new record.- Throws:
SqlJetException
-
insertOr
public long insertOr(SqlJetConflictAction onConflict, java.lang.Object... values) throws SqlJetException
Description copied from interface:ISqlJetTableAdd new record to the table with specified values.
Values must be specified by position in table structure.
If table have INTEGER PRIMARY KEY column then this column could be null and in this case it value will be defined automatically.
If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.
All relevant indexes are updated automatically.
Returns ROWID of inserted record.
Can be used without of active transaction, in this case method begins and ends own internal transaction.
Implements ON CONFLICT clause. See
SqlJetConflictAction.- Specified by:
insertOrin interfaceISqlJetTable- Parameters:
onConflict-SqlJetConflictAction.values- Values for the new record.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
insertByFieldNamesOr
public long insertByFieldNamesOr(SqlJetConflictAction onConflict, java.util.Map<java.lang.String,java.lang.Object> values) throws SqlJetException
Description copied from interface:ISqlJetTableInsert record by values by names of fields.
If table have INTEGER PRIMARY KEY column then this column could be null or even not specified and in this case it value will be defined automatically.
The ROWID of record could be passed by any of this names: ROWID, _ROWID_, OID. ROWID could be specified even if table haven't INTEGER PRIMARY KEY column.
All relevant indexes are updated automatically.
Returns ROWID of inserted record.
Can be used without of active transaction, in this case method begins and ends own internal transaction.
Implements ON CONFLICT clause. See
SqlJetConflictAction.- Specified by:
insertByFieldNamesOrin interfaceISqlJetTable- Parameters:
onConflict-SqlJetConflictAction.values- Values for the new record.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
insertWithRowIdOr
public long insertWithRowIdOr(SqlJetConflictAction onConflict, long rowId, java.lang.Object... values) throws SqlJetException
Description copied from interface:ISqlJetTableInserts record at specified rowId.
If rowId is 0 then it generates new rowId.
If table has INTEGER PRIMARY KEY column and rowId isn't 0 then value for this field will be ignored and could be specified just as null. If table has INTEGER PRIMARY KEY column and rowId is 0 then value for this field used as rowId.
If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.
All relevant indexes are updated automatically.
Returns ROWID of inserted record.
Can be used without of active transaction, in this case method begins and ends own internal transaction.
Implements ON CONFLICT clause. See
SqlJetConflictAction.- Specified by:
insertWithRowIdOrin interfaceISqlJetTable- Parameters:
onConflict-SqlJetConflictAction.rowId- ROWID of record.values- Values for the new record.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
order
public ISqlJetCursor order(java.lang.String indexName) throws SqlJetException
Description copied from interface:ISqlJetTableOpen cursors which sorts table by index.
If indexName is NULL then primary key will be used.
Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.
- Specified by:
orderin interfaceISqlJetTable- Parameters:
indexName- name of index which defines ordering.If null then primary key will be used.- Returns:
- cursor sorted by index.
- Throws:
SqlJetException
-
scope
public ISqlJetCursor scope(java.lang.String indexName, java.lang.Object[] firstKey, java.lang.Object[] lastKey) throws SqlJetException
Description copied from interface:ISqlJetTableOpen cursor which restricts table to some scope of index values.
Scope is specified as pair of index keys. First key means start of scope and last key means end of scope. One of these keys (or even both) could be NULL. In this case scope is open from one side (or both sides). If first key is less of last key then cursor will be in reversed order. If indexName is NULL then primary key will be used.
Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.
- Specified by:
scopein interfaceISqlJetTable- Parameters:
indexName- Name of the searched index. If null then primary key will be used.firstKey- first key of scope. Could be NULL.lastKey- first key of scope. Could be NULL.- Returns:
- cursor which have defined scope of rows.
- Throws:
SqlJetException
-
scope
public ISqlJetCursor scope(java.lang.String indexName, SqlJetScope scope) throws SqlJetException
Description copied from interface:ISqlJetTableOpen cursor which restricts table to some scope of index values.
Scope is specified as pair of index keys. First key means start of scope and last key means end of scope. One of these keys (or even both) could be NULL. In this case scope is open from one side (or both sides). If first key is less of last key then cursor will be in reversed order. If indexName is NULL then primary key will be used.
Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.
- Specified by:
scopein interfaceISqlJetTable- Parameters:
indexName- Name of the searched index. If null then primary key will be used.scope- structure that contains both left and right bounds of the requested scope.- Returns:
- cursor which have defined scope of rows.
- Throws:
SqlJetException
-
clear
public void clear() throws SqlJetExceptionDescription copied from interface:ISqlJetTableClear table. It fast delete of all rows in table.- Specified by:
clearin interfaceISqlJetTable- Throws:
SqlJetException
-
-