From a85e7e333ec97a7b5779912f32ffb628aae3fa29 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Sat, 5 Apr 2008 03:28:11 +0000 Subject: [PATCH] add constants for movement booleans git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@308 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../healthmarketscience/jackcess/Cursor.java | 36 +++++++++++-------- .../jackcess/UsageMap.java | 8 ++--- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/java/com/healthmarketscience/jackcess/Cursor.java b/src/java/com/healthmarketscience/jackcess/Cursor.java index da54d63..b3ae216 100644 --- a/src/java/com/healthmarketscience/jackcess/Cursor.java +++ b/src/java/com/healthmarketscience/jackcess/Cursor.java @@ -60,6 +60,11 @@ public abstract class Cursor implements Iterable> { private static final Log LOG = LogFactory.getLog(Cursor.class); + /** boolean value indicating forward movement */ + public static final boolean MOVE_FORWARD = true; + /** boolean value indicating reverse movement */ + public static final boolean MOVE_REVERSE = false; + /** first position for the TableScanCursor */ private static final ScanPosition FIRST_SCAN_POSITION = new ScanPosition(RowId.FIRST_ROW_ID); @@ -333,7 +338,7 @@ public abstract class Cursor implements Iterable> * row). */ public void beforeFirst() { - reset(true); + reset(MOVE_FORWARD); } /** @@ -341,7 +346,7 @@ public abstract class Cursor implements Iterable> * row). */ public void afterLast() { - reset(false); + reset(MOVE_REVERSE); } /** @@ -352,7 +357,7 @@ public abstract class Cursor implements Iterable> throws IOException { if(getFirstPosition().equals(_curPos)) { - return !recheckPosition(false); + return !recheckPosition(MOVE_REVERSE); } return false; } @@ -365,7 +370,7 @@ public abstract class Cursor implements Iterable> throws IOException { if(getLastPosition().equals(_curPos)) { - return !recheckPosition(true); + return !recheckPosition(MOVE_FORWARD); } return false; } @@ -418,7 +423,7 @@ public abstract class Cursor implements Iterable> { return new Iterable>() { public Iterator> iterator() { - return new RowIterator(columnNames, false); + return new RowIterator(columnNames, MOVE_REVERSE); } }; } @@ -462,7 +467,7 @@ public abstract class Cursor implements Iterable> */ public Iterator> iterator(Collection columnNames) { - return new RowIterator(columnNames, true); + return new RowIterator(columnNames, MOVE_FORWARD); } /** @@ -492,7 +497,7 @@ public abstract class Cursor implements Iterable> public Map getNextRow(Collection columnNames) throws IOException { - return getAnotherRow(columnNames, true); + return getAnotherRow(columnNames, MOVE_FORWARD); } /** @@ -513,7 +518,7 @@ public abstract class Cursor implements Iterable> public Map getPreviousRow(Collection columnNames) throws IOException { - return getAnotherRow(columnNames, false); + return getAnotherRow(columnNames, MOVE_REVERSE); } @@ -543,7 +548,7 @@ public abstract class Cursor implements Iterable> public boolean moveToNextRow() throws IOException { - return moveToAnotherRow(true); + return moveToAnotherRow(MOVE_FORWARD); } /** @@ -554,7 +559,7 @@ public abstract class Cursor implements Iterable> public boolean moveToPreviousRow() throws IOException { - return moveToAnotherRow(false); + return moveToAnotherRow(MOVE_REVERSE); } /** @@ -783,7 +788,7 @@ public abstract class Cursor implements Iterable> public int moveNextRows(int numRows) throws IOException { - return moveSomeRows(numRows, true); + return moveSomeRows(numRows, MOVE_FORWARD); } /** @@ -793,7 +798,7 @@ public abstract class Cursor implements Iterable> public int movePreviousRows(int numRows) throws IOException { - return moveSomeRows(numRows, false); + return moveSomeRows(numRows, MOVE_REVERSE); } /** @@ -1244,7 +1249,8 @@ public abstract class Cursor implements Iterable> * cursor logic from value storage. */ private abstract class IndexDirHandler extends DirHandler { - public abstract Index.Entry getAnotherEntry(); + public abstract Index.Entry getAnotherEntry() + throws IOException; } /** @@ -1260,7 +1266,7 @@ public abstract class Cursor implements Iterable> return getLastPosition(); } @Override - public Index.Entry getAnotherEntry() { + public Index.Entry getAnotherEntry() throws IOException { return _entryCursor.getNextEntry(); } } @@ -1278,7 +1284,7 @@ public abstract class Cursor implements Iterable> return getFirstPosition(); } @Override - public Index.Entry getAnotherEntry() { + public Index.Entry getAnotherEntry() throws IOException { return _entryCursor.getPreviousEntry(); } } diff --git a/src/java/com/healthmarketscience/jackcess/UsageMap.java b/src/java/com/healthmarketscience/jackcess/UsageMap.java index 9b286e6..8e40f4d 100644 --- a/src/java/com/healthmarketscience/jackcess/UsageMap.java +++ b/src/java/com/healthmarketscience/jackcess/UsageMap.java @@ -769,7 +769,7 @@ public class UsageMap * {@link RowId#LAST_PAGE_NUMBER} otherwise */ public int getNextPage() { - return getAnotherPage(true); + return getAnotherPage(Cursor.MOVE_FORWARD); } /** @@ -777,7 +777,7 @@ public class UsageMap * {@link RowId#FIRST_PAGE_NUMBER} otherwise */ public int getPreviousPage() { - return getAnotherPage(false); + return getAnotherPage(Cursor.MOVE_REVERSE); } /** @@ -815,7 +815,7 @@ public class UsageMap * page in the map */ public void beforeFirst() { - reset(true); + reset(Cursor.MOVE_FORWARD); } /** @@ -823,7 +823,7 @@ public class UsageMap * last page in the map */ public void afterLast() { - reset(false); + reset(Cursor.MOVE_REVERSE); } /** -- 2.39.5