public final class CursorJoiner extends Object implements Iterator<CursorJoiner.Result>, Iterable<CursorJoiner.Result>
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; } }
Modifier and Type | Class and Description |
---|---|
static class |
CursorJoiner.Result
The result of a call to next().
|
Constructor and Description |
---|
CursorJoiner(Cursor cursorLeft,
String[] columnNamesLeft,
Cursor cursorRight,
String[] columnNamesRight)
Initializes the CursorJoiner and resets the cursors to the first row.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Returns whether or not there are more rows to compare using next().
|
Iterator<CursorJoiner.Result> |
iterator()
Returns an iterator over elements of type
T . |
CursorJoiner.Result |
next()
Returns the comparison result of the next row from each cursor.
|
void |
remove()
Removes from the underlying collection the last element returned
by this iterator (optional operation).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
forEach, spliterator
public CursorJoiner(Cursor cursorLeft, String[] columnNamesLeft, Cursor cursorRight, String[] columnNamesRight)
cursorLeft
- The left cursor to comparecolumnNamesLeft
- The column names to compare from the left cursorcursorRight
- The right cursor to comparecolumnNamesRight
- The column names to compare from the right cursorpublic Iterator<CursorJoiner.Result> iterator()
Iterable
T
.iterator
in interface Iterable<CursorJoiner.Result>
public boolean hasNext()
hasNext
in interface Iterator<CursorJoiner.Result>
public CursorJoiner.Result next()
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.
next
in interface Iterator<CursorJoiner.Result>
public void remove()
Iterator
Iterator.next()
. The behavior of an iterator
is unspecified if the underlying collection is modified while the
iteration is in progress in any way other than by calling this
method.remove
in interface Iterator<CursorJoiner.Result>