APIdia Launch Partner
Top Description Inners Fields Constructors Methods
io.github.spannm.jackcess.impl

public abstract Class CursorImpl

extends Object
implements Cursor
Class Inheritance
All Implemented Interfaces
io.github.spannm.jackcess.Cursor, java.lang.Iterable
Known Direct Subclasses
io.github.spannm.jackcess.impl.IndexCursorImpl, io.github.spannm.jackcess.impl.TableScanCursor
Imports
io.github.spannm.jackcess.Column, .Cursor, .CursorBuilder, .JackcessRuntimeException, .Row, .RowId, io.github.spannm.jackcess.impl.TableImpl.RowState, io.github.spannm.jackcess.util.ColumnMatcher, .ErrorHandler, .IterableBuilder, .SimpleColumnMatcher, .ToStringBuilder, java.io.IOException, .UncheckedIOException, java.util.Arrays, .Collection, .Iterator, .Map, .NoSuchElementException, java.util.function.Predicate, java.util.logging.Level, .Logger

Manages iteration for a Table. Different cursors provide different methods of traversing a table. Cursors should be fairly robust in the face of table modification during traversal (although depending on how the table is traversed, row updates may or may not be seen). Multiple cursors may traverse the same table simultaneously.

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract class
CursorImpl.BaseIterator

Base implementation of iterator for this cursor, modifiable.

private class
CursorImpl.ColumnMatchIterator

Row iterator for this cursor, modifiable.

protected abstract static class
CursorImpl.DirHandler

Handles moving the cursor in a given direction.

protected static class
CursorImpl.IdImpl

Identifier for a cursor.

protected abstract static class
CursorImpl.PositionImpl

Value object which maintains the current position of the cursor.

private class
CursorImpl.RowIterator

Row iterator for this cursor, modifiable.

private class
CursorImpl.RowMatchIterator

Row iterator for this cursor, modifiable.

protected static class
CursorImpl.SavepointImpl

Value object which represents a complete save state of the cursor.

Field Summary

Modifier and TypeField and Description
private static final Logger
protected ColumnMatcher
mcolumnMatcher

ColumnMatcher to be used when matching column values

protected CursorImpl.PositionImpl
mcurPos

the current row

private final CursorImpl.PositionImpl
mfirstPos

the first (exclusive) row id for this cursor

private final CursorImpl.IdImpl
mid

identifier for this cursor

private final CursorImpl.PositionImpl
mlastPos

the last (exclusive) row id for this cursor

public static final boolean
MOVE_FORWARD

boolean value indicating forward movement

public static final boolean
MOVE_REVERSE

boolean value indicating reverse movement

protected CursorImpl.PositionImpl
mprevPos

the previous row

private final TableImpl.RowState
mrowState

State used for reading the table rows

private final TableImpl
mtable

owning table

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
afterLast()

Implements io.github.spannm.jackcess.Cursor.afterLast.

Resets this cursor for reverse traversal (sets cursor to after the last row).

public void
beforeFirst()

Implements io.github.spannm.jackcess.Cursor.beforeFirst.

Resets this cursor for forward traversal (sets cursor to before the first row).

public static CursorImpl
createCursor(TableImpl
the table over which this cursor will traverse
table
)

Creates a normal, un-indexed cursor for the given table.

public boolean
currentRowMatches(Column columnPattern, Object valuePattern)

Implements io.github.spannm.jackcess.Cursor.currentRowMatches.

Returns true if the current row matches the given pattern.

public boolean
currentRowMatches(ColumnImpl columnPattern, Object valuePattern)

public boolean
currentRowMatches(Map<String, ?> rowPattern)

Implements io.github.spannm.jackcess.Cursor.currentRowMatches.

Returns true if the current row matches the given pattern.

protected boolean
currentRowMatchesImpl(ColumnImpl columnPattern, Object valuePattern, ColumnMatcher columnMatcher)

protected boolean
currentRowMatchesImpl(Map<String, ?> rowPattern, ColumnMatcher columnMatcher)

protected final boolean
currentRowMatchesPattern(String columnPattern, Object valuePattern, ColumnMatcher columnMatcher, Object rowValue)

public void
protected abstract CursorImpl.PositionImpl
findAnotherPosition(TableImpl.RowState rowState, CursorImpl.PositionImpl curPos, boolean moveForward)

Finds the next non-deleted row after the given row (as defined by this cursor) and returns the id of the row, where "next" may be backwards if moveForward is false.

protected boolean
findAnotherRow(ColumnImpl columnPattern, Object valuePattern, boolean reset, boolean moveForward, ColumnMatcher columnMatcher, Object searchInfo)

protected boolean
findAnotherRow(Map<String, ?> rowPattern, boolean reset, boolean moveForward, ColumnMatcher columnMatcher, Object searchInfo)

