|
Elexis API documentationVersion 2.1.6 as of December 11 2011 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.healthmarketscience.jackcess.Cursor
public abstract class 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.
Nested Class Summary | |
---|---|
static class |
Cursor.Id
Identifier for a cursor. |
static class |
Cursor.Position
Value object which maintains the current position of the cursor. |
static class |
Cursor.Savepoint
Value object which represents a complete save state of the cursor. |
Field Summary | |
---|---|
static boolean |
MOVE_FORWARD
boolean value indicating forward movement |
static boolean |
MOVE_REVERSE
boolean value indicating reverse movement |
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 Cursor |
createCursor(Table table)
Creates a normal, un-indexed cursor for the given table. |
static Cursor |
createIndexCursor(Table table,
Index index)
Creates an indexed cursor for the given table. |
static Cursor |
createIndexCursor(Table table,
Index index,
java.lang.Object[] startRow,
boolean startInclusive,
java.lang.Object[] endRow,
boolean endInclusive)
Creates an indexed cursor for the given table, narrowed to the given range. |
static Cursor |
createIndexCursor(Table table,
Index index,
java.lang.Object[] startRow,
java.lang.Object[] endRow)
Creates an indexed cursor for the given table, narrowed to the given range. |
boolean |
currentRowMatches(Column columnPattern,
java.lang.Object valuePattern)
Returns true if the current row matches the given pattern. |
boolean |
currentRowMatches(java.util.Map<java.lang.String,java.lang.Object> rowPattern)
Returns true if the current row matches the given pattern. |
void |
deleteCurrentRow()
Delete the current row. |
boolean |
findRow(Column columnPattern,
java.lang.Object valuePattern)
Moves to the first row (as defined by the cursor) where the given column has the given value. |
boolean |
findRow(java.util.Map<java.lang.String,java.lang.Object> rowPattern)
Moves to the first row (as defined by the cursor) where the given columns have the given values. |
static java.util.Map<java.lang.String,java.lang.Object> |
findRow(Table table,
Index index,
java.util.Map<java.lang.String,java.lang.Object> rowPattern)
Convenience method for finding a specific row in an indexed table which matches a given row "pattern". |
static java.util.Map<java.lang.String,java.lang.Object> |
findRow(Table table,
java.util.Map<java.lang.String,java.lang.Object> rowPattern)
Convenience method for finding a specific row in a table which matches a given row "pattern". |
static java.lang.Object |
findValue(Table table,
Column column,
Column columnPattern,
java.lang.Object valuePattern)
Convenience method for finding a specific row in a table which matches a given row "pattern". |
static java.lang.Object |
findValue(Table table,
Index index,
Column column,
Column columnPattern,
java.lang.Object valuePattern)
Convenience method for finding a specific row in a table which matches a given row "pattern". |
java.util.Map<java.lang.String,java.lang.Object> |
getCurrentRow()
Returns the current row in this cursor (Column name -> Column value). |
java.util.Map<java.lang.String,java.lang.Object> |
getCurrentRow(java.util.Collection<java.lang.String> columnNames)
Returns the current row in this cursor (Column name -> Column value). |
java.lang.Object |
getCurrentRowValue(Column column)
Returns the given column from the current row. |
ErrorHandler |
getErrorHandler()
Gets the currently configured ErrorHandler (always non- null ). |
JetFormat |
getFormat()
|
Cursor.Id |
getId()
|
Index |
getIndex()
|
java.util.Map<java.lang.String,java.lang.Object> |
getNextRow()
Moves to the next row in the table and returns it. |
java.util.Map<java.lang.String,java.lang.Object> |
getNextRow(java.util.Collection<java.lang.String> columnNames)
Moves to the next row in the table and returns it. |
PageChannel |
getPageChannel()
|
java.util.Map<java.lang.String,java.lang.Object> |
getPreviousRow()
Moves to the previous row in the table and returns it. |
java.util.Map<java.lang.String,java.lang.Object> |
getPreviousRow(java.util.Collection<java.lang.String> columnNames)
Moves to the previous row in the table and returns it. |
Cursor.Savepoint |
getSavepoint()
Returns the current state of the cursor which can be restored at a future point in time by a call to restoreSavepoint(com.healthmarketscience.jackcess.Cursor.Savepoint) . |
Table |
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). |
java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>> |
iterable(java.util.Collection<java.lang.String> columnNames)
Returns an Iterable whose iterator() method returns the result of a call to iterator(Collection) |
java.util.Iterator<java.util.Map<java.lang.String,java.lang.Object>> |
iterator()
Calls beforeFirst on this cursor and returns an unmodifiable Iterator which will
iterate through all the rows of this table. |
java.util.Iterator<java.util.Map<java.lang.String,java.lang.Object>> |
iterator(java.util.Collection<java.lang.String> columnNames)
Calls beforeFirst on this table and returns an unmodifiable Iterator which will
iterate through all the rows of this table, returning only the given columns. |
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. |
void |
reset()
Resets this cursor for forward traversal. |
void |
restoreSavepoint(Cursor.Savepoint savepoint)
Moves the cursor to a savepoint previously returned from getSavepoint() . |
java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>> |
reverseIterable()
Returns an Iterable whose iterator() method calls afterLast on this cursor and
returns an unmodifiable Iterator which will iterate through all the rows of this table in
reverse order. |
java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>> |
reverseIterable(java.util.Collection<java.lang.String> columnNames)
Returns an Iterable whose iterator() method calls afterLast on this table and
returns an unmodifiable Iterator which will iterate through all the rows of this table in
reverse order, returning only the given columns. |
void |
setCurrentRowValue(Column column,
java.lang.Object value)
Updates a single value in the current row. |
void |
setErrorHandler(ErrorHandler newErrorHandler)
Sets a new ErrorHandler. |
java.lang.String |
toString()
|
void |
updateCurrentRow(java.lang.Object... row)
Update the current row. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final boolean MOVE_FORWARD
public static final boolean MOVE_REVERSE
Method Detail |
---|
public static Cursor createCursor(Table table)
table
- the table over which this cursor will traversepublic static Cursor createIndexCursor(Table table, Index index) throws java.io.IOException
Note, index based table traversal may not include all rows, as certain types of indexes do
not include all entries (namely, some indexes ignore null entries, see
Index.shouldIgnoreNulls()
).
table
- the table over which this cursor will traverseindex
- index for the table which will define traversal order as well as enhance certain
lookups
java.io.IOException
public static Cursor createIndexCursor(Table table, Index index, java.lang.Object[] startRow, java.lang.Object[] endRow) throws java.io.IOException
Note, index based table traversal may not include all rows, as certain types of indexes do
not include all entries (namely, some indexes ignore null entries, see
Index.shouldIgnoreNulls()
).
table
- the table over which this cursor will traverseindex
- index for the table which will define traversal order as well as enhance certain
lookupsstartRow
- the first row of data for the cursor (inclusive), or null
for the first
entryendRow
- the last row of data for the cursor (inclusive), or null
for the last
entry
java.io.IOException
public static Cursor createIndexCursor(Table table, Index index, java.lang.Object[] startRow, boolean startInclusive, java.lang.Object[] endRow, boolean endInclusive) throws java.io.IOException
Note, index based table traversal may not include all rows, as certain types of indexes do
not include all entries (namely, some indexes ignore null entries, see
Index.shouldIgnoreNulls()
).
table
- the table over which this cursor will traverseindex
- index for the table which will define traversal order as well as enhance certain
lookupsstartRow
- the first row of data for the cursor, or null
for the first entrystartInclusive
- whether or not startRow is inclusive or exclusiveendRow
- the last row of data for the cursor, or null
for the last entryendInclusive
- whether or not endRow is inclusive or exclusive
java.io.IOException
public static java.util.Map<java.lang.String,java.lang.Object> findRow(Table table, java.util.Map<java.lang.String,java.lang.Object> rowPattern) throws java.io.IOException
findRow(Map)
for details on the rowPattern.
table
- the table to searchrowPattern
- pattern to be used to find the row
null
if a match could not be found.
java.io.IOException
public static java.lang.Object findValue(Table table, Column column, Column columnPattern, java.lang.Object valuePattern) throws java.io.IOException
findRow(Column,Object)
for details on the pattern.
Note, a null
result value is ambiguous in that it could imply no match or a matching
row with null
for the desired value. If distinguishing this situation is important,
you will need to use a Cursor directly instead of this convenience method.
table
- the table to searchcolumn
- column whose value should be returnedcolumnPattern
- column being matched by the valuePatternvaluePattern
- value from the columnPattern which will match the desired row
null
if a match could not be found.
java.io.IOException
public static java.util.Map<java.lang.String,java.lang.Object> findRow(Table table, Index index, java.util.Map<java.lang.String,java.lang.Object> rowPattern) throws java.io.IOException
findRow(Map)
for details on the rowPattern.
table
- the table to searchindex
- index to assist the searchrowPattern
- pattern to be used to find the row
null
if a match could not be found.
java.io.IOException
public static java.lang.Object findValue(Table table, Index index, Column column, Column columnPattern, java.lang.Object valuePattern) throws java.io.IOException
findRow(Column,Object)
for details on the pattern.
Note, a null
result value is ambiguous in that it could imply no match or a matching
row with null
for the desired value. If distinguishing this situation is important,
you will need to use a Cursor directly instead of this convenience method.
table
- the table to searchindex
- index to assist the searchcolumn
- column whose value should be returnedcolumnPattern
- column being matched by the valuePatternvaluePattern
- value from the columnPattern which will match the desired row
null
if a match could not be found.
java.io.IOException
public Cursor.Id getId()
public Table getTable()
public Index getIndex()
public JetFormat getFormat()
public PageChannel getPageChannel()
public ErrorHandler getErrorHandler()
null
). This will be used to
handle all errors.
public void setErrorHandler(ErrorHandler newErrorHandler)
null
, resets to using the ErrorHandler configured at the
Table level.
public Cursor.Savepoint getSavepoint()
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
.
public void restoreSavepoint(Cursor.Savepoint savepoint) throws java.io.IOException
getSavepoint()
.
java.lang.IllegalArgumentException
- if the given savepoint does not have a cursorId equal to this cursor's id
java.io.IOException
public void reset()
beforeFirst()
.
public void beforeFirst()
public void afterLast()
public boolean isBeforeFirst() throws java.io.IOException
true
if the cursor is currently positioned before the first row, false
otherwise.
java.io.IOException
public boolean isAfterLast() throws java.io.IOException
true
if the cursor is currently positioned after the last row, false
otherwise.
java.io.IOException
public boolean isCurrentRowDeleted() throws java.io.IOException
true
if the row at which the cursor is currently positioned is deleted,
false
otherwise (including invalid rows).
java.io.IOException
public java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>> reverseIterable()
afterLast
on this cursor and
returns an unmodifiable Iterator which will iterate through all the rows of this table in
reverse order. Use of the Iterator follows the same restrictions as a call to
getPreviousRow
.
java.lang.IllegalStateException
- if an IOException is thrown by one of the operations, the actual exception will
be contained withinpublic java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>> reverseIterable(java.util.Collection<java.lang.String> columnNames)
afterLast
on this table and
returns an unmodifiable Iterator which will iterate through all the rows of this table in
reverse order, returning only the given columns. Use of the Iterator follows the same
restrictions as a call to getPreviousRow
.
java.lang.IllegalStateException
- if an IOException is thrown by one of the operations, the actual exception will
be contained withinpublic java.util.Iterator<java.util.Map<java.lang.String,java.lang.Object>> iterator()
beforeFirst
on this cursor and returns an unmodifiable Iterator which will
iterate through all the rows of this table. Use of the Iterator follows the same restrictions
as a call to getNextRow
.
iterator
in interface java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>>
java.lang.IllegalStateException
- if an IOException is thrown by one of the operations, the actual exception will
be contained withinpublic java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>> iterable(java.util.Collection<java.lang.String> columnNames)
iterator(Collection)
java.lang.IllegalStateException
- if an IOException is thrown by one of the operations, the actual exception will
be contained withinpublic java.util.Iterator<java.util.Map<java.lang.String,java.lang.Object>> iterator(java.util.Collection<java.lang.String> columnNames)
beforeFirst
on this table and returns an unmodifiable Iterator which will
iterate through all the rows of this table, returning only the given columns. Use of the
Iterator follows the same restrictions as a call to getNextRow
.
java.lang.IllegalStateException
- if an IOException is thrown by one of the operations, the actual exception will
be contained withinpublic void deleteCurrentRow() throws java.io.IOException
java.lang.IllegalStateException
- if the current row is not valid (at beginning or end of table), or already
deleted.
java.io.IOException
public void updateCurrentRow(java.lang.Object... row) throws java.io.IOException
java.lang.IllegalStateException
- if the current row is not valid (at beginning or end of table), or deleted.
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getNextRow() throws java.io.IOException
null
if no next
row is found
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getNextRow(java.util.Collection<java.lang.String> columnNames) throws java.io.IOException
columnNames
- Only column names in this collection will be returned
null
if no next
row is found
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getPreviousRow() throws java.io.IOException
null
if no
previous row is found
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getPreviousRow(java.util.Collection<java.lang.String> columnNames) throws java.io.IOException
columnNames
- Only column names in this collection will be returned
null
if no
previous row is found
java.io.IOException
public boolean moveToNextRow() throws java.io.IOException
true
if a valid next row was found, false
otherwise
java.io.IOException
public boolean moveToPreviousRow() throws java.io.IOException
true
if a valid previous row was found, false
otherwise
java.io.IOException
public boolean findRow(Column columnPattern, java.lang.Object valuePattern) throws java.io.IOException
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
true
if a valid row was found with the given value, false
if no row
was found
java.io.IOException
public boolean findRow(java.util.Map<java.lang.String,java.lang.Object> rowPattern) throws java.io.IOException
rowPattern
- column names and values which must be equal to the corresponding values in the
matched row
true
if a valid row was found with the given values, false
if no row
was found
java.io.IOException
public boolean currentRowMatches(Column columnPattern, java.lang.Object valuePattern) throws java.io.IOException
true
if the current row matches the given pattern.
columnPattern
- column from the table for this cursor which is being matched by the valuePatternvaluePattern
- value which is tested for equality with the corresponding value in the current row
java.io.IOException
public boolean currentRowMatches(java.util.Map<java.lang.String,java.lang.Object> rowPattern) throws java.io.IOException
true
if the current row matches the given pattern.
rowPattern
- column names and values which must be equal to the corresponding values in the
current row
java.io.IOException
public int moveNextRows(int numRows) throws java.io.IOException
java.io.IOException
public int movePreviousRows(int numRows) throws java.io.IOException
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getCurrentRow() throws java.io.IOException
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getCurrentRow(java.util.Collection<java.lang.String> columnNames) throws java.io.IOException
columnNames
- Only column names in this collection will be returned
java.io.IOException
public java.lang.Object getCurrentRowValue(Column column) throws java.io.IOException
java.io.IOException
public void setCurrentRowValue(Column column, java.lang.Object value) throws java.io.IOException
java.lang.IllegalStateException
- if the current row is not valid (at beginning or end of table), or deleted.
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
Elexis API documentationVersion 2.1.6 as of December 11 2011 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |