summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/com/healthmarketscience/jackcess/Column.java6
-rw-r--r--src/java/com/healthmarketscience/jackcess/Database.java2
-rw-r--r--src/java/com/healthmarketscience/jackcess/JetFormat.java15
3 files changed, 20 insertions, 3 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java
index c455575..033e933 100644
--- a/src/java/com/healthmarketscience/jackcess/Column.java
+++ b/src/java/com/healthmarketscience/jackcess/Column.java
@@ -269,7 +269,11 @@ public class Column implements Comparable<Column> {
*
* @throw IllegalArgumentException if this column definition is invalid.
*/
- public void validate() {
+ public void validate(JetFormat format) {
+ if(_format != format) {
+ throw new IllegalArgumentException("format must be " + format +
+ " but is " + _format);
+ }
if(getType() == null) {
throw new IllegalArgumentException("must have type");
}
diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java
index 492df5f..1f93d46 100644
--- a/src/java/com/healthmarketscience/jackcess/Database.java
+++ b/src/java/com/healthmarketscience/jackcess/Database.java
@@ -417,7 +417,7 @@ public class Database
Set<String> colNames = new HashSet<String>();
// next, validate the column definitions
for(Column column : columns) {
- column.validate();
+ column.validate(_format);
if(!colNames.add(column.getName().toUpperCase())) {
throw new IllegalArgumentException("duplicate column name: " +
column.getName());
diff --git a/src/java/com/healthmarketscience/jackcess/JetFormat.java b/src/java/com/healthmarketscience/jackcess/JetFormat.java
index 8b01fc0..c40bcc2 100644
--- a/src/java/com/healthmarketscience/jackcess/JetFormat.java
+++ b/src/java/com/healthmarketscience/jackcess/JetFormat.java
@@ -58,6 +58,9 @@ public abstract class JetFormat {
//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
//doesn't allow this; hence all the abstract defineXXX() methods.
+
+ /** the name of this format */
+ private final String _name;
/** Database page size in bytes */
public final int PAGE_SIZE;
@@ -141,7 +144,8 @@ public abstract class JetFormat {
}
}
- private JetFormat() {
+ private JetFormat(String name) {
+ _name = name;
PAGE_SIZE = definePageSize();
@@ -265,8 +269,17 @@ public abstract class JetFormat {
protected abstract int definePagesPerUsageMapPage();
protected abstract Charset defineCharset();
+
+ @Override
+ public String toString() {
+ return _name;
+ }
private static final class Jet4Format extends JetFormat {
+
+ private Jet4Format() {
+ super("VERSION_4");
+ }
protected int definePageSize() { return 4096; }