Class SqlJetTable
- All Implemented Interfaces:
ISqlJetTable
ISqlJetTable
.-
Constructor Summary
ConstructorsConstructorDescriptionSqlJetTable
(SqlJetDb db, ISqlJetBtree btree, String tableName, boolean write) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear table.Get database connection.Get table's schema definition.getIndexDef
(String name) Get definition of index by name.Returns definitions of indices used in this table.Get table indexes names.Returns name of primary key index.long
Add new record to the table with specified values.long
insertByFieldNames
(Map<String, Object> values) Insert record by values by names of fields.long
insertByFieldNamesOr
(SqlJetConflictAction onConflict, Map<String, Object> values) Insert record by values by names of fields.long
insertOr
(SqlJetConflictAction onConflict, Object... values) Add new record to the table with specified values.long
insertWithRowId
(long rowId, Object... values) Inserts record at specified rowId.long
insertWithRowIdOr
(SqlJetConflictAction onConflict, long rowId, Object... values) Inserts record at specified rowId.Open cursor for records which have found by key on index.open()
Open cursor for all table records.Open cursors which sorts table by index.Open cursor which restricts table to some scope of index values.scope
(String indexName, SqlJetScope scope) Open cursor which restricts table to some scope of index values.
-
Constructor Details
-
SqlJetTable
public SqlJetTable(SqlJetDb db, ISqlJetBtree btree, String tableName, boolean write) throws SqlJetException - Throws:
SqlJetException
-
-
Method Details
-
getDataBase
Description copied from interface:ISqlJetTable
Get database connection.- Specified by:
getDataBase
in interfaceISqlJetTable
- Returns:
- the database connection.
-
getPrimaryKeyIndexName
Description copied from interface:ISqlJetTable
Returns 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:
getPrimaryKeyIndexName
in interfaceISqlJetTable
- Returns:
- the primaryKeyIndex name of index or null if table haven't primary key or have INTEGER PRIMARY KEY.
- Throws:
SqlJetException
-
getDefinition
Description copied from interface:ISqlJetTable
Get table's schema definition.- Specified by:
getDefinition
in interfaceISqlJetTable
- Throws:
SqlJetException
-
getIndexesDefs
Description copied from interface:ISqlJetTable
Returns definitions of indices used in this table.- Specified by:
getIndexesDefs
in interfaceISqlJetTable
- Returns:
- definitions of indices used in this table.
- Throws:
SqlJetException
-
getIndexesNames
Description copied from interface:ISqlJetTable
Get table indexes names.- Specified by:
getIndexesNames
in interfaceISqlJetTable
- Returns:
- names of table indexes.
- Throws:
SqlJetException
-
getIndexDef
Description copied from interface:ISqlJetTable
Get definition of index by name.- Specified by:
getIndexDef
in interfaceISqlJetTable
- Parameters:
name
- name of index.- Returns:
- definition of index.
- Throws:
SqlJetException
-
open
Description copied from interface:ISqlJetTable
Open cursor for all table records.
Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.
- Specified by:
open
in interfaceISqlJetTable
- Returns:
- cursor for all table records.
- Throws:
SqlJetException
-
lookup
Description copied from interface:ISqlJetTable
Open 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:
lookup
in 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
Description copied from interface:ISqlJetTable
Add 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:
insert
in interfaceISqlJetTable
- Parameters:
values
- Values for the new record.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
insertByFieldNames
Description copied from interface:ISqlJetTable
Insert 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:
insertByFieldNames
in interfaceISqlJetTable
- Parameters:
values
- map of field names with values.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
insertWithRowId
Description copied from interface:ISqlJetTable
Inserts 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:
insertWithRowId
in interfaceISqlJetTable
- Parameters:
rowId
- ROWID of record.values
- Values for the new record.- Throws:
SqlJetException
-
insertOr
Description copied from interface:ISqlJetTable
Add 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:
insertOr
in interfaceISqlJetTable
- Parameters:
onConflict
-SqlJetConflictAction
.values
- Values for the new record.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
insertByFieldNamesOr
public long insertByFieldNamesOr(SqlJetConflictAction onConflict, Map<String, Object> values) throws SqlJetExceptionDescription copied from interface:ISqlJetTable
Insert 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:
insertByFieldNamesOr
in 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, Object... values) throws SqlJetException Description copied from interface:ISqlJetTable
Inserts 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:
insertWithRowIdOr
in interfaceISqlJetTable
- Parameters:
onConflict
-SqlJetConflictAction
.rowId
- ROWID of record.values
- Values for the new record.- Returns:
- ROWID of inserted record.
- Throws:
SqlJetException
-
order
Description copied from interface:ISqlJetTable
Open 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:
order
in 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(String indexName, Object[] firstKey, Object[] lastKey) throws SqlJetException Description copied from interface:ISqlJetTable
Open 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:
scope
in 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
Description copied from interface:ISqlJetTable
Open 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:
scope
in 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
Description copied from interface:ISqlJetTable
Clear table. It fast delete of all rows in table.- Specified by:
clear
in interfaceISqlJetTable
- Throws:
SqlJetException
-