public abstract class CursorImpl extends Object implements Cursor
The Cursor provides a variety of static utility methods to construct
cursors with given characteristics or easily search for specific values.
For even friendlier and more flexible construction, see
CursorBuilder
.
Is not thread-safe.
Cursor.Id, Cursor.Position, Cursor.Savepoint
Modifier and Type | Field and Description |
---|---|
static boolean |
MOVE_FORWARD
boolean value indicating forward movement
|
static boolean |
MOVE_REVERSE
boolean value indicating reverse movement
|
Modifier and Type | Method and Description |
---|---|
void |
afterLast()
Resets this cursor for reverse traversal (sets cursor to after the last
row).
|
void |
beforeFirst()
Resets this cursor for forward traversal (sets cursor to before the first
row).
|
static CursorImpl |
createCursor(TableImpl table)
Creates a normal, un-indexed cursor for the given table.
|
boolean |
currentRowMatches(ColumnImpl columnPattern,
Object valuePattern) |
boolean |
currentRowMatches(Column columnPattern,
Object valuePattern)
Returns
true if the current row matches the given pattern. |
boolean |
currentRowMatches(Map<String,?> rowPattern)
Returns
true if the current row matches the given pattern. |
void |
deleteCurrentRow()
Delete the current row.
|
boolean |
findFirstRow(ColumnImpl columnPattern,
Object valuePattern) |
boolean |
findFirstRow(Column columnPattern,
Object valuePattern)
Moves to the first row (as defined by the cursor) where the given column
has the given value.
|
boolean |
findFirstRow(Map<String,?> rowPattern)
Moves to the first row (as defined by the cursor) where the given columns
have the given values.
|
boolean |
findNextRow(ColumnImpl columnPattern,
Object valuePattern) |
boolean |
findNextRow(Column columnPattern,
Object valuePattern)
Moves to the next row (as defined by the cursor) where the given column
has the given value.
|
boolean |
findNextRow(Map<String,?> rowPattern)
Moves to the next row (as defined by the cursor) where the given columns
have the given values.
|
boolean |
findRow(RowId rowId)
Moves to the row with the given rowId.
|
ColumnMatcher |
getColumnMatcher()
Returns the currently configured ColumnMatcher, always non-
null . |
Row |
getCurrentRow()
Returns the current row in this cursor (Column name -> Column value).
|
Row |
getCurrentRow(Collection<String> columnNames)
Returns the current row in this cursor (Column name -> Column value).
|
Object |
getCurrentRowValue(Column column)
Returns the given column from the current row.
|
Object |
getCurrentRowValue(ColumnImpl column) |
ErrorHandler |
getErrorHandler()
Gets the currently configured ErrorHandler (always non-
null ). |
JetFormat |
getFormat() |
com.healthmarketscience.jackcess.impl.CursorImpl.IdImpl |
getId() |
Row |
getNextRow()
Moves to the next row in the table and returns it.
|
Row |
getNextRow(Collection<String> columnNames)
Moves to the next row in the table and returns it.
|
PageChannel |
getPageChannel() |
Row |
getPreviousRow()
Moves to the previous row in the table and returns it.
|
Row |
getPreviousRow(Collection<String> columnNames)
Moves to the previous row in the table and returns it.
|
TableImpl.RowState |
getRowState() |
com.healthmarketscience.jackcess.impl.CursorImpl.SavepointImpl |
getSavepoint()
Returns the current state of the cursor which can be restored at a future
point in time by a call to
Cursor.restoreSavepoint(com.healthmarketscience.jackcess.Cursor.Savepoint) . |
TableImpl |
getTable() |
boolean |
isAfterLast()
Returns
true if the cursor is currently positioned after the
last row, false otherwise. |
boolean |
isBeforeFirst()
Returns
true if the cursor is currently positioned before the
first row, false otherwise. |
boolean |
isCurrentRowDeleted()
Returns
true if the row at which the cursor is currently
positioned is deleted, false otherwise (including invalid rows). |
Iterator<Row> |
iterator()
Calls
Cursor.beforeFirst() on this cursor and returns a modifiable
Iterator which will iterate through all the rows of this table. |
Iterator<Row> |
iterator(IterableBuilder iterBuilder) |
int |
moveNextRows(int numRows)
Moves forward as many rows as possible up to the given number of rows.
|
int |
movePreviousRows(int numRows)
Moves backward as many rows as possible up to the given number of rows.
|
boolean |
moveToNextRow()
Moves to the next row as defined by this cursor.
|
boolean |
moveToPreviousRow()
Moves to the previous row as defined by this cursor.
|
IterableBuilder |
newIterable()
Convenience method for constructing a new IterableBuilder for this
cursor.
|
void |
reset()
Resets this cursor for forward traversal.
|
void |
restoreSavepoint(Cursor.Savepoint savepoint)
Moves the cursor to a savepoint previously returned from
Cursor.getSavepoint() . |
void |
restoreSavepoint(com.healthmarketscience.jackcess.impl.CursorImpl.SavepointImpl savepoint) |
void |
setColumnMatcher(ColumnMatcher columnMatcher)
Sets a new ColumnMatcher.
|
void |
setCurrentRowValue(ColumnImpl column,
Object value) |
void |
setCurrentRowValue(Column column,
Object value)
Updates a single value in the current row.
|
void |
setErrorHandler(ErrorHandler newErrorHandler)
Sets a new ErrorHandler.
|
String |
toString() |
Object[] |
updateCurrentRow(Object... row)
Update the current row.
|
<M extends Map<String,Object>> |
updateCurrentRowFromMap(M row)
Update the current row.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static final boolean MOVE_FORWARD
public static final boolean MOVE_REVERSE
public static CursorImpl createCursor(TableImpl table)
table
- the table over which this cursor will traversepublic TableImpl.RowState getRowState()
public com.healthmarketscience.jackcess.impl.CursorImpl.IdImpl getId()
public JetFormat getFormat()
public PageChannel getPageChannel()
public ErrorHandler getErrorHandler()
Cursor
null
).
This will be used to handle all errors.getErrorHandler
in interface Cursor
public void setErrorHandler(ErrorHandler newErrorHandler)
Cursor
null
, resets to using the
ErrorHandler configured at the Table level.setErrorHandler
in interface Cursor
public ColumnMatcher getColumnMatcher()
Cursor
null
.getColumnMatcher
in interface Cursor
public void setColumnMatcher(ColumnMatcher columnMatcher)
Cursor
null
, resets to using the default
matcher (default depends on Cursor type).setColumnMatcher
in interface Cursor
public com.healthmarketscience.jackcess.impl.CursorImpl.SavepointImpl getSavepoint()
Cursor
Cursor.restoreSavepoint(com.healthmarketscience.jackcess.Cursor.Savepoint)
.
Savepoints may be used across different cursor instances for the same
table, but they must have the same Cursor.Id
.
getSavepoint
in interface Cursor
public void restoreSavepoint(Cursor.Savepoint savepoint) throws IOException
Cursor
Cursor.getSavepoint()
.restoreSavepoint
in interface Cursor
IOException
public void restoreSavepoint(com.healthmarketscience.jackcess.impl.CursorImpl.SavepointImpl savepoint) throws IOException
IOException
public void reset()
Cursor
Cursor.beforeFirst()
.public void beforeFirst()
Cursor
beforeFirst
in interface Cursor
public void afterLast()
Cursor
public boolean isBeforeFirst() throws IOException
Cursor
true
if the cursor is currently positioned before the
first row, false
otherwise.isBeforeFirst
in interface Cursor
IOException
public boolean isAfterLast() throws IOException
Cursor
true
if the cursor is currently positioned after the
last row, false
otherwise.isAfterLast
in interface Cursor
IOException
public boolean isCurrentRowDeleted() throws IOException
Cursor
true
if the row at which the cursor is currently
positioned is deleted, false
otherwise (including invalid rows).isCurrentRowDeleted
in interface Cursor
IOException
public Iterator<Row> iterator()
Cursor
Cursor.beforeFirst()
on this cursor 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
Cursor.getNextRow()
.
For more flexible iteration see Cursor.newIterable()
.
public IterableBuilder newIterable()
Cursor
newIterable
in interface Cursor
public Iterator<Row> iterator(IterableBuilder iterBuilder)
public void deleteCurrentRow() throws IOException
Cursor
Note, re-deleting an already deleted row is allowed (it does nothing).
deleteCurrentRow
in interface Cursor
IOException
public Object[] updateCurrentRow(Object... row) throws IOException
Cursor
updateCurrentRow
in interface Cursor
IOException
public <M extends Map<String,Object>> M updateCurrentRowFromMap(M row) throws IOException
Cursor
updateCurrentRowFromMap
in interface Cursor
IOException
public Row getNextRow() throws IOException
Cursor
getNextRow
in interface Cursor
null
if no next row is foundIOException
public Row getNextRow(Collection<String> columnNames) throws IOException
Cursor
getNextRow
in interface Cursor
columnNames
- Only column names in this collection will be returnednull
if no next row is foundIOException
public Row getPreviousRow() throws IOException
Cursor
getPreviousRow
in interface Cursor
null
if no previous row is foundIOException
public Row getPreviousRow(Collection<String> columnNames) throws IOException
Cursor
getPreviousRow
in interface Cursor
columnNames
- Only column names in this collection will be returnednull
if no previous row is foundIOException
public boolean moveToNextRow() throws IOException
Cursor
moveToNextRow
in interface Cursor
true
if a valid next row was found, false
otherwiseIOException
public boolean moveToPreviousRow() throws IOException
Cursor
moveToPreviousRow
in interface Cursor
true
if a valid previous row was found, false
otherwiseIOException
public boolean findRow(RowId rowId) throws IOException
Cursor
findRow
in interface Cursor
true
if a valid row was found with the given id,
false
if no row was foundIOException
public boolean findFirstRow(Column columnPattern, Object valuePattern) throws IOException
Cursor
Warning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches).
findFirstRow
in interface Cursor
columnPattern
- column from the table for this cursor which is being
matched by the valuePatternvaluePattern
- value which is equal to the corresponding value in
the matched row. If this object is an instance of
Predicate
, it will be
applied to the potential row value instead
(overriding any configured ColumnMatcher)true
if a valid row was found with the given value,
false
if no row was foundIOException
public boolean findFirstRow(ColumnImpl columnPattern, Object valuePattern) throws IOException
IOException
public boolean findNextRow(Column columnPattern, Object valuePattern) throws IOException
Cursor
findNextRow
in interface Cursor
columnPattern
- column from the table for this cursor which is being
matched by the valuePatternvaluePattern
- value which is equal to the corresponding value in
the matched row. If this object is an instance of
Predicate
, it will be
applied to the potential row value instead
(overriding any configured ColumnMatcher)true
if a valid row was found with the given value,
false
if no row was foundIOException
public boolean findNextRow(ColumnImpl columnPattern, Object valuePattern) throws IOException
IOException
public boolean findFirstRow(Map<String,?> rowPattern) throws IOException
Cursor
Warning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches).
findFirstRow
in interface Cursor
rowPattern
- column names and values which must be equal to the
corresponding values in the matched row. If a value is
an instance of Predicate
, it
will be applied to the potential row value instead
(overriding any configured ColumnMatcher)true
if a valid row was found with the given values,
false
if no row was foundIOException
public boolean findNextRow(Map<String,?> rowPattern) throws IOException
Cursor
findNextRow
in interface Cursor
rowPattern
- column names and values which must be equal to the
corresponding values in the matched row. If a value is
an instance of Predicate
, it
will be applied to the potential row value instead
(overriding any configured ColumnMatcher)true
if a valid row was found with the given values,
false
if no row was foundIOException
public boolean currentRowMatches(Column columnPattern, Object valuePattern) throws IOException
Cursor
true
if the current row matches the given pattern.currentRowMatches
in interface Cursor
columnPattern
- column from the table for this cursor which is being
matched by the valuePatternvaluePattern
- value which is equal to the corresponding value in
the matched row. If this object is an instance of
Predicate
, it will be
applied to the potential row value instead
(overriding any configured ColumnMatcher)IOException
public boolean currentRowMatches(ColumnImpl columnPattern, Object valuePattern) throws IOException
IOException
public boolean currentRowMatches(Map<String,?> rowPattern) throws IOException
Cursor
true
if the current row matches the given pattern.currentRowMatches
in interface Cursor
rowPattern
- column names and values which must be equal to the
corresponding values in the matched row. If a value is
an instance of Predicate
, it
will be applied to the potential row value instead
(overriding any configured ColumnMatcher)IOException
public int moveNextRows(int numRows) throws IOException
Cursor
moveNextRows
in interface Cursor
IOException
public int movePreviousRows(int numRows) throws IOException
Cursor
movePreviousRows
in interface Cursor
IOException
public Row getCurrentRow() throws IOException
Cursor
getCurrentRow
in interface Cursor
IOException
public Row getCurrentRow(Collection<String> columnNames) throws IOException
Cursor
getCurrentRow
in interface Cursor
columnNames
- Only column names in this collection will be returnedIOException
public Object getCurrentRowValue(Column column) throws IOException
Cursor
getCurrentRowValue
in interface Cursor
IOException
public Object getCurrentRowValue(ColumnImpl column) throws IOException
IOException
public void setCurrentRowValue(Column column, Object value) throws IOException
Cursor
setCurrentRowValue
in interface Cursor
IOException
public void setCurrentRowValue(ColumnImpl column, Object value) throws IOException
IOException
Copyright © 2005–2024 OpenHMS. All rights reserved.