diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2013-03-05 01:45:45 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2013-03-05 01:45:45 +0000 |
commit | 358c699c72cea34ee966f981abbb7f67c46188ff (patch) | |
tree | 17d3a6e3610861249007a51bb78a32bfaec7c436 /src | |
parent | 71c3508b8ac2b56698bfe247b95eae5a1f390701 (diff) | |
download | jackcess-358c699c72cea34ee966f981abbb7f67c46188ff.tar.gz jackcess-358c699c72cea34ee966f981abbb7f67c46188ff.zip |
make abstract classes interfaces instead
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-2@672 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
9 files changed, 128 insertions, 203 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index 76fcbd9..f05b58d 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -30,7 +30,7 @@ import com.healthmarketscience.jackcess.complex.ComplexValue; * * @author James Ahlborn */ -public abstract class Column +public interface Column { /** * Meaningless placeholder object for inserting values in an autonumber @@ -50,99 +50,99 @@ public abstract class Column /** * @usage _general_method_ */ - public abstract Table getTable(); + public Table getTable(); /** * @usage _general_method_ */ - public abstract Database getDatabase(); + public Database getDatabase(); /** * @usage _general_method_ */ - public abstract String getName(); + public String getName(); /** * @usage _advanced_method_ */ - public abstract boolean isVariableLength(); + public boolean isVariableLength(); /** * @usage _general_method_ */ - public abstract boolean isAutoNumber(); + public boolean isAutoNumber(); /** * @usage _advanced_method_ */ - public abstract int getColumnIndex(); + public int getColumnIndex(); /** * @usage _general_method_ */ - public abstract DataType getType(); + public DataType getType(); /** * @usage _general_method_ */ - public abstract int getSQLType() throws SQLException; + public int getSQLType() throws SQLException; /** * @usage _general_method_ */ - public abstract boolean isCompressedUnicode(); + public boolean isCompressedUnicode(); /** * @usage _general_method_ */ - public abstract byte getPrecision(); + public byte getPrecision(); /** * @usage _general_method_ */ - public abstract byte getScale(); + public byte getScale(); /** * @usage _general_method_ */ - public abstract short getLength(); + public short getLength(); /** * @usage _general_method_ */ - public abstract short getLengthInUnits(); + public short getLengthInUnits(); /** * Whether or not this column is "append only" (its history is tracked by a * separate version history column). * @usage _general_method_ */ - public abstract boolean isAppendOnly(); + public boolean isAppendOnly(); /** * Returns whether or not this is a hyperlink column (only possible for * columns of type MEMO). * @usage _general_method_ */ - public abstract boolean isHyperlink(); + public boolean isHyperlink(); /** * Returns extended functionality for "complex" columns. * @usage _general_method_ */ - public abstract ComplexColumnInfo<? extends ComplexValue> getComplexInfo(); + public ComplexColumnInfo<? extends ComplexValue> getComplexInfo(); /** * @return the properties for this column * @usage _general_method_ */ - public abstract PropertyMap getProperties() throws IOException; + public PropertyMap getProperties() throws IOException; - public abstract Object setRowValue(Object[] rowArray, Object value); + public Object setRowValue(Object[] rowArray, Object value); - public abstract Object setRowValue(Map<String,Object> rowMap, Object value); + public Object setRowValue(Map<String,Object> rowMap, Object value); - public abstract Object getRowValue(Object[] rowArray); + public Object getRowValue(Object[] rowArray); - public abstract Object getRowValue(Map<String,?> rowMap); + public Object getRowValue(Map<String,?> rowMap); } diff --git a/src/java/com/healthmarketscience/jackcess/ColumnImpl.java b/src/java/com/healthmarketscience/jackcess/ColumnImpl.java index cf824bb..d6c7a74 100644 --- a/src/java/com/healthmarketscience/jackcess/ColumnImpl.java +++ b/src/java/com/healthmarketscience/jackcess/ColumnImpl.java @@ -47,7 +47,6 @@ import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.TimeZone; import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -67,7 +66,7 @@ import org.apache.commons.logging.LogFactory; * @author Tim McCune * @usage _general_class_ */ -public class ColumnImpl extends Column implements Comparable<ColumnImpl> { +public class ColumnImpl implements Column, Comparable<ColumnImpl> { private static final Log LOG = LogFactory.getLog(ColumnImpl.class); @@ -309,12 +308,10 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { } } - @Override public TableImpl getTable() { return _table; } - @Override public DatabaseImpl getDatabase() { return getTable().getDatabase(); } @@ -333,7 +330,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { return getDatabase().getPageChannel(); } - @Override public String getName() { return _name; } @@ -345,7 +341,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _name = name; } - @Override public boolean isVariableLength() { return _variableLength; } @@ -357,7 +352,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _variableLength = variableLength; } - @Override public boolean isAutoNumber() { return _autoNumber; } @@ -384,7 +378,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _columnNumber = newColumnNumber; } - @Override public int getColumnIndex() { return _columnIndex; } @@ -423,12 +416,10 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { } } - @Override public DataType getType() { return _type; } - @Override public int getSQLType() throws SQLException { return _type.getSQLType(); } @@ -447,7 +438,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { setType(DataType.fromSQLType(type, lengthInUnits)); } - @Override public boolean isCompressedUnicode() { return _textInfo._compressedUnicode; } @@ -460,7 +450,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _textInfo._compressedUnicode = newCompessedUnicode; } - @Override public byte getPrecision() { return _numericInfo._precision; } @@ -473,7 +462,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _numericInfo._precision = newPrecision; } - @Override public byte getScale() { return _numericInfo._scale; } @@ -515,7 +503,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _columnLength = length; } - @Override public short getLength() { return _columnLength; } @@ -527,7 +514,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { setLength((short)getType().fromUnitSize(unitLength)); } - @Override public short getLengthInUnits() { return (short)getType().toUnitSize(getLength()); } @@ -568,7 +554,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { return getDatabase().getCalendar(); } - @Override public boolean isAppendOnly() { return (getVersionHistoryColumn() != null); } @@ -590,7 +575,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _textInfo._versionHistoryCol = versionHistoryCol; } - @Override public boolean isHyperlink() { return _textInfo._hyperlink; } @@ -603,7 +587,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { _textInfo._hyperlink = hyperlink; } - @Override public ComplexColumnInfo<? extends ComplexValue> getComplexInfo() { return _complexInfo; } @@ -657,7 +640,6 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { return _autoNumberGenerator; } - @Override public PropertyMap getProperties() throws IOException { if(_props == null) { _props = getTable().getPropertyMaps().get(getName()); @@ -753,24 +735,20 @@ public class ColumnImpl extends Column implements Comparable<ColumnImpl> { } } - @Override public Object setRowValue(Object[] rowArray, Object value) { rowArray[_columnIndex] = value; return value; } - @Override public Object setRowValue(Map<String,Object> rowMap, Object value) { rowMap.put(_name, value); return value; } - @Override public Object getRowValue(Object[] rowArray) { return rowArray[_columnIndex]; } - @Override public Object getRowValue(Map<String,?> rowMap) { return rowMap.get(_name); } diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java index 7857a87..2b87af4 100644 --- a/src/java/com/healthmarketscience/jackcess/Database.java +++ b/src/java/com/healthmarketscience/jackcess/Database.java @@ -34,12 +34,13 @@ import com.healthmarketscience.jackcess.query.Query; /** * An Access database instance. A new instance can be instantiated by opening - * an existing database file ({@link #open}) or creating a new database file - * ({@link #create}) (for more advanced opening/creating using {@link - * DatabaseBuilder}). Once a Database has been opened, you can interact with - * the data via the relevant {@link Table}. When a Database instance is no - * longer useful, it should <b>always</b> be closed ({@link #close}) to avoid - * corruption. + * an existing database file ({@link DatabaseBuilder#open(File)}) or creating + * a new database file ({@link DatabaseBuilder#create(FileFormat,File)}) (for + * more advanced opening/creating use {@link DatabaseBuilder}). Once a + * Database has been opened, you can interact with the data via the relevant + * {@link Table}. When a Database instance is no longer useful, it should + * <b>always</b> be closed ({@link + * #close}) to avoid corruption. * <p> * Note, Database instances (and all the related objects) are <i>not</i> * thread-safe. However, separate Database instances (and their respective @@ -48,7 +49,7 @@ import com.healthmarketscience.jackcess.query.Query; * @author James Ahlborn * @usage _general_class_ */ -public abstract class Database implements Iterable<Table>, Closeable, Flushable +public interface Database extends Iterable<Table>, Closeable, Flushable { /** default value for the auto-sync value ({@code true}). this is slower, * but leaves more chance of a useable database in the face of failures. @@ -134,7 +135,7 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable String linkeeFileName) throws IOException { - return Database.open(new File(linkeeFileName)); + return DatabaseBuilder.open(new File(linkeeFileName)); } }; @@ -169,45 +170,15 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable } /** - * Open an existing Database. If the existing file is not writeable, the - * file will be opened read-only. Auto-syncing is enabled for the returned - * Database. - * - * @param mdbFile File containing the database - * - * @see DatabaseBuilder for more flexible Database opening - * @usage _general_method_ - */ - public static Database open(File mdbFile) throws IOException { - return new DatabaseBuilder(mdbFile).open(); - } - - /** - * Create a new Database for the given fileFormat - * - * @param fileFormat version of new database. - * @param mdbFile Location to write the new database to. <b>If this file - * already exists, it will be overwritten.</b> - * - * @see DatabaseBuilder for more flexible Database creation - * @usage _general_method_ - */ - public static Database create(FileFormat fileFormat, File mdbFile) - throws IOException - { - return new DatabaseBuilder(mdbFile).setFileFormat(fileFormat).create(); - } - - /** * Returns the File underlying this Database */ - public abstract File getFile(); + public File getFile(); /** * @return The names of all of the user tables (String) * @usage _general_method_ */ - public abstract Set<String> getTableNames() throws IOException; + public Set<String> getTableNames() throws IOException; /** * @return The names of all of the system tables (String). Note, in order @@ -216,7 +187,7 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable * directly!</i>. * @usage _intermediate_method_ */ - public abstract Set<String> getSystemTableNames() throws IOException; + public Set<String> getSystemTableNames() throws IOException; /** * @return an unmodifiable Iterator of the user Tables in this Database. @@ -226,27 +197,27 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable * database while an Iterator is in use. * @usage _general_method_ */ - public abstract Iterator<Table> iterator(); + public Iterator<Table> iterator(); /** * @param name Table name * @return The table, or null if it doesn't exist * @usage _general_method_ */ - public abstract Table getTable(String name) throws IOException; + public Table getTable(String name) throws IOException; /** * Finds all the relationships in the database between the given tables. * @usage _intermediate_method_ */ - public abstract List<Relationship> getRelationships(Table table1, Table table2) + public List<Relationship> getRelationships(Table table1, Table table2) throws IOException; /** * Finds all the queries in the database. * @usage _intermediate_method_ */ - public abstract List<Query> getQueries() throws IOException; + public List<Query> getQueries() throws IOException; /** * Returns a reference to <i>any</i> available table in this access @@ -261,38 +232,38 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable * @return The table, or {@code null} if it doesn't exist * @usage _intermediate_method_ */ - public abstract Table getSystemTable(String tableName) throws IOException; + public Table getSystemTable(String tableName) throws IOException; /** * @return the core properties for the database * @usage _general_method_ */ - public abstract PropertyMap getDatabaseProperties() throws IOException; + public PropertyMap getDatabaseProperties() throws IOException; /** * @return the summary properties for the database * @usage _general_method_ */ - public abstract PropertyMap getSummaryProperties() throws IOException; + public PropertyMap getSummaryProperties() throws IOException; /** * @return the user-defined properties for the database * @usage _general_method_ */ - public abstract PropertyMap getUserDefinedProperties() throws IOException; + public PropertyMap getUserDefinedProperties() throws IOException; /** * @return the current database password, or {@code null} if none set. * @usage _general_method_ */ - public abstract String getDatabasePassword() throws IOException; + public String getDatabasePassword() throws IOException; /** * Flushes any current changes to the database file (and any linked * databases) to disk. * @usage _general_method_ */ - public abstract void flush() throws IOException; + public void flush() throws IOException; /** * Close the database file (and any linked databases). A Database @@ -302,19 +273,19 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable * OutputStream or jdbc Connection). * @usage _general_method_ */ - public abstract void close() throws IOException; + public void close() throws IOException; /** * @return The system catalog table * @usage _advanced_method_ */ - public abstract Table getSystemCatalog(); + public Table getSystemCatalog(); /** * @return The system Access Control Entries table (loaded on demand) * @usage _advanced_method_ */ - public abstract Table getAccessControlEntries() throws IOException; + public Table getAccessControlEntries() throws IOException; /** * Gets the currently configured ErrorHandler (always non-{@code null}). @@ -322,28 +293,28 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable * Cursor level. * @usage _intermediate_method_ */ - public abstract ErrorHandler getErrorHandler(); + public ErrorHandler getErrorHandler(); /** * Sets a new ErrorHandler. If {@code null}, resets to the * {@link #DEFAULT_ERROR_HANDLER}. * @usage _intermediate_method_ */ - public abstract void setErrorHandler(ErrorHandler newErrorHandler); + public void setErrorHandler(ErrorHandler newErrorHandler); /** * Gets the currently configured LinkResolver (always non-{@code null}). * This will be used to handle all linked database loading. * @usage _intermediate_method_ */ - public abstract LinkResolver getLinkResolver(); + public LinkResolver getLinkResolver(); /** * Sets a new LinkResolver. If {@code null}, resets to the * {@link #DEFAULT_LINK_RESOLVER}. * @usage _intermediate_method_ */ - public abstract void setLinkResolver(LinkResolver newLinkResolver); + public void setLinkResolver(LinkResolver newLinkResolver); /** * Returns an unmodifiable view of the currently loaded linked databases, @@ -351,57 +322,57 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable * information may be useful for implementing a LinkResolver. * @usage _intermediate_method_ */ - public abstract Map<String,Database> getLinkedDatabases(); + public Map<String,Database> getLinkedDatabases(); /** * Gets currently configured TimeZone (always non-{@code null}). * @usage _intermediate_method_ */ - public abstract TimeZone getTimeZone(); + public TimeZone getTimeZone(); /** * Sets a new TimeZone. If {@code null}, resets to the default value. * @usage _intermediate_method_ */ - public abstract void setTimeZone(TimeZone newTimeZone); + public void setTimeZone(TimeZone newTimeZone); /** * Gets currently configured Charset (always non-{@code null}). * @usage _intermediate_method_ */ - public abstract Charset getCharset(); + public Charset getCharset(); /** * Sets a new Charset. If {@code null}, resets to the default value. * @usage _intermediate_method_ */ - public abstract void setCharset(Charset newCharset); + public void setCharset(Charset newCharset); /** * Gets currently configured {@link Table.ColumnOrder} (always non-{@code * null}). * @usage _intermediate_method_ */ - public abstract Table.ColumnOrder getColumnOrder(); + public Table.ColumnOrder getColumnOrder(); /** * Sets a new Table.ColumnOrder. If {@code null}, resets to the default value. * @usage _intermediate_method_ */ - public abstract void setColumnOrder(Table.ColumnOrder newColumnOrder); + public void setColumnOrder(Table.ColumnOrder newColumnOrder); /** * Gets currently foreign-key enforcement policy. * @usage _intermediate_method_ */ - public abstract boolean isEnforceForeignKeys(); + public boolean isEnforceForeignKeys(); /** * Sets a new foreign-key enforcement policy. If {@code null}, resets to * the default value. * @usage _intermediate_method_ */ - public abstract void setEnforceForeignKeys(Boolean newEnforceForeignKeys); + public void setEnforceForeignKeys(Boolean newEnforceForeignKeys); /** * Returns the FileFormat of this database (which may involve inspecting the @@ -409,6 +380,6 @@ public abstract class Database implements Iterable<Table>, Closeable, Flushable * @throws IllegalStateException if the file format cannot be determined * @usage _general_method_ */ - public abstract FileFormat getFileFormat() throws IOException; + public FileFormat getFileFormat() throws IOException; } diff --git a/src/java/com/healthmarketscience/jackcess/DatabaseBuilder.java b/src/java/com/healthmarketscience/jackcess/DatabaseBuilder.java index 0b43657..363a6b9 100644 --- a/src/java/com/healthmarketscience/jackcess/DatabaseBuilder.java +++ b/src/java/com/healthmarketscience/jackcess/DatabaseBuilder.java @@ -160,4 +160,36 @@ public class DatabaseBuilder return DatabaseImpl.create(_fileFormat, _mdbFile, _channel, _autoSync, _charset, _timeZone); } + + /** + * Open an existing Database. If the existing file is not writeable, the + * file will be opened read-only. Auto-syncing is enabled for the returned + * Database. + * + * @param mdbFile File containing the database + * + * @see DatabaseBuilder for more flexible Database opening + * @usage _general_method_ + */ + public static Database open(File mdbFile) throws IOException { + return new DatabaseBuilder(mdbFile).open(); + } + + /** + * Create a new Database for the given fileFormat + * + * @param fileFormat version of new database. + * @param mdbFile Location to write the new database to. <b>If this file + * already exists, it will be overwritten.</b> + * + * @see DatabaseBuilder for more flexible Database creation + * @usage _general_method_ + */ + public static Database create(Database.FileFormat fileFormat, File mdbFile) + throws IOException + { + return new DatabaseBuilder(mdbFile).setFileFormat(fileFormat).create(); + } + + } diff --git a/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java b/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java index 2f257e5..4da11f5 100644 --- a/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java +++ b/src/java/com/healthmarketscience/jackcess/DatabaseImpl.java @@ -67,7 +67,7 @@ import org.apache.commons.logging.LogFactory; * @author Tim McCune * @usage _general_class_ */ -public class DatabaseImpl extends Database +public class DatabaseImpl implements Database { private static final Log LOG = LogFactory.getLog(DatabaseImpl.class); @@ -546,7 +546,6 @@ public class DatabaseImpl extends Database readSystemCatalog(); } - @Override public File getFile() { return _file; } @@ -565,12 +564,10 @@ public class DatabaseImpl extends Database return _format; } - @Override public TableImpl getSystemCatalog() { return _systemCatalog; } - @Override public TableImpl getAccessControlEntries() throws IOException { if(_accessControlEntries == null) { _accessControlEntries = getSystemTable(TABLE_SYSTEM_ACES); @@ -598,39 +595,32 @@ public class DatabaseImpl extends Database return _complexCols; } - @Override public ErrorHandler getErrorHandler() { return((_dbErrorHandler != null) ? _dbErrorHandler : DEFAULT_ERROR_HANDLER); } - @Override public void setErrorHandler(ErrorHandler newErrorHandler) { _dbErrorHandler = newErrorHandler; } - @Override public LinkResolver getLinkResolver() { return((_linkResolver != null) ? _linkResolver : DEFAULT_LINK_RESOLVER); } - @Override public void setLinkResolver(LinkResolver newLinkResolver) { _linkResolver = newLinkResolver; } - @Override public Map<String,Database> getLinkedDatabases() { return ((_linkedDbs == null) ? Collections.<String,Database>emptyMap() : Collections.unmodifiableMap(_linkedDbs)); } - @Override public TimeZone getTimeZone() { return _timeZone; } - @Override public void setTimeZone(TimeZone newTimeZone) { if(newTimeZone == null) { newTimeZone = getDefaultTimeZone(); @@ -640,13 +630,11 @@ public class DatabaseImpl extends Database _calendar = null; } - @Override public Charset getCharset() { return _charset; } - @Override public void setCharset(Charset newCharset) { if(newCharset == null) { newCharset = getDefaultCharset(getFormat()); @@ -654,12 +642,10 @@ public class DatabaseImpl extends Database _charset = newCharset; } - @Override public Table.ColumnOrder getColumnOrder() { return _columnOrder; } - @Override public void setColumnOrder(Table.ColumnOrder newColumnOrder) { if(newColumnOrder == null) { newColumnOrder = getDefaultColumnOrder(); @@ -667,12 +653,10 @@ public class DatabaseImpl extends Database _columnOrder = newColumnOrder; } - @Override public boolean isEnforceForeignKeys() { return _enforceForeignKeys; } - @Override public void setEnforceForeignKeys(Boolean newEnforceForeignKeys) { if(newEnforceForeignKeys == null) { newEnforceForeignKeys = getDefaultEnforceForeignKeys(); @@ -709,7 +693,6 @@ public class DatabaseImpl extends Database return _propsHandler; } - @Override public FileFormat getFileFormat() throws IOException { if(_fileFormat == null) { @@ -856,7 +839,6 @@ public class DatabaseImpl extends Database } } - @Override public Set<String> getTableNames() throws IOException { if(_tableNames == null) { Set<String> tableNames = @@ -867,7 +849,6 @@ public class DatabaseImpl extends Database return _tableNames; } - @Override public Set<String> getSystemTableNames() throws IOException { Set<String> sysTableNames = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); @@ -875,12 +856,10 @@ public class DatabaseImpl extends Database return sysTableNames; } - @Override public Iterator<Table> iterator() { return new TableIterator(); } - @Override public TableImpl getTable(String name) throws IOException { return getTable(name, false); } @@ -1026,7 +1005,6 @@ public class DatabaseImpl extends Database addToAccessControlEntries(tdefPageNumber); } - @Override public List<Relationship> getRelationships(Table table1, Table table2) throws IOException { @@ -1070,7 +1048,6 @@ public class DatabaseImpl extends Database return relationships; } - @Override public List<Query> getQueries() throws IOException { // the queries table does not get loaded until first accessed @@ -1121,13 +1098,11 @@ public class DatabaseImpl extends Database return queries; } - @Override public TableImpl getSystemTable(String tableName) throws IOException { return getTable(tableName, true); } - @Override public PropertyMap getDatabaseProperties() throws IOException { if(_dbPropMaps == null) { _dbPropMaps = getPropertiesForDbObject(OBJECT_NAME_DB_PROPS); @@ -1135,7 +1110,6 @@ public class DatabaseImpl extends Database return _dbPropMaps.getDefault(); } - @Override public PropertyMap getSummaryProperties() throws IOException { if(_summaryPropMaps == null) { _summaryPropMaps = getPropertiesForDbObject(OBJECT_NAME_SUMMARY_PROPS); @@ -1143,7 +1117,6 @@ public class DatabaseImpl extends Database return _summaryPropMaps.getDefault(); } - @Override public PropertyMap getUserDefinedProperties() throws IOException { if(_userDefPropMaps == null) { _userDefPropMaps = getPropertiesForDbObject(OBJECT_NAME_USERDEF_PROPS); @@ -1193,7 +1166,6 @@ public class DatabaseImpl extends Database return readProperties(propsBytes, objectId); } - @Override public String getDatabasePassword() throws IOException { ByteBuffer buffer = takeSharedBuffer(); @@ -1435,7 +1407,6 @@ public class DatabaseImpl extends Database return Cursor.createCursor(table); } - @Override public void flush() throws IOException { if(_linkedDbs != null) { for(Database linkedDb : _linkedDbs.values()) { @@ -1445,7 +1416,6 @@ public class DatabaseImpl extends Database _pageChannel.flush(); } - @Override public void close() throws IOException { if(_linkedDbs != null) { for(Database linkedDb : _linkedDbs.values()) { diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java index cffd63b..4054c66 100644 --- a/src/java/com/healthmarketscience/jackcess/Index.java +++ b/src/java/com/healthmarketscience/jackcess/Index.java @@ -26,32 +26,32 @@ import java.util.List; * * @author James Ahlborn */ -public abstract class Index +public interface Index { - public abstract Table getTable(); + public Table getTable(); - public abstract String getName(); + public String getName(); - public abstract boolean isPrimaryKey(); + public boolean isPrimaryKey(); - public abstract boolean isForeignKey(); + public boolean isForeignKey(); /** * @return the Columns for this index (unmodifiable) */ - public abstract List<? extends Index.Column> getColumns(); + public List<? extends Index.Column> getColumns(); /** * @return the Index referenced by this Index's ForeignKeyReference (if it * has one), otherwise {@code null}. */ - public abstract Index getReferencedIndex() throws IOException; + public Index getReferencedIndex() throws IOException; /** * Whether or not {@code null} values are actually recorded in the index. */ - public abstract boolean shouldIgnoreNulls(); + public boolean shouldIgnoreNulls(); /** * Whether or not index entries must be unique. @@ -65,7 +65,7 @@ public abstract class Index * case <i>will violate</i> the unique constraint</li> * </ul> */ - public abstract boolean isUnique(); + public boolean isUnique(); /** * Information about a Column in an Index diff --git a/src/java/com/healthmarketscience/jackcess/IndexImpl.java b/src/java/com/healthmarketscience/jackcess/IndexImpl.java index 0cfe19e..8e85064 100644 --- a/src/java/com/healthmarketscience/jackcess/IndexImpl.java +++ b/src/java/com/healthmarketscience/jackcess/IndexImpl.java @@ -43,7 +43,7 @@ import org.apache.commons.logging.LogFactory; * * @author Tim McCune */ -public class IndexImpl extends Index implements Comparable<IndexImpl> +public class IndexImpl implements Index, Comparable<IndexImpl> { protected static final Log LOG = LogFactory.getLog(IndexImpl.class); @@ -115,7 +115,6 @@ public class IndexImpl extends Index implements Comparable<IndexImpl> return _data; } - @Override public TableImpl getTable() { return getIndexData().getTable(); } @@ -144,7 +143,6 @@ public class IndexImpl extends Index implements Comparable<IndexImpl> return getIndexData().getUniqueEntryCountOffset(); } - @Override public String getName() { return _name; } @@ -153,12 +151,10 @@ public class IndexImpl extends Index implements Comparable<IndexImpl> _name = name; } - @Override public boolean isPrimaryKey() { return _indexType == PRIMARY_KEY_INDEX_TYPE; } - @Override public boolean isForeignKey() { return _indexType == FOREIGN_KEY_INDEX_TYPE; } @@ -167,7 +163,6 @@ public class IndexImpl extends Index implements Comparable<IndexImpl> return _reference; } - @Override public IndexImpl getReferencedIndex() throws IOException { if(_reference == null) { @@ -211,17 +206,14 @@ public class IndexImpl extends Index implements Comparable<IndexImpl> return refIndex; } - @Override public boolean shouldIgnoreNulls() { return getIndexData().shouldIgnoreNulls(); } - @Override public boolean isUnique() { return getIndexData().isUnique(); } - @Override public List<IndexData.ColumnDescriptor> getColumns() { return getIndexData().getColumns(); } diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java index b0dcf7e..8244c17 100644 --- a/src/java/com/healthmarketscience/jackcess/Table.java +++ b/src/java/com/healthmarketscience/jackcess/Table.java @@ -28,7 +28,7 @@ import java.util.Map; * @author James Ahlborn * @usage _general_class_ */ -public abstract class Table implements Iterable<Map<String, Object>> +public interface Table extends Iterable<Map<String, Object>> { /** * enum which controls the ordering of the columns in a table. @@ -47,23 +47,23 @@ public abstract class Table implements Iterable<Map<String, Object>> * @return The name of the table * @usage _general_method_ */ - public abstract String getName(); + public String getName(); /** * Whether or not this table has been marked as hidden. * @usage _general_method_ */ - public abstract boolean isHidden(); + public boolean isHidden(); /** * @usage _general_method_ */ - public abstract int getColumnCount(); + public int getColumnCount(); /** * @usage _general_method_ */ - public abstract Database getDatabase(); + public Database getDatabase(); /** * Gets the currently configured ErrorHandler (always non-{@code null}). @@ -71,45 +71,45 @@ public abstract class Table implements Iterable<Map<String, Object>> * level. * @usage _intermediate_method_ */ - public abstract ErrorHandler getErrorHandler(); + public ErrorHandler getErrorHandler(); /** * Sets a new ErrorHandler. If {@code null}, resets to using the * ErrorHandler configured at the Database level. * @usage _intermediate_method_ */ - public abstract void setErrorHandler(ErrorHandler newErrorHandler); + public void setErrorHandler(ErrorHandler newErrorHandler); /** * @return All of the columns in this table (unmodifiable List) * @usage _general_method_ */ - public abstract List<? extends Column> getColumns(); + public List<? extends Column> getColumns(); /** * @return the column with the given name * @usage _general_method_ */ - public abstract Column getColumn(String name); + public Column getColumn(String name); /** * @return the properties for this table * @usage _general_method_ */ - public abstract PropertyMap getProperties() throws IOException; + public PropertyMap getProperties() throws IOException; /** * @return All of the Indexes on this table (unmodifiable List) * @usage _intermediate_method_ */ - public abstract List<? extends Index> getIndexes(); + public List<? extends Index> getIndexes(); /** * @return the index with the given name * @throws IllegalArgumentException if there is no index with the given name * @usage _intermediate_method_ */ - public abstract Index getIndex(String name); + public Index getIndex(String name); /** * @return the primary key index for this table @@ -117,7 +117,7 @@ public abstract class Table implements Iterable<Map<String, Object>> * table * @usage _intermediate_method_ */ - public abstract Index getPrimaryKeyIndex(); + public Index getPrimaryKeyIndex(); /** * @return the foreign key index joining this table to the given other table @@ -125,30 +125,30 @@ public abstract class Table implements Iterable<Map<String, Object>> * table and the given table * @usage _intermediate_method_ */ - public abstract Index getForeignKeyIndex(Table otherTable); + public Index getForeignKeyIndex(Table otherTable); /** * Converts a map of columnName -> columnValue to an array of row values * appropriate for a call to {@link #addRow(Object...)}. * @usage _general_method_ */ - public abstract Object[] asRow(Map<String,?> rowMap); + public Object[] asRow(Map<String,?> rowMap); /** * Converts a map of columnName -> columnValue to an array of row values * appropriate for a call to {@link #updateCurrentRow(Object...)}. * @usage _general_method_ */ - public abstract Object[] asUpdateRow(Map<String,?> rowMap); + public Object[] asUpdateRow(Map<String,?> rowMap); /** * Adds a single row to this table and writes it to disk. The values are * expected to be given in the order that the Columns are listed by the * {@link #getColumns} method. This is by default the storage order of the * Columns in the database, however this order can be influenced by setting - * the ColumnOrder via {@link DatabaseImpl#setColumnOrder} prior to opening the - * Table. The {@link #asRow} method can be used to easily convert a row Map into the - * appropriate row array for this Table. + * the ColumnOrder via {@link DatabaseImpl#setColumnOrder} prior to opening + * the Table. The {@link #asRow} method can be used to easily convert a row + * Map into the appropriate row array for this Table. * <p> * Note, if this table has an auto-number column, the value generated will be * put back into the given row array (assuming the given row array is at @@ -159,7 +159,7 @@ public abstract class Table implements Iterable<Map<String, Object>> * otherwise it will not be modified. * @usage _general_method_ */ - public abstract void addRow(Object... row) throws IOException; + public void addRow(Object... row) throws IOException; /** * Add multiple rows to this table, only writing to disk after all @@ -177,10 +177,10 @@ public abstract class Table implements Iterable<Map<String, Object>> * will not be modified. * @usage _general_method_ */ - public abstract void addRows(List<? extends Object[]> rows) throws IOException; + public void addRows(List<? extends Object[]> rows) throws IOException; /** * @usage _general_method_ */ - public abstract int getRowCount(); + public int getRowCount(); } diff --git a/src/java/com/healthmarketscience/jackcess/TableImpl.java b/src/java/com/healthmarketscience/jackcess/TableImpl.java index 1e6c838..9df4ce2 100644 --- a/src/java/com/healthmarketscience/jackcess/TableImpl.java +++ b/src/java/com/healthmarketscience/jackcess/TableImpl.java @@ -54,7 +54,7 @@ import org.apache.commons.logging.LogFactory; * @author Tim McCune * @usage _general_class_ */ -public class TableImpl extends Table +public class TableImpl implements Table { private static final Log LOG = LogFactory.getLog(TableImpl.class); @@ -206,12 +206,10 @@ public class TableImpl extends Table _fkEnforcer = new FKEnforcer(this); } - @Override public String getName() { return _name; } - @Override public boolean isHidden() { return((_flags & DatabaseImpl.HIDDEN_OBJECT_FLAG) != 0); } @@ -223,12 +221,10 @@ public class TableImpl extends Table return _maxColumnCount; } - @Override public int getColumnCount() { return _columns.size(); } - @Override public DatabaseImpl getDatabase() { return _database; } @@ -247,13 +243,11 @@ public class TableImpl extends Table return getDatabase().getPageChannel(); } - @Override public ErrorHandler getErrorHandler() { return((_tableErrorHandler != null) ? _tableErrorHandler : getDatabase().getErrorHandler()); } - @Override public void setErrorHandler(ErrorHandler newErrorHandler) { _tableErrorHandler = newErrorHandler; } @@ -301,12 +295,10 @@ public class TableImpl extends Table return _longValueBufferH; } - @Override public List<ColumnImpl> getColumns() { return Collections.unmodifiableList(_columns); } - @Override public ColumnImpl getColumn(String name) { for(ColumnImpl column : _columns) { if(column.getName().equalsIgnoreCase(name)) { @@ -341,7 +333,6 @@ public class TableImpl extends Table _autoNumColumns = getAutoNumberColumns(columns); } - @Override public PropertyMap getProperties() throws IOException { if(_props == null) { _props = getPropertyMaps().getDefault(); @@ -361,12 +352,10 @@ public class TableImpl extends Table return _propertyMaps; } - @Override public List<IndexImpl> getIndexes() { return Collections.unmodifiableList(_indexes); } - @Override public IndexImpl getIndex(String name) { for(IndexImpl index : _indexes) { if(index.getName().equalsIgnoreCase(name)) { @@ -377,7 +366,6 @@ public class TableImpl extends Table " does not exist on this table"); } - @Override public IndexImpl getPrimaryKeyIndex() { for(IndexImpl index : _indexes) { if(index.isPrimaryKey()) { @@ -388,7 +376,6 @@ public class TableImpl extends Table " does not have a primary key index"); } - @Override public IndexImpl getForeignKeyIndex(Table otherTable) { for(IndexImpl index : _indexes) { if(index.isForeignKey() && (index.getReference() != null) && @@ -1306,12 +1293,10 @@ public class TableImpl extends Table return ByteUtil.getUnsignedVarInt(buffer, getFormat().SIZE_NAME_LENGTH); } - @Override public Object[] asRow(Map<String,?> rowMap) { return asRow(rowMap, null); } - @Override public Object[] asUpdateRow(Map<String,?> rowMap) { return asRow(rowMap, Column.KEEP_VALUE); } @@ -1336,12 +1321,10 @@ public class TableImpl extends Table return row; } - @Override public void addRow(Object... row) throws IOException { addRows(Collections.singletonList(row), _singleRowBufferH); } - @Override public void addRows(List<? extends Object[]> rows) throws IOException { addRows(rows, _multiRowBufferH); } @@ -1872,7 +1855,6 @@ public class TableImpl extends Table } } - @Override public int getRowCount() { return _rowCount; } |