diff options
author | Dan Rollo <bhamail@users.sf.net> | 2010-04-07 02:14:41 +0000 |
---|---|---|
committer | Dan Rollo <bhamail@users.sf.net> | 2010-04-07 02:14:41 +0000 |
commit | 2c646fd415e0ec611407dc5e2aac79cac5af70c8 (patch) | |
tree | fc79d6f8065e877d3d7b87a4baee361e92772ba8 /src/java/com/healthmarketscience/jackcess/Database.java | |
parent | b288c8bae282f0023f3b257d36b0c6f82782fed4 (diff) | |
download | jackcess-2c646fd415e0ec611407dc5e2aac79cac5af70c8.tar.gz jackcess-2c646fd415e0ec611407dc5e2aac79cac5af70c8.zip |
Detect unsupported Jet and File formats and throw specific exceptions early.newformats
Remove old @todo comments and sys.outs.
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/newformats@456 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java/com/healthmarketscience/jackcess/Database.java')
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Database.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java index 5044de7..00ac78f 100644 --- a/src/java/com/healthmarketscience/jackcess/Database.java +++ b/src/java/com/healthmarketscience/jackcess/Database.java @@ -170,7 +170,12 @@ public class Database private static final String CAT_COL_FLAGS = "Flags"; /** System catalog column name of the properties column */ private static final String CAT_COL_PROPS = "LvProp"; - + + /** Error message prefix for unsupported file format. */ + static final String MSG_PREFIX_CREATE_UNSUPPORTED_FILE_FORMAT = "Unsupported file format: "; + /** Error message prefix for unsupported file format. */ + static final String MSG_PREFIX_OPEN_UNSUPPORTED_JET_FORMAT = "Unsupported Jet format: "; + public static enum FileFormat { V1997(null, JetFormat.VERSION_3), // v97 is not supported, so no empty template is provided @@ -439,6 +444,10 @@ public class Database boolean autoSync) throws IOException { + if (JetFormat.VERSION_3.equals(fileFormat.getJetFormat())) { + throw new IllegalArgumentException(MSG_PREFIX_CREATE_UNSUPPORTED_FILE_FORMAT + fileFormat); + } + FileChannel channel = openChannel(mdbFile, false); channel.truncate(0); channel.transferFrom(Channels.newChannel( @@ -478,6 +487,10 @@ public class Database throws IOException { _format = JetFormat.getFormat(channel); + if (JetFormat.VERSION_3.equals(_format)) { + channel.close(); + throw new IllegalArgumentException(MSG_PREFIX_OPEN_UNSUPPORTED_JET_FORMAT + _format); + } _fileFormat = fileFormat; _pageChannel = new PageChannel(channel, _format, autoSync); // note, it's slighly sketchy to pass ourselves along partially |