summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2013-03-15 23:44:44 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2013-03-15 23:44:44 +0000
commit3a62a7937de11bd539aed54075667b64d65eb2e6 (patch)
tree773461fef761d878622cf706f5ae14ad7be7a35d
parent274737e40f7fe274a2a2eacc51507bb31cd5b06f (diff)
downloadjackcess-3a62a7937de11bd539aed54075667b64d65eb2e6.tar.gz
jackcess-3a62a7937de11bd539aed54075667b64d65eb2e6.zip
add RuntimeException wrapper for IOException
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-2@690 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--TODO.txt1
-rw-r--r--src/java/com/healthmarketscience/jackcess/Cursor.java16
-rw-r--r--src/java/com/healthmarketscience/jackcess/Database.java2
-rw-r--r--src/java/com/healthmarketscience/jackcess/IndexCursor.java8
-rw-r--r--src/java/com/healthmarketscience/jackcess/RuntimeIOException.java42
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java17
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java5
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java3
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/TableImpl.java2
-rw-r--r--src/java/com/healthmarketscience/jackcess/util/CaseInsensitiveColumnMatcher.java5
-rw-r--r--src/java/com/healthmarketscience/jackcess/util/Joiner.java4
11 files changed, 76 insertions, 29 deletions
diff --git a/TODO.txt b/TODO.txt
index a757bda..9ded7f1 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -43,3 +43,4 @@ Refactor goals:
- enhance public api classes
- add @usage tags to util classes
- add unit tests for Row update/delete methods, add/update *FromMap methods
+- add reason to unsupop throws for indexes
diff --git a/src/java/com/healthmarketscience/jackcess/Cursor.java b/src/java/com/healthmarketscience/jackcess/Cursor.java
index 55efb06..4cdce1d 100644
--- a/src/java/com/healthmarketscience/jackcess/Cursor.java
+++ b/src/java/com/healthmarketscience/jackcess/Cursor.java
@@ -130,7 +130,7 @@ public interface Cursor extends Iterable<Row>
* 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> reverseIterable();
@@ -141,7 +141,7 @@ public interface Cursor extends Iterable<Row>
* 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> reverseIterable(
@@ -152,7 +152,7 @@ public interface Cursor extends Iterable<Row>
* Iterator which will iterate through all the rows of this table. 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> iterator();
@@ -162,7 +162,7 @@ public interface Cursor extends Iterable<Row>
* 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> iterable(
@@ -175,7 +175,7 @@ public interface Cursor extends Iterable<Row>
* 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> columnMatchIterable(
@@ -188,7 +188,7 @@ public interface Cursor extends Iterable<Row>
* 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> columnMatchIterable(
@@ -201,7 +201,7 @@ public interface Cursor extends Iterable<Row>
* 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> rowMatchIterable(
@@ -214,7 +214,7 @@ public interface Cursor extends Iterable<Row>
* 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
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> rowMatchIterable(
diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java
index 88701fc..0d3fe36 100644
--- a/src/java/com/healthmarketscience/jackcess/Database.java
+++ b/src/java/com/healthmarketscience/jackcess/Database.java
@@ -165,7 +165,7 @@ public interface Database extends Iterable<Table>, Closeable, Flushable
/**
* @return an unmodifiable Iterator of the user Tables in this Database.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
* @throws ConcurrentModificationException if a table is added to the
* database while an Iterator is in use.
diff --git a/src/java/com/healthmarketscience/jackcess/IndexCursor.java b/src/java/com/healthmarketscience/jackcess/IndexCursor.java
index ebf1362..6e1d0c9 100644
--- a/src/java/com/healthmarketscience/jackcess/IndexCursor.java
+++ b/src/java/com/healthmarketscience/jackcess/IndexCursor.java
@@ -70,7 +70,7 @@ public interface IndexCursor extends Cursor
/**
* Returns a modifiable Iterator which will iterate through all the rows of
* this table which match the given index entries.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> entryIterator(Object... entryValues);
@@ -79,7 +79,7 @@ public interface IndexCursor extends Cursor
* Returns a modifiable Iterator which will iterate through all the rows of
* this table which match the given index entries, returning only the given
* columns.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> entryIterator(
@@ -88,7 +88,7 @@ public interface IndexCursor extends Cursor
/**
* Returns an Iterable whose iterator() method returns the result of a call
* to {@link #entryIterator(Object...)}
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> entryIterable(Object... entryValues);
@@ -96,7 +96,7 @@ public interface IndexCursor extends Cursor
/**
* Returns an Iterable whose iterator() method returns the result of a call
* to {@link #entryIterator(Collection,Object...)}
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> entryIterable(
diff --git a/src/java/com/healthmarketscience/jackcess/RuntimeIOException.java b/src/java/com/healthmarketscience/jackcess/RuntimeIOException.java
new file mode 100644
index 0000000..3ffc9e6
--- /dev/null
+++ b/src/java/com/healthmarketscience/jackcess/RuntimeIOException.java
@@ -0,0 +1,42 @@
+/*
+Copyright (c) 2013 James Ahlborn
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+USA
+*/
+
+package com.healthmarketscience.jackcess;
+
+import java.io.IOException;
+
+/**
+ * RuntimeException wrapper around an IOException
+ *
+ * @author James Ahlborn
+ */
+public class RuntimeIOException extends IllegalStateException
+{
+ private static final long serialVersionUID = 20130315L;
+
+ public RuntimeIOException(IOException e)
+ {
+ this(((e != null) ? e.getMessage() : null), e);
+ }
+
+ public RuntimeIOException(String msg, IOException e)
+ {
+ super(msg, e);
+ }
+}
diff --git a/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java b/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java
index 77e4798..9b09513 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java
@@ -43,6 +43,7 @@ import com.healthmarketscience.jackcess.util.ErrorHandler;
import com.healthmarketscience.jackcess.util.ColumnMatcher;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.Row;
+import com.healthmarketscience.jackcess.RuntimeIOException;
import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.util.SimpleColumnMatcher;
@@ -448,7 +449,7 @@ public abstract class CursorImpl implements Cursor
* 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 <code>getNextRow</code>.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> iterator(Collection<String> columnNames)
@@ -474,7 +475,7 @@ public abstract class CursorImpl implements Cursor
* match the given column pattern. Use of the Iterator follows the same
* restrictions as a call to <code>getNextRow</code>. See
* {@link #findFirstRow(Column,Object)} for details on the columnPattern.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> columnMatchIterator(
@@ -516,7 +517,7 @@ public abstract class CursorImpl implements Cursor
* the Iterator follows the same restrictions as a call to
* <code>getNextRow</code>. See {@link #findFirstRow(Column,Object)} for
* details on the columnPattern.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> columnMatchIterator(
@@ -546,7 +547,7 @@ public abstract class CursorImpl implements Cursor
* match the given row pattern. Use of the Iterator follows the same
* restrictions as a call to <code>getNextRow</code>. See
* {@link #findFirstRow(Map)} for details on the rowPattern.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> rowMatchIterator(
@@ -574,7 +575,7 @@ public abstract class CursorImpl implements Cursor
* the Iterator follows the same restrictions as a call to
* <code>getNextRow</code>. See {@link #findFirstRow(Map)} for details on
* the rowPattern.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterator<Row> rowMatchIterator(
@@ -1017,7 +1018,7 @@ public abstract class CursorImpl implements Cursor
_hasNext = findNext();
_validRow = _hasNext;
} catch(IOException e) {
- throw new IllegalStateException(e);
+ throw new RuntimeIOException(e);
}
}
return _hasNext;
@@ -1032,7 +1033,7 @@ public abstract class CursorImpl implements Cursor
_hasNext = null;
return rtn;
} catch(IOException e) {
- throw new IllegalStateException(e);
+ throw new RuntimeIOException(e);
}
}
@@ -1042,7 +1043,7 @@ public abstract class CursorImpl implements Cursor
deleteCurrentRow();
_validRow = false;
} catch(IOException e) {
- throw new IllegalStateException(e);
+ throw new RuntimeIOException(e);
}
} else {
throw new IllegalStateException("Not at valid row");
diff --git a/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
index 2083c47..5c193b3 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
@@ -67,6 +67,7 @@ import com.healthmarketscience.jackcess.IndexCursor;
import com.healthmarketscience.jackcess.PropertyMap;
import com.healthmarketscience.jackcess.Relationship;
import com.healthmarketscience.jackcess.Row;
+import com.healthmarketscience.jackcess.RuntimeIOException;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.query.Query;
import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
@@ -1753,7 +1754,7 @@ public class DatabaseImpl implements Database
try {
_tableNameIter = getTableNames().iterator();
} catch(IOException e) {
- throw new IllegalStateException(e);
+ throw new RuntimeIOException(e);
}
}
@@ -1772,7 +1773,7 @@ public class DatabaseImpl implements Database
try {
return getTable(_tableNameIter.next());
} catch(IOException e) {
- throw new IllegalStateException(e);
+ throw new RuntimeIOException(e);
}
}
}
diff --git a/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java b/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
index f6c49e3..e477327 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
@@ -30,6 +30,7 @@ import java.util.Set;
import com.healthmarketscience.jackcess.IndexCursor;
import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.RowId;
+import com.healthmarketscience.jackcess.RuntimeIOException;
import com.healthmarketscience.jackcess.impl.TableImpl.RowState;
import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
import com.healthmarketscience.jackcess.util.ColumnMatcher;
@@ -537,7 +538,7 @@ public class IndexCursorImpl extends CursorImpl implements IndexCursor
_hasNext = findFirstRowByEntryImpl(rowValues, true);
_validRow = _hasNext;
} catch(IOException e) {
- throw new IllegalStateException(e);
+ throw new RuntimeIOException(e);
}
}
diff --git a/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java
index 140f5d4..fb9900c 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java
@@ -880,7 +880,7 @@ public class TableImpl implements Table
* Iterator which will iterate through all the rows of this table. Use of
* the Iterator follows the same restrictions as a call to
* <code>getNextRow</code>.
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
* @usage _general_method_
*/
diff --git a/src/java/com/healthmarketscience/jackcess/util/CaseInsensitiveColumnMatcher.java b/src/java/com/healthmarketscience/jackcess/util/CaseInsensitiveColumnMatcher.java
index 2779cbb..3b5170b 100644
--- a/src/java/com/healthmarketscience/jackcess/util/CaseInsensitiveColumnMatcher.java
+++ b/src/java/com/healthmarketscience/jackcess/util/CaseInsensitiveColumnMatcher.java
@@ -22,6 +22,7 @@ package com.healthmarketscience.jackcess.util;
import java.io.IOException;
+import com.healthmarketscience.jackcess.RuntimeIOException;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.impl.ColumnImpl;
@@ -59,8 +60,8 @@ public class CaseInsensitiveColumnMatcher implements ColumnMatcher {
((cs1 != null) && (cs2 != null) &&
cs1.toString().equalsIgnoreCase(cs2.toString())));
} catch(IOException e) {
- throw new IllegalStateException("Could not read column " + columnName
- + " value", e);
+ throw new RuntimeIOException("Could not read column " + columnName
+ + " value", e);
}
}
diff --git a/src/java/com/healthmarketscience/jackcess/util/Joiner.java b/src/java/com/healthmarketscience/jackcess/util/Joiner.java
index df11fd3..d43ff1b 100644
--- a/src/java/com/healthmarketscience/jackcess/util/Joiner.java
+++ b/src/java/com/healthmarketscience/jackcess/util/Joiner.java
@@ -219,7 +219,7 @@ public class Joiner
*
* @param fromRow row from the "from" table (which must include the relevant
* columns for this join relationship)
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> findRowsIterable(Map<String,?> fromRow)
@@ -234,7 +234,7 @@ public class Joiner
* @param fromRow row from the "from" table (which must include the relevant
* columns for this join relationship)
* @param columnNames desired columns in the from table row
- * @throws IllegalStateException if an IOException is thrown by one of the
+ * @throws RuntimeIOException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
public Iterable<Row> findRowsIterable(