aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/healthmarketscience
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2011-03-18 03:49:20 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2011-03-18 03:49:20 +0000
commit87848aae4274462e9cabf0e7999ca6cc12a6b6f3 (patch)
treec36050247a98152ce5ed9df87d4e8ce21c73e346 /src/java/com/healthmarketscience
parent64e9887133cc2a0996f3793bb3748023c215cdfc (diff)
downloadjackcess-87848aae4274462e9cabf0e7999ca6cc12a6b6f3.tar.gz
jackcess-87848aae4274462e9cabf0e7999ca6cc12a6b6f3.zip
make iterator work a little better, allow remove
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@527 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java/com/healthmarketscience')
-rw-r--r--src/java/com/healthmarketscience/jackcess/Cursor.java39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Cursor.java b/src/java/com/healthmarketscience/jackcess/Cursor.java
index 58acfee..81a2555 100644
--- a/src/java/com/healthmarketscience/jackcess/Cursor.java
+++ b/src/java/com/healthmarketscience/jackcess/Cursor.java
@@ -963,30 +963,30 @@ public abstract class Cursor implements Iterable<Map<String, Object>>
protected abstract DirHandler getDirHandler(boolean moveForward);
/**
- * Row iterator for this table, unmodifiable.
+ * Row iterator for this table, modifiable.
*/
private final class RowIterator implements Iterator<Map<String, Object>>
{
private final Collection<String> _columnNames;
private final boolean _moveForward;
- private boolean _hasNext = false;
+ private Boolean _hasNext;
private RowIterator(Collection<String> columnNames, boolean moveForward)
{
- try {
- _columnNames = columnNames;
- _moveForward = moveForward;
- reset(_moveForward);
- _hasNext = moveToAnotherRow(_moveForward);
- } catch(IOException e) {
- throw new IllegalStateException(e);
- }
+ _columnNames = columnNames;
+ _moveForward = moveForward;
+ reset(_moveForward);
}
- public boolean hasNext() { return _hasNext; }
-
- public void remove() {
- throw new UnsupportedOperationException();
+ public boolean hasNext() {
+ if(_hasNext == null) {
+ try {
+ _hasNext = moveToAnotherRow(_moveForward);
+ } catch(IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return _hasNext;
}
public Map<String, Object> next() {
@@ -995,13 +995,20 @@ public abstract class Cursor implements Iterable<Map<String, Object>>
}
try {
Map<String, Object> rtn = getCurrentRow(_columnNames);
- _hasNext = moveToAnotherRow(_moveForward);
+ _hasNext = null;
return rtn;
} catch(IOException e) {
throw new IllegalStateException(e);
}
}
-
+
+ public void remove() {
+ try {
+ deleteCurrentRow();
+ } catch(IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
}
/**