Package org.tmatesoft.sqljet.core.table
Interface ISqlJetCursor
-
- All Known Implementing Classes:
SqlJetCursor
,SqlJetIndexOrderCursor
,SqlJetIndexScopeCursor
,SqlJetReverseOrderCursor
,SqlJetRowNumCursor
,SqlJetTableDataCursor
public interface ISqlJetCursor
This class represents table cursor that may be used to browse over records in the table, to modify or delete existing records.- Author:
- TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes the cursor.void
delete()
Deletes the current record.boolean
eof()
Tests whether this cursor is positioned behind the last record.boolean
first()
Goes to the first record.byte[]
getBlobAsArray(int field)
Returns specified field's value as BLOB.byte[]
getBlobAsArray(java.lang.String fieldName)
Returns specified field's value as BLOB.java.io.InputStream
getBlobAsStream(int field)
Returns specified field's value as BLOB.java.io.InputStream
getBlobAsStream(java.lang.String fieldName)
Returns specified field's value as BLOB.boolean
getBoolean(int field)
Returns specified field's value as boolean.boolean
getBoolean(java.lang.String fieldName)
Returns specified field's value as boolean.int
getFieldsCount()
Returns number of fields in the current record.SqlJetValueType
getFieldType(int field)
Returns field type.SqlJetValueType
getFieldType(java.lang.String fieldName)
Returns field type.double
getFloat(int field)
Returns specified field's value as float.double
getFloat(java.lang.String fieldName)
Returns specified field's value as float.long
getInteger(int field)
Returns specified field's value as integer.long
getInteger(java.lang.String fieldName)
Returns specified field's value as integer.long
getLimit()
Returns limit of this cursor.long
getRowCount()
Returns number of rows accessible with this cursor.long
getRowId()
Gets row Id of the current record.long
getRowIndex()
Returns index of the current row.java.lang.Object[]
getRowValues()
Returns all field values of current row.java.lang.String
getString(int field)
Returns specified field's value as String.java.lang.String
getString(java.lang.String fieldName)
Returns specified field's value as String.java.lang.Object
getValue(int field)
Returns value of the field of the specified index in the current row.java.lang.Object
getValue(java.lang.String fieldName)
Returns value of the field with the specified name in the current row.boolean
goTo(long rowId)
Goes to the record with the specified row Id.boolean
goToRow(long rowIndex)
Goes to the row with the specified index.boolean
isNull(int field)
Tests field value for null.boolean
isNull(java.lang.String fieldName)
Tests field value for null.boolean
last()
Goes to the last record.boolean
next()
Goes to the next record.boolean
previous()
Goes to the previous record.ISqlJetCursor
reverse()
Returns cursor with the order reversed.void
setLimit(long limit)
Sets limit for this cursor.void
update(java.lang.Object... values)
Updates the current record.void
updateByFieldNames(java.util.Map<java.lang.String,java.lang.Object> values)
Updates the current record.void
updateByFieldNamesOr(SqlJetConflictAction onConflict, java.util.Map<java.lang.String,java.lang.Object> values)
Updates the current record.void
updateOr(SqlJetConflictAction onConflict, java.lang.Object... values)
Updates the current record.long
updateWithRowId(long rowId, java.lang.Object... values)
Updates rowId and values in the current record.long
updateWithRowIdOr(SqlJetConflictAction onConflict, long rowId, java.lang.Object... values)
Updates rowId and values in the current record.
-
-
-
Method Detail
-
close
void close() throws SqlJetException
Closes the cursor.- Throws:
SqlJetException
-
getRowId
long getRowId() throws SqlJetException
Gets row Id of the current record.- Returns:
- row Id of the current record.
- Throws:
SqlJetException
-
goTo
boolean goTo(long rowId) throws SqlJetException
Goes to the record with the specified row Id.- Parameters:
rowId
- row Id- Returns:
- true if cursor was moved successfully.
- Throws:
SqlJetException
-
eof
boolean eof() throws SqlJetException
Tests whether this cursor is positioned behind the last record.- Returns:
- true if the cursor is not on a record and fields can't be read.
- Throws:
SqlJetException
-
first
boolean first() throws SqlJetException
Goes to the first record.- Returns:
- true if there is at least one record.
- Throws:
SqlJetException
-
last
boolean last() throws SqlJetException
Goes to the last record.- Returns:
- true if there is at least one record.
- Throws:
SqlJetException
-
next
boolean next() throws SqlJetException
Goes to the next record.- Returns:
- true if there is at least one record and end of cursor is not reached yet
- Throws:
SqlJetException
-
previous
boolean previous() throws SqlJetException
Goes to the previous record.- Returns:
- true if there is at least one record and begin of cursor is not reached yet
- Throws:
SqlJetException
-
getFieldsCount
int getFieldsCount() throws SqlJetException
Returns number of fields in the current record.- Throws:
SqlJetException
-
getFieldType
SqlJetValueType getFieldType(int field) throws SqlJetException
Returns field type.- Parameters:
field
- index of the field- Returns:
- type of field
- Throws:
SqlJetException
-
getFieldType
SqlJetValueType getFieldType(java.lang.String fieldName) throws SqlJetException
Returns field type.- Parameters:
fieldName
- name of the field- Returns:
- type of field
- Throws:
SqlJetException
-
isNull
boolean isNull(int field) throws SqlJetException
Tests field value for null.- Parameters:
field
- number of field begin from zero- Returns:
- true if field value is null
- Throws:
SqlJetException
-
isNull
boolean isNull(java.lang.String fieldName) throws SqlJetException
Tests field value for null.- Returns:
- true if field value is null
- Throws:
SqlJetException
-
getString
java.lang.String getString(int field) throws SqlJetException
Returns specified field's value as String.- Parameters:
field
- index of the field- Returns:
- field's value as string
- Throws:
SqlJetException
-
getString
java.lang.String getString(java.lang.String fieldName) throws SqlJetException
Returns specified field's value as String.- Parameters:
fieldName
- name of the field- Returns:
- field's value as string
- Throws:
SqlJetException
-
getInteger
long getInteger(int field) throws SqlJetException
Returns specified field's value as integer.- Parameters:
field
- index of the field- Returns:
- field's value as integer
- Throws:
SqlJetException
-
getInteger
long getInteger(java.lang.String fieldName) throws SqlJetException
Returns specified field's value as integer.- Parameters:
fieldName
- name of the field- Throws:
SqlJetException
-
getFloat
double getFloat(int field) throws SqlJetException
Returns specified field's value as float.- Parameters:
field
- index of the field- Returns:
- field's value as real
- Throws:
SqlJetException
-
getFloat
double getFloat(java.lang.String fieldName) throws SqlJetException
Returns specified field's value as float.- Parameters:
fieldName
- name of the field- Throws:
SqlJetException
-
getBoolean
boolean getBoolean(int field) throws SqlJetException
Returns specified field's value as boolean.- Parameters:
field
- index of the field- Returns:
- field value
- Throws:
SqlJetException
-
getBoolean
boolean getBoolean(java.lang.String fieldName) throws SqlJetException
Returns specified field's value as boolean.- Parameters:
fieldName
- name of the field- Returns:
- field value
- Throws:
SqlJetException
-
getBlobAsArray
byte[] getBlobAsArray(int field) throws SqlJetException
Returns specified field's value as BLOB.- Parameters:
field
- index of the field- Returns:
- field's value as BLOB
- Throws:
SqlJetException
-
getBlobAsArray
byte[] getBlobAsArray(java.lang.String fieldName) throws SqlJetException
Returns specified field's value as BLOB.- Parameters:
fieldName
- name of the field- Returns:
- field's value as BLOB
- Throws:
SqlJetException
-
getBlobAsStream
java.io.InputStream getBlobAsStream(int field) throws SqlJetException
Returns specified field's value as BLOB.- Parameters:
field
- number of field begin from zero- Returns:
- field's value as BLOB
- Throws:
SqlJetException
-
getBlobAsStream
java.io.InputStream getBlobAsStream(java.lang.String fieldName) throws SqlJetException
Returns specified field's value as BLOB.- Parameters:
fieldName
- name of the field- Returns:
- field's value as BLOB
- Throws:
SqlJetException
-
getValue
java.lang.Object getValue(int field) throws SqlJetException
Returns value of the field of the specified index in the current row.- Parameters:
field
- index of the field- Throws:
SqlJetException
-
getValue
java.lang.Object getValue(java.lang.String fieldName) throws SqlJetException
Returns value of the field with the specified name in the current row.- Parameters:
fieldName
- name of the field- Throws:
SqlJetException
-
getRowValues
java.lang.Object[] getRowValues() throws SqlJetException
Returns all field values of current row.- Returns:
- field values array
- Throws:
SqlJetException
-
update
void update(java.lang.Object... values) throws SqlJetException
Updates the current record.- Parameters:
values
- New record values.- Throws:
SqlJetException
-
updateWithRowId
long updateWithRowId(long rowId, java.lang.Object... values) throws SqlJetException
Updates rowId and values in the current record.- Parameters:
values
- New record values.- Throws:
SqlJetException
-
updateByFieldNames
void updateByFieldNames(java.util.Map<java.lang.String,java.lang.Object> values) throws SqlJetException
Updates the current record.- Parameters:
values
- New record values mapped by field names.- Throws:
SqlJetException
-
updateOr
void updateOr(SqlJetConflictAction onConflict, java.lang.Object... values) throws SqlJetException
Updates the current record. Implements ON CONFLICT clause. SeeSqlJetConflictAction
.- Parameters:
onConflict
-SqlJetConflictAction
.values
- New record values.- Throws:
SqlJetException
-
updateWithRowIdOr
long updateWithRowIdOr(SqlJetConflictAction onConflict, long rowId, java.lang.Object... values) throws SqlJetException
Updates rowId and values in the current record. Implements ON CONFLICT clause. SeeSqlJetConflictAction
.- Parameters:
onConflict
-SqlJetConflictAction
.values
- New record values.- Throws:
SqlJetException
-
updateByFieldNamesOr
void updateByFieldNamesOr(SqlJetConflictAction onConflict, java.util.Map<java.lang.String,java.lang.Object> values) throws SqlJetException
Updates the current record. Implements ON CONFLICT clause. SeeSqlJetConflictAction
.- Parameters:
onConflict
-SqlJetConflictAction
.values
- New record values mapped by field names.- Throws:
SqlJetException
-
delete
void delete() throws SqlJetException
Deletes the current record.- Throws:
SqlJetException
-
reverse
ISqlJetCursor reverse() throws SqlJetException
Returns cursor with the order reversed.- Returns:
- cursor that will traverse the same rows as this one, but in reversed order.
- Throws:
SqlJetException
-
getRowCount
long getRowCount() throws SqlJetException
Returns number of rows accessible with this cursor.- Returns:
- number of rows
- Throws:
SqlJetException
-
getRowIndex
long getRowIndex() throws SqlJetException
Returns index of the current row. Index is 1-based, first record has index of one.- Returns:
- 1-based index of the current row.
- Throws:
SqlJetException
-
goToRow
boolean goToRow(long rowIndex) throws SqlJetException
Goes to the row with the specified index. Index is 1-based, first record has index of one.- Parameters:
rowIndex
-- Returns:
- true if cursor has been set on the specified record.
- Throws:
SqlJetException
-
setLimit
void setLimit(long limit) throws SqlJetException
Sets limit for this cursor. Negative or zero value resets limit to infinity.- Parameters:
limit
- limit to set or zero to drop the limit.- Throws:
SqlJetException
-
getLimit
long getLimit()
Returns limit of this cursor.- Returns:
- limit of this cursor or zero if limit has not been set.
-
-