From 32a3d34bd2b74381877f905d3514708a97b91c3f Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Mon, 14 Mar 2011 02:25:21 +0000 Subject: [PATCH] add nominal support for access 2010, essentially read-only until the new text index sorting is worked out git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@525 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../healthmarketscience/jackcess/Column.java | 9 ++- .../jackcess/Database.java | 3 +- .../jackcess/JetFormat.java | 57 ++++++++++++++----- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index d22b61c..f578f76 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -93,15 +93,18 @@ public class Column implements Comparable { 25569L * (long)MILLISECONDS_PER_DAY; /** - * Long value (LVAL) type that indicates that the value is stored on the same page + * Long value (LVAL) type that indicates that the value is stored on the + * same page */ private static final byte LONG_VALUE_TYPE_THIS_PAGE = (byte) 0x80; /** - * Long value (LVAL) type that indicates that the value is stored on another page + * Long value (LVAL) type that indicates that the value is stored on another + * page */ private static final byte LONG_VALUE_TYPE_OTHER_PAGE = (byte) 0x40; /** - * Long value (LVAL) type that indicates that the value is stored on multiple other pages + * Long value (LVAL) type that indicates that the value is stored on + * multiple other pages */ private static final byte LONG_VALUE_TYPE_OTHER_PAGES = (byte) 0x00; diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java index 806c791..1c6e5b6 100644 --- a/src/java/com/healthmarketscience/jackcess/Database.java +++ b/src/java/com/healthmarketscience/jackcess/Database.java @@ -245,7 +245,8 @@ public class Database V1997(null, JetFormat.VERSION_3), V2000(RESOURCE_PATH + "empty.mdb", JetFormat.VERSION_4), V2003(RESOURCE_PATH + "empty2003.mdb", JetFormat.VERSION_4), - V2007(RESOURCE_PATH + "empty2007.accdb", JetFormat.VERSION_5, ".accdb"), + V2007(RESOURCE_PATH + "empty2007.accdb", JetFormat.VERSION_12, ".accdb"), + V2010(RESOURCE_PATH + "empty2010.accdb", JetFormat.VERSION_14, ".accdb"), MSISAM(null, JetFormat.VERSION_MSISAM, ".mny"); private final String _emptyFile; diff --git a/src/java/com/healthmarketscience/jackcess/JetFormat.java b/src/java/com/healthmarketscience/jackcess/JetFormat.java index d512659..08db1e0 100644 --- a/src/java/com/healthmarketscience/jackcess/JetFormat.java +++ b/src/java/com/healthmarketscience/jackcess/JetFormat.java @@ -60,8 +60,10 @@ public abstract class JetFormat { private static final byte CODE_VERSION_3 = 0x0; /** Version code for Jet version 4 */ private static final byte CODE_VERSION_4 = 0x1; - /** Version code for Jet version 5 */ - private static final byte CODE_VERSION_5 = 0x2; + /** Version code for Jet version 12 */ + private static final byte CODE_VERSION_12 = 0x2; + /** Version code for Jet version 14 */ + private static final byte CODE_VERSION_14 = 0x3; /** location of the engine name in the header */ static final int OFFSET_ENGINE_NAME = 0x4; @@ -116,9 +118,12 @@ public abstract class JetFormat { private static final Map POSSIBLE_VERSION_4 = new EnumMap(Database.FileFormat.class); - private static final Map POSSIBLE_VERSION_5 = + private static final Map POSSIBLE_VERSION_12 = Collections.singletonMap(Database.FileFormat.V2007, (byte[])null); + private static final Map POSSIBLE_VERSION_14 = + Collections.singletonMap(Database.FileFormat.V2010, (byte[])null); + private static final Map POSSIBLE_VERSION_MSISAM = Collections.singletonMap(Database.FileFormat.MSISAM, (byte[])null); @@ -134,8 +139,10 @@ public abstract class JetFormat { public static final JetFormat VERSION_4 = new Jet4Format(); /** the JetFormat constants for the MSISAM database */ public static final JetFormat VERSION_MSISAM = new MSISAMFormat(); - /** the JetFormat constants for the Jet database version "5" */ - public static final JetFormat VERSION_5 = new Jet5Format(); + /** the JetFormat constants for the Jet database version "12" */ + public static final JetFormat VERSION_12 = new Jet12Format(); + /** the JetFormat constants for the Jet database version "14" */ + public static final JetFormat VERSION_14 = new Jet14Format(); //These constants are populated by this class's constructor. They can't be //populated by the subclass's constructor because they are final, and Java @@ -262,8 +269,10 @@ public abstract class JetFormat { return VERSION_MSISAM; } return VERSION_4; - } else if (version == CODE_VERSION_5) { - return VERSION_5; + } else if (version == CODE_VERSION_12) { + return VERSION_12; + } else if (version == CODE_VERSION_14) { + return VERSION_14; } throw new IOException("Unsupported " + ((version < CODE_VERSION_3) ? "older" : "newer") + @@ -664,7 +673,7 @@ public abstract class JetFormat { this("VERSION_4"); } - private Jet4Format(final String name) { + private Jet4Format(String name) { super(name); } @@ -870,17 +879,39 @@ public abstract class JetFormat { } } - private static final class Jet5Format extends Jet4Format { - private Jet5Format() { - super("VERSION_5"); - } + private static class Jet12Format extends Jet4Format { + private Jet12Format() { + super("VERSION_12"); + } + + + private Jet12Format(String name) { + super(name); + } @Override protected boolean defineReverseFirstByteInDescNumericIndexes() { return true; } @Override protected Map getPossibleFileFormats() { - return PossibleFileFormats.POSSIBLE_VERSION_5; + return PossibleFileFormats.POSSIBLE_VERSION_12; + } + } + + private static final class Jet14Format extends Jet12Format { + private Jet14Format() { + super("VERSION_14"); + } + + @Override + protected boolean defineIndexesSupported() { + // 2010 uses a new text index format (new "General" sort order)... + return false; + } + + @Override + protected Map getPossibleFileFormats() { + return PossibleFileFormats.POSSIBLE_VERSION_14; } } -- 2.39.5