From: James Ahlborn Date: Fri, 15 Mar 2013 16:00:57 +0000 (+0000) Subject: simplify cursor interface (remove redundant iterator methods) X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a1d94149888e0612be3e561b05602de88ac5f49c;p=jackcess.git simplify cursor interface (remove redundant iterator methods) git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-2@687 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/java/com/healthmarketscience/jackcess/Cursor.java b/src/java/com/healthmarketscience/jackcess/Cursor.java index 6d5787c..636d604 100644 --- a/src/java/com/healthmarketscience/jackcess/Cursor.java +++ b/src/java/com/healthmarketscience/jackcess/Cursor.java @@ -46,8 +46,6 @@ import com.healthmarketscience.jackcess.util.ColumnMatcher; public interface Cursor extends Iterable { - // FIXME, include iterable and iterator methods? - public Id getId(); public Table getTable(); @@ -129,21 +127,21 @@ public interface Cursor extends Iterable public boolean isCurrentRowDeleted() throws IOException; /** - * Returns an Iterable whose iterator() method calls afterLast - * on this cursor and returns a modifiable 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. + * Returns an Iterable whose iterator() method calls {@link #afterLast} on + * this cursor and returns a modifiable 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 {@link #getPreviousRow}. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ public Iterable reverseIterable(); /** - * Returns an Iterable whose iterator() method calls afterLast - * on this table and returns a modifiable 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. + * Returns an Iterable whose iterator() method calls {@link #afterLast} on + * this table and returns a modifiable 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 + * {@link #getPreviousRow}. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ @@ -151,18 +149,20 @@ public interface Cursor extends Iterable Collection columnNames); /** - * Calls beforeFirst on this cursor and returns a modifiable + * Calls {@link #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 - * getNextRow. + * {@link #getNextRow}. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ public Iterator iterator(); /** - * Returns an Iterable whose iterator() method returns the result of a call - * to {@link #iterator(Collection)} + * Returns an Iterable whose iterator() method calls {@link #beforeFirst} on + * this table and returns a modifiable 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 {@link #getNextRow}. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ @@ -170,18 +170,12 @@ public interface Cursor extends Iterable Collection columnNames); /** - * Calls beforeFirst on this table and returns a modifiable - * 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. - * @throws IllegalStateException if an IOException is thrown by one of the - * operations, the actual exception will be contained within - */ - public Iterator iterator(Collection columnNames); - - /** - * Returns an Iterable whose iterator() method returns the result of a call - * to {@link #columnMatchIterable(Column,Object)} + * Returns an Iterable whose iterator() method calls {@link #beforeFirst} on + * this cursor and returns a modifiable Iterator which will iterate through + * all the rows of this table which match the given column pattern. Use of + * the Iterator follows the same restrictions as a call to {@link + * #getNextRow}. See {@link #findFirstRow(Column,Object)} for details on + * #the columnPattern. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ @@ -189,20 +183,12 @@ public interface Cursor extends Iterable Column columnPattern, Object valuePattern); /** - * Calls beforeFirst on this cursor and returns a modifiable - * Iterator which will iterate through all the rows of this table which - * match the given column pattern. Use of the Iterator follows the same - * restrictions as a call to getNextRow. See - * {@link #findFirstRow(Column,Object)} for details on the columnPattern. - * @throws IllegalStateException if an IOException is thrown by one of the - * operations, the actual exception will be contained within - */ - public Iterator columnMatchIterator( - Column columnPattern, Object valuePattern); - - /** - * Returns an Iterable whose iterator() method returns the result of a call - * to {@link #columnMatchIterator(Collection,Column,Object)} + * Returns an Iterable whose iterator() method calls {@link #beforeFirst} on + * this table and returns a modifiable Iterator which will iterate through + * all the rows of this table which match the given column pattern, + * returning only the given columns. Use of the Iterator follows the same + * restrictions as a call to {@link #getNextRow}. See {@link + * #findFirstRow(Column,Object)} for details on the columnPattern. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ @@ -211,21 +197,11 @@ public interface Cursor extends Iterable Column columnPattern, Object valuePattern); /** - * Calls beforeFirst on this table and returns a modifiable - * Iterator which will iterate through all the rows of this table which - * match the given column pattern, returning only the given columns. Use of - * the Iterator follows the same restrictions as a call to - * getNextRow. See {@link #findFirstRow(Column,Object)} for - * details on the columnPattern. - * @throws IllegalStateException if an IOException is thrown by one of the - * operations, the actual exception will be contained within - */ - public Iterator columnMatchIterator( - Collection columnNames, Column columnPattern, Object valuePattern); - - /** - * Returns an Iterable whose iterator() method returns the result of a call - * to {@link #rowMatchIterator(Map)} + * Returns an Iterable whose iterator() method calls {@link #beforeFirst} on + * this cursor and returns a modifiable Iterator which will iterate through + * all the rows of this table which match the given row pattern. Use of the + * Iterator follows the same restrictions as a call to {@link #getNextRow}. + * See {@link #findFirstRow(Map)} for details on the rowPattern. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ @@ -233,20 +209,12 @@ public interface Cursor extends Iterable Map rowPattern); /** - * Calls beforeFirst on this cursor and returns a modifiable - * Iterator which will iterate through all the rows of this table which - * match the given row pattern. Use of the Iterator follows the same - * restrictions as a call to getNextRow. See - * {@link #findFirstRow(Map)} for details on the rowPattern. - * @throws IllegalStateException if an IOException is thrown by one of the - * operations, the actual exception will be contained within - */ - public Iterator rowMatchIterator( - Map rowPattern); - - /** - * Returns an Iterable whose iterator() method returns the result of a call - * to {@link #rowMatchIterator(Collection,Map)} + * Returns an Iterable whose iterator() method calls {@link #beforeFirst} on + * this table and returns a modifiable Iterator which will iterate through + * all the rows of this table which match the given row pattern, returning + * only the given columns. Use of the Iterator follows the same + * restrictions as a call to {@link #getNextRow}. See {@link + * #findFirstRow(Map)} for details on the rowPattern. * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ @@ -254,19 +222,6 @@ public interface Cursor extends Iterable Collection columnNames, Map rowPattern); - /** - * Calls beforeFirst on this table and returns a modifiable - * Iterator which will iterate through all the rows of this table which - * match the given row pattern, returning only the given columns. Use of - * the Iterator follows the same restrictions as a call to - * getNextRow. See {@link #findFirstRow(Map)} for details on - * the rowPattern. - * @throws IllegalStateException if an IOException is thrown by one of the - * operations, the actual exception will be contained within - */ - public Iterator rowMatchIterator( - Collection columnNames, Map rowPattern); - /** * Delete the current row. * @throws IllegalStateException if the current row is not valid (at diff --git a/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java b/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java index 7583034..8d0b4b6 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java @@ -440,6 +440,14 @@ public abstract class CursorImpl implements Cursor }; } + /** + * Calls beforeFirst on this table and returns a modifiable + * 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. + * @throws IllegalStateException if an IOException is thrown by one of the + * operations, the actual exception will be contained within + */ public Iterator iterator(Collection columnNames) { return new RowIterator(columnNames, MOVE_FORWARD); @@ -457,6 +465,15 @@ public abstract class CursorImpl implements Cursor return columnMatchIterable(null, columnPattern, valuePattern); } + /** + * Calls beforeFirst on this cursor and returns a modifiable + * Iterator which will iterate through all the rows of this table which + * match the given column pattern. Use of the Iterator follows the same + * restrictions as a call to getNextRow. See + * {@link #findFirstRow(Column,Object)} for details on the columnPattern. + * @throws IllegalStateException if an IOException is thrown by one of the + * operations, the actual exception will be contained within + */ public Iterator columnMatchIterator( Column columnPattern, Object valuePattern) { @@ -489,6 +506,16 @@ public abstract class CursorImpl implements Cursor }; } + /** + * Calls beforeFirst on this table and returns a modifiable + * Iterator which will iterate through all the rows of this table which + * match the given column pattern, returning only the given columns. Use of + * the Iterator follows the same restrictions as a call to + * getNextRow. See {@link #findFirstRow(Column,Object)} for + * details on the columnPattern. + * @throws IllegalStateException if an IOException is thrown by one of the + * operations, the actual exception will be contained within + */ public Iterator columnMatchIterator( Collection columnNames, Column columnPattern, Object valuePattern) @@ -510,6 +537,15 @@ public abstract class CursorImpl implements Cursor return rowMatchIterable(null, rowPattern); } + /** + * Calls beforeFirst on this cursor and returns a modifiable + * Iterator which will iterate through all the rows of this table which + * match the given row pattern. Use of the Iterator follows the same + * restrictions as a call to getNextRow. See + * {@link #findFirstRow(Map)} for details on the rowPattern. + * @throws IllegalStateException if an IOException is thrown by one of the + * operations, the actual exception will be contained within + */ public Iterator rowMatchIterator( Map rowPattern) { @@ -528,6 +564,16 @@ public abstract class CursorImpl implements Cursor }; } + /** + * Calls beforeFirst on this table and returns a modifiable + * Iterator which will iterate through all the rows of this table which + * match the given row pattern, returning only the given columns. Use of + * the Iterator follows the same restrictions as a call to + * getNextRow. See {@link #findFirstRow(Map)} for details on + * the rowPattern. + * @throws IllegalStateException if an IOException is thrown by one of the + * operations, the actual exception will be contained within + */ public Iterator rowMatchIterator( Collection columnNames, Map rowPattern) {