From: James Ahlborn Date: Fri, 15 Mar 2013 23:44:44 +0000 (+0000) Subject: add RuntimeException wrapper for IOException X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3a62a7937de11bd539aed54075667b64d65eb2e6;p=jackcess.git 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 --- 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 * 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 reverseIterable(); @@ -141,7 +141,7 @@ public interface Cursor extends Iterable * 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 reverseIterable( @@ -152,7 +152,7 @@ public interface Cursor extends Iterable * 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 iterator(); @@ -162,7 +162,7 @@ public interface Cursor extends Iterable * 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 iterable( @@ -175,7 +175,7 @@ public interface Cursor extends Iterable * 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 columnMatchIterable( @@ -188,7 +188,7 @@ public interface Cursor extends Iterable * 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 columnMatchIterable( @@ -201,7 +201,7 @@ public interface Cursor extends Iterable * 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 rowMatchIterable( @@ -214,7 +214,7 @@ public interface Cursor extends Iterable * 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 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, 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 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 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 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 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 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 iterator(Collection 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 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 Iterator columnMatchIterator( @@ -516,7 +517,7 @@ public abstract class CursorImpl implements Cursor * 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 + * @throws RuntimeIOException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ public Iterator 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 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 Iterator rowMatchIterator( @@ -574,7 +575,7 @@ public abstract class CursorImpl implements Cursor * 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 + * @throws RuntimeIOException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ public Iterator 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 * 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 * @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 findRowsIterable(Map 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 findRowsIterable(