From: James Ahlborn Date: Tue, 5 Mar 2013 02:14:57 +0000 (+0000) Subject: shuffle some default instances X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=83db63185e3757c072138305e0a8bcd516f5c2ac;p=jackcess.git shuffle some default instances git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-2@673 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/TODO.txt b/TODO.txt index 592adae..ba829a4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -33,3 +33,4 @@ Refactor goals: - tweak lookup apis (specify column vs column name) - separate classes into more packages (api,builder,util,impl) - remove debug log blocks +- add Row interface diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java index 2b87af4..84a75fb 100644 --- a/src/java/com/healthmarketscience/jackcess/Database.java +++ b/src/java/com/healthmarketscience/jackcess/Database.java @@ -109,36 +109,6 @@ public interface Database extends Iterable, Closeable, Flushable public static final String FK_ENFORCE_PROPERTY = "com.healthmarketscience.jackcess.enforceForeignKeys"; - /** - * default error handler used if none provided (just rethrows exception) - * @usage _general_field_ - */ - public static final ErrorHandler DEFAULT_ERROR_HANDLER = new ErrorHandler() { - public Object handleRowError(Column column, byte[] columnData, - Location location, Exception error) - throws IOException - { - // really can only be RuntimeException or IOException - if(error instanceof IOException) { - throw (IOException)error; - } - throw (RuntimeException)error; - } - }; - - /** - * default link resolver used if none provided - * @usage _general_field_ - */ - public static final LinkResolver DEFAULT_LINK_RESOLVER = new LinkResolver() { - public Database resolveLinkedDatabase(Database linkerDb, - String linkeeFileName) - throws IOException - { - return DatabaseBuilder.open(new File(linkeeFileName)); - } - }; - /** * Enum which indicates which version of Access created the database. * @usage _general_class_ @@ -297,7 +267,7 @@ public interface Database extends Iterable
, Closeable, Flushable /** * Sets a new ErrorHandler. If {@code null}, resets to the - * {@link #DEFAULT_ERROR_HANDLER}. + * {@link ErrorHandler#DEFAULT}. * @usage _intermediate_method_ */ public void setErrorHandler(ErrorHandler newErrorHandler); @@ -311,7 +281,7 @@ public interface Database extends Iterable
, Closeable, Flushable /** * Sets a new LinkResolver. If {@code null}, resets to the - * {@link #DEFAULT_LINK_RESOLVER}. + * {@link LinkResolver#DEFAULT}. * @usage _intermediate_method_ */ public void setLinkResolver(LinkResolver newLinkResolver); diff --git a/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java b/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java index 4da11f5..b040eb9 100644 --- a/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java +++ b/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java @@ -596,8 +596,7 @@ public class DatabaseImpl implements Database } public ErrorHandler getErrorHandler() { - return((_dbErrorHandler != null) ? _dbErrorHandler : - DEFAULT_ERROR_HANDLER); + return((_dbErrorHandler != null) ? _dbErrorHandler : ErrorHandler.DEFAULT); } public void setErrorHandler(ErrorHandler newErrorHandler) { @@ -605,7 +604,7 @@ public class DatabaseImpl implements Database } public LinkResolver getLinkResolver() { - return((_linkResolver != null) ? _linkResolver : DEFAULT_LINK_RESOLVER); + return((_linkResolver != null) ? _linkResolver : LinkResolver.DEFAULT); } public void setLinkResolver(LinkResolver newLinkResolver) { diff --git a/src/java/com/healthmarketscience/jackcess/ErrorHandler.java b/src/java/com/healthmarketscience/jackcess/ErrorHandler.java index 052dac1..62960f4 100644 --- a/src/java/com/healthmarketscience/jackcess/ErrorHandler.java +++ b/src/java/com/healthmarketscience/jackcess/ErrorHandler.java @@ -33,13 +33,29 @@ import java.io.IOException; * Handler for errors encountered while reading a column of row data from a * Table. An instance of this class may be configured at the Database, Table, * or Cursor level to customize error handling as desired. The default - * instance used is {@link Database#DEFAULT_ERROR_HANDLER}, which just - * rethrows any exceptions encountered. + * instance used is {@link #DEFAULT}, which just rethrows any exceptions + * encountered. * * @author James Ahlborn */ public interface ErrorHandler { + /** + * default error handler used if none provided (just rethrows exception) + * @usage _general_field_ + */ + public static final ErrorHandler DEFAULT = new ErrorHandler() { + public Object handleRowError(Column column, byte[] columnData, + Location location, Exception error) + throws IOException + { + // really can only be RuntimeException or IOException + if(error instanceof IOException) { + throw (IOException)error; + } + throw (RuntimeException)error; + } + }; /** * Handles an error encountered while reading a column of data from a Table diff --git a/src/java/com/healthmarketscience/jackcess/LinkResolver.java b/src/java/com/healthmarketscience/jackcess/LinkResolver.java index 3ce7315..d51c919 100644 --- a/src/java/com/healthmarketscience/jackcess/LinkResolver.java +++ b/src/java/com/healthmarketscience/jackcess/LinkResolver.java @@ -19,6 +19,7 @@ USA package com.healthmarketscience.jackcess; +import java.io.File; import java.io.IOException; /** @@ -28,6 +29,19 @@ import java.io.IOException; */ public interface LinkResolver { + /** + * default link resolver used if none provided + * @usage _general_field_ + */ + public static final LinkResolver DEFAULT = new LinkResolver() { + public Database resolveLinkedDatabase(Database linkerDb, + String linkeeFileName) + throws IOException + { + return DatabaseBuilder.open(new File(linkeeFileName)); + } + }; + /** * Returns the appropriate Database instance for the linkeeFileName from the * given linkerDb.