protected boolean

Returns:

true if a valid row was found with the given value, false if no row was found
findAnotherRowImpl
(ColumnImpl
column from the table for this cursor which is being matched by the valuePattern
columnPattern
,
Object
value which is equal to the corresponding value in the matched row
valuePattern
,
boolean moveForward, ColumnMatcher columnMatcher, Object searchInfo)

Moves to the next row (as defined by the cursor) where the given column has the given value.

protected boolean

Returns:

true if a valid row was found with the given values, false if no row was found
findAnotherRowImpl
(Map<String, ?>
column names and values which must be equal to the corresponding values in the matched row
rowPattern
,
boolean moveForward, ColumnMatcher columnMatcher, Object searchInfo)

Moves to the next row (as defined by the cursor) where the given columns have the given values.

public boolean
findFirstRow(Column columnPattern, Object valuePattern)

Implements io.github.spannm.jackcess.Cursor.findFirstRow.

Moves to the first row (as defined by the cursor) where the given column has the given value.

public boolean
findFirstRow(ColumnImpl columnPattern, Object valuePattern)

public boolean
findFirstRow(Map<String, ?> rowPattern)

Implements io.github.spannm.jackcess.Cursor.findFirstRow.

Moves to the first row (as defined by the cursor) where the given columns have the given values.

public boolean
findNextRow(Column columnPattern, Object valuePattern)

Implements io.github.spannm.jackcess.Cursor.findNextRow.

Moves to the next row (as defined by the cursor) where the given column has the given value.

public boolean
findNextRow(ColumnImpl columnPattern, Object valuePattern)

public boolean
findNextRow(Map<String, ?> rowPattern)

Implements io.github.spannm.jackcess.Cursor.findNextRow.

Moves to the next row (as defined by the cursor) where the given columns have the given values.

public boolean
findRow(RowId rowId)

Implements io.github.spannm.jackcess.Cursor.findRow.

Moves to the row with the given rowId.

private Row

Returns:

another row in this table (Column name -> Column value), where "next" may be backwards if moveForward is false, or null if there is not another row in the given direction.
getAnotherRow
(Collection<String>
Only column names in this collection will be returned
columnNames
,
boolean moveForward)

Moves to another row in the table based on the given direction and returns it.

public ColumnMatcher
getColumnMatcher()

Implements io.github.spannm.jackcess.Cursor.getColumnMatcher.

Returns the currently configured ColumnMatcher, always non-null.

public Row
getCurrentRow()

Implements io.github.spannm.jackcess.Cursor.getCurrentRow.

Returns the current row in this cursor (Column name -> Column value).

public Row
getCurrentRow(Collection<String> columnNames)

Implements io.github.spannm.jackcess.Cursor.getCurrentRow.

Returns the current row in this cursor (Column name -> Column value).

public Object
getCurrentRowValue(Column column)

Implements io.github.spannm.jackcess.Cursor.getCurrentRowValue.

Returns the given column from the current row.

public Object
protected ColumnMatcher
getDefaultColumnMatcher()

Returns the default ColumnMatcher for this Cursor.

protected abstract CursorImpl.DirHandler
getDirHandler(boolean moveForward)

Returns the DirHandler for the given movement direction.

public ErrorHandler
getErrorHandler()

Implements io.github.spannm.jackcess.Cursor.getErrorHandler.

Gets the currently configured ErrorHandler (always non-null).

protected CursorImpl.PositionImpl
getFirstPosition()

Returns the first row id (exclusive) as defined by this cursor.

public JetFormat
public CursorImpl.IdImpl
getId()

Implements io.github.spannm.jackcess.Cursor.getId.

Returns the unique identifier of this cursor, usable for validating a Savepoint.

protected CursorImpl.PositionImpl
getLastPosition()

Returns the last row id (exclusive) as defined by this cursor.

public Row
getNextRow()

Implements io.github.spannm.jackcess.Cursor.getNextRow.

Moves to the next row in the table and returns it.

public Row
getNextRow(Collection<String> columnNames)

Implements io.github.spannm.jackcess.Cursor.getNextRow.

Moves to the next row in the table and returns it.

public PageChannel
public Row
getPreviousRow()

Implements io.github.spannm.jackcess.Cursor.getPreviousRow.

Moves to the previous row in the table and returns it.

public Row
getPreviousRow(Collection<String> columnNames)

Implements io.github.spannm.jackcess.Cursor.getPreviousRow.

Moves to the previous row in the table and returns it.

protected abstract CursorImpl.PositionImpl
getRowPosition(RowIdImpl rowId)

Returns the appropriate position information for the given row (which is the current row and is valid).

public TableImpl.RowState
public CursorImpl.SavepointImpl
getSavepoint()

Implements io.github.spannm.jackcess.Cursor.getSavepoint.

Returns the current state of the cursor which can be restored at a future point in time by a call to restoreSavepoint.

public TableImpl
getTable()

Implements io.github.spannm.jackcess.Cursor.getTable.

Returns the table over which this cursor iterates.

public boolean
isAfterLast()

Implements io.github.spannm.jackcess.Cursor.isAfterLast.

Returns true if the cursor is currently positioned after the last row, false otherwise.

protected boolean
isAtBeginning(boolean moveForward)

public boolean
isBeforeFirst()

Implements io.github.spannm.jackcess.Cursor.isBeforeFirst.

Returns true if the cursor is currently positioned before the first row, false otherwise.

public boolean
isCurrentRowDeleted()

Implements io.github.spannm.jackcess.Cursor.isCurrentRowDeleted.

Returns true if the row at which the cursor is currently positioned is deleted, false otherwise (including invalid rows).

protected boolean
isCurrentRowValid()

Returns true of the current row is valid, false otherwise.

protected boolean
isUpToDate()

Returns true if this cursor is up-to-date with respect to the relevant table and related table objects, false otherwise.

public Iterator<Row>
iterator()

Implements io.github.spannm.jackcess.Cursor.iterator.

Calls beforeFirst on this cursor and returns a modifiable Iterator which will iterate through all the rows of this table.

public Iterator<Row>
protected boolean
keepSearching(ColumnMatcher columnMatcher, Object searchInfo)

Called by findAnotherRowImpl to determine if the search should continue after finding a row which does not match the current pattern.

public int
moveNextRows(int numRows)

Implements io.github.spannm.jackcess.Cursor.moveNextRows.

Moves forward as many rows as possible up to the given number of rows.

public int
movePreviousRows(int numRows)

Implements io.github.spannm.jackcess.Cursor.movePreviousRows.

Moves backward as many rows as possible up to the given number of rows.

private int

Returns:

the number of rows moved.
moveSomeRows
(int numRows, boolean moveForward)

Moves as many rows as possible in the given direction up to the given number of rows.

protected boolean

Returns:

true if another valid row was found in the given direction, false otherwise
moveToAnotherRow
(boolean moveForward)

Moves to another row in the given direction as defined by this cursor.

private boolean
moveToAnotherRowImpl(boolean moveForward)

Does the grunt work of moving the cursor to another position in the given direction.

public boolean
moveToNextRow()

Implements io.github.spannm.jackcess.Cursor.moveToNextRow.

Moves to the next row as defined by this cursor.

public boolean
moveToPreviousRow()

Implements io.github.spannm.jackcess.Cursor.moveToPreviousRow.

Moves to the previous row as defined by this cursor.

public IterableBuilder
newIterable()

Implements io.github.spannm.jackcess.Cursor.newIterable.

Convenience method for constructing a new IterableBuilder for this cursor.

protected Object
prepareSearchInfo(ColumnImpl columnPattern, Object valuePattern)

Called before a search commences to allow for search specific data to be generated (which is cached for re-use by the iterators).

protected Object
prepareSearchInfo(Map<String, ?> rowPattern)

Called before a search commences to allow for search specific data to be generated (which is cached for re-use by the iterators).

private boolean

Returns:

true if the cursor ended up in a new position, false otherwise.
recheckPosition
(boolean moveForward)

Rechecks the current position if the underlying data structures have been modified.

public void
reset()

Implements io.github.spannm.jackcess.Cursor.reset.

Resets this cursor for forward traversal.

protected void
reset(boolean moveForward)

Resets this cursor for traversing the given direction.

protected void
restorePosition(CursorImpl.PositionImpl curPos)

Restores a current position for the cursor (current position becomes previous position).

protected final void
restorePosition(CursorImpl.PositionImpl curPos, CursorImpl.PositionImpl prevPos)

Restores a current and previous position for the cursor if the given positions are different from the current positions.

protected void
restorePositionImpl(CursorImpl.PositionImpl curPos, CursorImpl.PositionImpl prevPos)

Restores a current and previous position for the cursor.

public void
restoreSavepoint(Cursor.Savepoint savepoint)

Implements io.github.spannm.jackcess.Cursor.restoreSavepoint.

Moves the cursor to a savepoint previously returned from getSavepoint.

public void
public void
setColumnMatcher(ColumnMatcher columnMatcher)

Implements io.github.spannm.jackcess.Cursor.setColumnMatcher.

Sets a new ColumnMatcher.

public void
setCurrentRowValue(Column column, Object value)

Implements io.github.spannm.jackcess.Cursor.setCurrentRowValue.

Updates a single value in the current row.

public void
public void
setErrorHandler(ErrorHandler newErrorHandler)

Implements io.github.spannm.jackcess.Cursor.setErrorHandler.

Sets a new ErrorHandler.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Object[]
public <M extends Map<String, Object>> M
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait