com.healthmarketscience.jackcess.impl
Class CursorImpl

java.lang.Object
  extended by com.healthmarketscience.jackcess.impl.CursorImpl
All Implemented Interfaces:
Cursor, Iterable<Row>
Direct Known Subclasses:
IndexCursorImpl, TableScanCursor

public abstract class CursorImpl
extends Object
implements Cursor

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.

Author:
James Ahlborn

Nested Class Summary
protected  class CursorImpl.BaseIterator
          Base implementation of iterator for this cursor, modifiable.
protected  class CursorImpl.DirHandler
          Handles moving the cursor in a given direction.
protected static class CursorImpl.IdImpl
          Identifier for a cursor.
protected static class CursorImpl.PositionImpl
          Value object which maintains the current position of the cursor.
protected static class CursorImpl.SavepointImpl
          Value object which represents a complete save state of the cursor.
 
Nested classes/interfaces inherited from interface com.healthmarketscience.jackcess.Cursor
Cursor.Id, Cursor.Position, Cursor.Savepoint
 
Field Summary
protected  ColumnMatcher _columnMatcher
          ColumnMatcher to be used when matching column values
protected  CursorImpl.PositionImpl _curPos
          the current row
protected  CursorImpl.PositionImpl _prevPos
          the previous row
static boolean MOVE_FORWARD
          boolean value indicating forward movement
static boolean MOVE_REVERSE
          boolean value indicating reverse movement
 
Constructor Summary
protected CursorImpl(CursorImpl.IdImpl id, TableImpl table, CursorImpl.PositionImpl firstPos, CursorImpl.PositionImpl lastPos)
           
 
Method Summary
 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.
protected  boolean currentRowMatchesImpl(ColumnImpl columnPattern, Object valuePattern, ColumnMatcher columnMatcher)
           
protected  boolean currentRowMatchesImpl(Map<String,?> rowPattern, ColumnMatcher columnMatcher)
           
 void deleteCurrentRow()
          Delete the current row.
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 findAnotherRowImpl(ColumnImpl columnPattern, Object 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 findAnotherRowImpl(Map<String,?> 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.
 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)
           
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.
 ErrorHandler getErrorHandler()
          Gets the currently configured ErrorHandler (always non-null).
protected  CursorImpl.PositionImpl getFirstPosition()
          Returns the first row id (exclusive) as defined by this cursor.
 JetFormat getFormat()
           
 CursorImpl.IdImpl getId()
           
protected  CursorImpl.PositionImpl getLastPosition()
          Returns the last row id (exclusive) as defined by this cursor.
 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.
protected abstract  CursorImpl.PositionImpl getRowPosition(RowIdImpl rowId)
          Returns the appropriate position information for the given row (which is the current row and is valid).
 TableImpl.RowState getRowState()
           
 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.
protected  boolean isAtBeginning(boolean moveForward)
           
 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).
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.
 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)
           
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.
 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.
protected  boolean moveToAnotherRow(boolean moveForward)
          Moves to another row in the given direction as defined by this cursor.
 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.
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).
 void 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  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.
 void restoreSavepoint(Cursor.Savepoint savepoint)
          Moves the cursor to a savepoint previously returned from Cursor.getSavepoint().
 void restoreSavepoint(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>>
M
updateCurrentRowFromMap(M row)
          Update the current row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MOVE_FORWARD

public static final boolean MOVE_FORWARD
boolean value indicating forward movement

See Also:
Constant Field Values

MOVE_REVERSE

public static final boolean MOVE_REVERSE
boolean value indicating reverse movement

See Also:
Constant Field Values

_prevPos

protected CursorImpl.PositionImpl _prevPos
the previous row


_curPos

protected CursorImpl.PositionImpl _curPos
the current row


_columnMatcher

protected ColumnMatcher _columnMatcher
ColumnMatcher to be used when matching column values

Constructor Detail

CursorImpl

protected CursorImpl(CursorImpl.IdImpl id,
                     TableImpl table,
                     CursorImpl.PositionImpl firstPos,
                     CursorImpl.PositionImpl lastPos)
Method Detail

createCursor

public static CursorImpl createCursor(TableImpl table)
Creates a normal, un-indexed cursor for the given table.

Parameters:
table - the table over which this cursor will traverse

getRowState

public TableImpl.RowState getRowState()

getId

public CursorImpl.IdImpl getId()
Specified by:
getId in interface Cursor

getTable

public TableImpl getTable()
Specified by:
getTable in interface Cursor

getFormat

public JetFormat getFormat()

getPageChannel

public PageChannel getPageChannel()

getErrorHandler

public ErrorHandler getErrorHandler()
Description copied from interface: Cursor
Gets the currently configured ErrorHandler (always non-null). This will be used to handle all errors.

Specified by:
getErrorHandler in interface Cursor

setErrorHandler

public void setErrorHandler(ErrorHandler newErrorHandler)
Description copied from interface: Cursor
Sets a new ErrorHandler. If null, resets to using the ErrorHandler configured at the Table level.

Specified by:
setErrorHandler in interface Cursor

getColumnMatcher

public ColumnMatcher getColumnMatcher()
Description copied from interface: Cursor
Returns the currently configured ColumnMatcher, always non-null.

Specified by:
getColumnMatcher in interface Cursor

setColumnMatcher

public void setColumnMatcher(ColumnMatcher columnMatcher)
Description copied from interface: Cursor
Sets a new ColumnMatcher. If null, resets to using the default matcher (default depends on Cursor type).

Specified by:
setColumnMatcher in interface Cursor

getDefaultColumnMatcher

protected ColumnMatcher getDefaultColumnMatcher()
Returns the default ColumnMatcher for this Cursor.


getSavepoint

public CursorImpl.SavepointImpl getSavepoint()
Description copied from interface: Cursor
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).

Savepoints may be used across different cursor instances for the same table, but they must have the same Cursor.Id.

Specified by:
getSavepoint in interface Cursor

restoreSavepoint

public void restoreSavepoint(Cursor.Savepoint savepoint)
                      throws IOException
Description copied from interface: Cursor
Moves the cursor to a savepoint previously returned from Cursor.getSavepoint().

Specified by:
restoreSavepoint in interface Cursor
Throws:
IOException

restoreSavepoint

public void restoreSavepoint(CursorImpl.SavepointImpl savepoint)
                      throws IOException
Throws:
IOException

getFirstPosition

protected CursorImpl.PositionImpl getFirstPosition()
Returns the first row id (exclusive) as defined by this cursor.


getLastPosition

protected CursorImpl.PositionImpl getLastPosition()
Returns the last row id (exclusive) as defined by this cursor.


reset

public void reset()
Description copied from interface: Cursor
Resets this cursor for forward traversal. Calls Cursor.beforeFirst().

Specified by:
reset in interface Cursor

beforeFirst

public void beforeFirst()
Description copied from interface: Cursor
Resets this cursor for forward traversal (sets cursor to before the first row).

Specified by:
beforeFirst in interface Cursor

afterLast

public void afterLast()
Description copied from interface: Cursor
Resets this cursor for reverse traversal (sets cursor to after the last row).

Specified by:
afterLast in interface Cursor

isBeforeFirst

public boolean isBeforeFirst()
                      throws IOException
Description copied from interface: Cursor
Returns true if the cursor is currently positioned before the first row, false otherwise.

Specified by:
isBeforeFirst in interface Cursor
Throws:
IOException

isAfterLast

public boolean isAfterLast()
                    throws IOException
Description copied from interface: Cursor
Returns true if the cursor is currently positioned after the last row, false otherwise.

Specified by:
isAfterLast in interface Cursor
Throws:
IOException

isAtBeginning

protected boolean isAtBeginning(boolean moveForward)
                         throws IOException
Throws:
IOException

isCurrentRowDeleted

public boolean isCurrentRowDeleted()
                            throws IOException
Description copied from interface: Cursor
Returns true if the row at which the cursor is currently positioned is deleted, false otherwise (including invalid rows).

Specified by:
isCurrentRowDeleted in interface Cursor
Throws:
IOException

reset

protected void reset(boolean moveForward)
Resets this cursor for traversing the given direction.


iterator

public Iterator<Row> iterator()
Description copied from interface: Cursor
Calls 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().

Specified by:
iterator in interface Cursor
Specified by:
iterator in interface Iterable<Row>

newIterable

public IterableBuilder newIterable()
Description copied from interface: Cursor
Convenience method for constructing a new IterableBuilder for this cursor. An IterableBuilder provides a variety of options for more flexible iteration.

Specified by:
newIterable in interface Cursor

iterator

public Iterator<Row> iterator(IterableBuilder iterBuilder)

deleteCurrentRow

public void deleteCurrentRow()
                      throws IOException
Description copied from interface: Cursor
Delete the current row.

Note, re-deleting an already deleted row is allowed (it does nothing).

Specified by:
deleteCurrentRow in interface Cursor
Throws:
IOException

updateCurrentRow

public Object[] updateCurrentRow(Object... row)
                          throws IOException
Description copied from interface: Cursor
Update the current row.

Specified by:
updateCurrentRow in interface Cursor
Returns:
the given row values if long enough, otherwise a new array, updated with the current row values
Throws:
IOException

updateCurrentRowFromMap

public <M extends Map<String,Object>> M updateCurrentRowFromMap(M row)
                                                     throws IOException
Description copied from interface: Cursor
Update the current row.

Specified by:
updateCurrentRowFromMap in interface Cursor
Returns:
the given row, updated with the current row values
Throws:
IOException

getNextRow

public Row getNextRow()
               throws IOException
Description copied from interface: Cursor
Moves to the next row in the table and returns it.

Specified by:
getNextRow in interface Cursor
Returns:
The next row in this table (Column name -> Column value), or null if no next row is found
Throws:
IOException

getNextRow

public Row getNextRow(Collection<String> columnNames)
               throws IOException
Description copied from interface: Cursor
Moves to the next row in the table and returns it.

Specified by:
getNextRow in interface Cursor
Parameters:
columnNames - Only column names in this collection will be returned
Returns:
The next row in this table (Column name -> Column value), or null if no next row is found
Throws:
IOException

getPreviousRow

public Row getPreviousRow()
                   throws IOException
Description copied from interface: Cursor
Moves to the previous row in the table and returns it.

Specified by:
getPreviousRow in interface Cursor
Returns:
The previous row in this table (Column name -> Column value), or null if no previous row is found
Throws:
IOException

getPreviousRow

public Row getPreviousRow(Collection<String> columnNames)
                   throws IOException
Description copied from interface: Cursor
Moves to the previous row in the table and returns it.

Specified by:
getPreviousRow in interface Cursor
Parameters:
columnNames - Only column names in this collection will be returned
Returns:
The previous row in this table (Column name -> Column value), or null if no previous row is found
Throws:
IOException

moveToNextRow

public boolean moveToNextRow()
                      throws IOException
Description copied from interface: Cursor
Moves to the next row as defined by this cursor.

Specified by:
moveToNextRow in interface Cursor
Returns:
true if a valid next row was found, false otherwise
Throws:
IOException

moveToPreviousRow

public boolean moveToPreviousRow()
                          throws IOException
Description copied from interface: Cursor
Moves to the previous row as defined by this cursor.

Specified by:
moveToPreviousRow in interface Cursor
Returns:
true if a valid previous row was found, false otherwise
Throws:
IOException

moveToAnotherRow

protected boolean moveToAnotherRow(boolean moveForward)
                            throws IOException
Moves to another row in the given direction as defined by this cursor.

Returns:
true if another valid row was found in the given direction, false otherwise
Throws:
IOException

restorePosition

protected void restorePosition(CursorImpl.PositionImpl curPos)
                        throws IOException
Restores a current position for the cursor (current position becomes previous position).

Throws:
IOException

restorePosition

protected final void restorePosition(CursorImpl.PositionImpl curPos,
                                     CursorImpl.PositionImpl prevPos)
                              throws IOException
Restores a current and previous position for the cursor if the given positions are different from the current positions.

Throws:
IOException

restorePositionImpl

protected void restorePositionImpl(CursorImpl.PositionImpl curPos,
                                   CursorImpl.PositionImpl prevPos)
                            throws IOException
Restores a current and previous position for the cursor.

Throws:
IOException

findRow

public boolean findRow(RowId rowId)
                throws IOException
Description copied from interface: Cursor
Moves to the row with the given rowId. If the row is not found (or an exception is thrown), the cursor is restored to its previous state.

Specified by:
findRow in interface Cursor
Returns:
true if a valid row was found with the given id, false if no row was found
Throws:
IOException

findFirstRow

public boolean findFirstRow(Column columnPattern,
                            Object valuePattern)
                     throws IOException
Description copied from interface: Cursor
Moves to the first row (as defined by the cursor) where the given column has the given value. This may be more efficient on some cursors than others. If a match is not found (or an exception is thrown), the cursor is restored to its previous state.

Warning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches).

Specified by:
findFirstRow in interface Cursor
Parameters:
columnPattern - column from the table for this cursor which is being matched by the valuePattern
valuePattern - value which is equal to the corresponding value in the matched row
Returns:
true if a valid row was found with the given value, false if no row was found
Throws:
IOException

findFirstRow

public boolean findFirstRow(ColumnImpl columnPattern,
                            Object valuePattern)
                     throws IOException
Throws:
IOException

findNextRow

public boolean findNextRow(Column columnPattern,
                           Object valuePattern)
                    throws IOException
Description copied from interface: Cursor
Moves to the next row (as defined by the cursor) where the given column has the given value. This may be more efficient on some cursors than others. If a match is not found (or an exception is thrown), the cursor is restored to its previous state.

Specified by:
findNextRow in interface Cursor
Parameters:
columnPattern - column from the table for this cursor which is being matched by the valuePattern
valuePattern - value which is equal to the corresponding value in the matched row
Returns:
true if a valid row was found with the given value, false if no row was found
Throws:
IOException

findNextRow

public boolean findNextRow(ColumnImpl columnPattern,
                           Object valuePattern)
                    throws IOException
Throws:
IOException

findAnotherRow

protected boolean findAnotherRow(ColumnImpl columnPattern,
                                 Object valuePattern,
                                 boolean reset,
                                 boolean moveForward,
                                 ColumnMatcher columnMatcher,
                                 Object searchInfo)
                          throws IOException
Throws:
IOException

findFirstRow

public boolean findFirstRow(Map<String,?> rowPattern)
                     throws IOException
Description copied from interface: Cursor
Moves to the first row (as defined by the cursor) where the given columns have the given values. This may be more efficient on some cursors than others. If a match is not found (or an exception is thrown), the cursor is restored to its previous state.

Warning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches).

Specified by:
findFirstRow in interface Cursor
Parameters:
rowPattern - column names and values which must be equal to the corresponding values in the matched row
Returns:
true if a valid row was found with the given values, false if no row was found
Throws:
IOException

findNextRow

public boolean findNextRow(Map<String,?> rowPattern)
                    throws IOException
Description copied from interface: Cursor
Moves to the next row (as defined by the cursor) where the given columns have the given values. This may be more efficient on some cursors than others. If a match is not found (or an exception is thrown), the cursor is restored to its previous state.

Specified by:
findNextRow in interface Cursor
Parameters:
rowPattern - column names and values which must be equal to the corresponding values in the matched row
Returns:
true if a valid row was found with the given values, false if no row was found
Throws:
IOException

findAnotherRow

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

currentRowMatches

public boolean currentRowMatches(Column columnPattern,
                                 Object valuePattern)
                          throws IOException
Description copied from interface: Cursor
Returns true if the current row matches the given pattern.

Specified by:
currentRowMatches in interface Cursor
Parameters:
columnPattern - column from the table for this cursor which is being matched by the valuePattern
valuePattern - value which is tested for equality with the corresponding value in the current row
Throws:
IOException

currentRowMatches

public boolean currentRowMatches(ColumnImpl columnPattern,
                                 Object valuePattern)
                          throws IOException
Throws:
IOException

currentRowMatchesImpl

protected boolean currentRowMatchesImpl(ColumnImpl columnPattern,
                                        Object valuePattern,
                                        ColumnMatcher columnMatcher)
                                 throws IOException
Throws:
IOException

currentRowMatches

public boolean currentRowMatches(Map<String,?> rowPattern)
                          throws IOException
Description copied from interface: Cursor
Returns true if the current row matches the given pattern.

Specified by:
currentRowMatches in interface Cursor
Parameters:
rowPattern - column names and values which must be equal to the corresponding values in the current row
Throws:
IOException

currentRowMatchesImpl

protected boolean currentRowMatchesImpl(Map<String,?> rowPattern,
                                        ColumnMatcher columnMatcher)
                                 throws IOException
Throws:
IOException

findAnotherRowImpl

protected boolean findAnotherRowImpl(ColumnImpl columnPattern,
                                     Object valuePattern,
                                     boolean moveForward,
                                     ColumnMatcher columnMatcher,
                                     Object searchInfo)
                              throws IOException
Moves to the next row (as defined by the cursor) where the given column has the given value. Caller manages save/restore on failure.

Default implementation scans the table from beginning to end.

Parameters:
columnPattern - column from the table for this cursor which is being matched by the valuePattern
valuePattern - value which is equal to the corresponding value in the matched row
Returns:
true if a valid row was found with the given value, false if no row was found
Throws:
IOException

findAnotherRowImpl

protected boolean findAnotherRowImpl(Map<String,?> rowPattern,
                                     boolean moveForward,
                                     ColumnMatcher columnMatcher,
                                     Object searchInfo)
                              throws IOException
Moves to the next row (as defined by the cursor) where the given columns have the given values. Caller manages save/restore on failure.

Default implementation scans the table from beginning to end.

Parameters:
rowPattern - column names and values which must be equal to the corresponding values in the matched row
Returns:
true if a valid row was found with the given values, false if no row was found
Throws:
IOException

prepareSearchInfo

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).


prepareSearchInfo

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).


keepSearching

protected boolean keepSearching(ColumnMatcher columnMatcher,
                                Object searchInfo)
                         throws IOException
Called by findAnotherRowImpl to determine if the search should continue after finding a row which does not match the current pattern.

Throws:
IOException

moveNextRows

public int moveNextRows(int numRows)
                 throws IOException
Description copied from interface: Cursor
Moves forward as many rows as possible up to the given number of rows.

Specified by:
moveNextRows in interface Cursor
Returns:
the number of rows moved.
Throws:
IOException

movePreviousRows

public int movePreviousRows(int numRows)
                     throws IOException
Description copied from interface: Cursor
Moves backward as many rows as possible up to the given number of rows.

Specified by:
movePreviousRows in interface Cursor
Returns:
the number of rows moved.
Throws:
IOException

getCurrentRow

public Row getCurrentRow()
                  throws IOException
Description copied from interface: Cursor
Returns the current row in this cursor (Column name -> Column value).

Specified by:
getCurrentRow in interface Cursor
Throws:
IOException

getCurrentRow

public Row getCurrentRow(Collection<String> columnNames)
                  throws IOException
Description copied from interface: Cursor
Returns the current row in this cursor (Column name -> Column value).

Specified by:
getCurrentRow in interface Cursor
Parameters:
columnNames - Only column names in this collection will be returned
Throws:
IOException

getCurrentRowValue

public Object getCurrentRowValue(Column column)
                          throws IOException
Description copied from interface: Cursor
Returns the given column from the current row.

Specified by:
getCurrentRowValue in interface Cursor
Throws:
IOException

getCurrentRowValue

public Object getCurrentRowValue(ColumnImpl column)
                          throws IOException
Throws:
IOException

setCurrentRowValue

public void setCurrentRowValue(Column column,
                               Object value)
                        throws IOException
Description copied from interface: Cursor
Updates a single value in the current row.

Specified by:
setCurrentRowValue in interface Cursor
Throws:
IOException

setCurrentRowValue

public void setCurrentRowValue(ColumnImpl column,
                               Object value)
                        throws IOException
Throws:
IOException

isUpToDate

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


isCurrentRowValid

protected boolean isCurrentRowValid()
                             throws IOException
Returns true of the current row is valid, false otherwise.

Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

getRowPosition

protected abstract CursorImpl.PositionImpl getRowPosition(RowIdImpl rowId)
                                                   throws IOException
Returns the appropriate position information for the given row (which is the current row and is valid).

Throws:
IOException

findAnotherPosition

protected abstract CursorImpl.PositionImpl findAnotherPosition(TableImpl.RowState rowState,
                                                               CursorImpl.PositionImpl curPos,
                                                               boolean moveForward)
                                                        throws IOException
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. If there are no more rows, the returned rowId should equal the value returned by getLastPosition() if moving forward and getFirstPosition() if moving backward.

Throws:
IOException

getDirHandler

protected abstract CursorImpl.DirHandler getDirHandler(boolean moveForward)
Returns the DirHandler for the given movement direction.



Copyright © 2005-2017 Health Market Science. All Rights Reserved.