CursorJoiner
class CursorJoiner : MutableIterable<CursorJoiner.Result!>, MutableIterator<CursorJoiner.Result!>
kotlin.Any | |
↳ | android.database.CursorJoiner |
Does a join on two cursors using the specified columns. The cursors must already be sorted on each of the specified columns in ascending order. This joiner only supports the case where the tuple of key column values is unique.
Typical usage:
CursorJoiner joiner = new CursorJoiner(cursorA, keyColumnsofA, cursorB, keyColumnsofB); for (CursorJoiner.Result joinerResult : joiner) { switch (joinerResult) { case LEFT: // handle case where a row in cursorA is unique break; case RIGHT: // handle case where a row in cursorB is unique break; case BOTH: // handle case where a row with the same key is in both cursors break; } }
Summary
Nested classes | |
---|---|
The result of a call to next(). |
Public constructors | |
---|---|
CursorJoiner(cursorLeft: Cursor!, columnNamesLeft: Array<String!>!, cursorRight: Cursor!, columnNamesRight: Array<String!>!) Initializes the CursorJoiner and resets the cursors to the first row. |
Public methods | |
---|---|
Boolean |
hasNext() Returns whether or not there are more rows to compare using next(). |
MutableIterator<CursorJoiner.Result!> |
iterator() |
CursorJoiner.Result! |
next() Returns the comparison result of the next row from each cursor. |
Unit |
remove() |
Public constructors
CursorJoiner
CursorJoiner(
cursorLeft: Cursor!,
columnNamesLeft: Array<String!>!,
cursorRight: Cursor!,
columnNamesRight: Array<String!>!)
Initializes the CursorJoiner and resets the cursors to the first row. The left and right column name arrays must have the same number of columns.
Parameters | |
---|---|
cursorLeft |
Cursor!: The left cursor to compare |
columnNamesLeft |
Array<String!>!: The column names to compare from the left cursor |
cursorRight |
Cursor!: The right cursor to compare |
columnNamesRight |
Array<String!>!: The column names to compare from the right cursor |
Public methods
hasNext
fun hasNext(): Boolean
Returns whether or not there are more rows to compare using next().
Return | |
---|---|
Boolean |
true if there are more rows to compare |
iterator
fun iterator(): MutableIterator<CursorJoiner.Result!>
Return | |
---|---|
MutableIterator<CursorJoiner.Result!> |
an Iterator. |
next
fun next(): CursorJoiner.Result!
Returns the comparison result of the next row from each cursor. If one cursor has no more rows but the other does then subsequent calls to this will indicate that the remaining rows are unique.
The caller must check that hasNext() returns true before calling this.
Once next() has been called the cursors specified in the result of the call to next() are guaranteed to point to the row that was indicated. Reading values from the cursor that was not indicated in the call to next() will result in undefined behavior.
Return | |
---|---|
CursorJoiner.Result! |
LEFT, if the row pointed to by the left cursor is unique, RIGHT if the row pointed to by the right cursor is unique, BOTH if the rows in both cursors are the same. |
Exceptions | |
---|---|
java.util.NoSuchElementException |
if the iteration has no more elements |
remove
fun remove(): Unit
Exceptions | |
---|---|
java.lang.UnsupportedOperationException |
if the remove operation is not supported by this iterator |
java.lang.IllegalStateException |
if the next method has not yet been called, or the remove method has already been called after the last call to the next method |