aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2011-04-05 13:13:53 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2011-04-05 13:13:53 +0000
commit748e2e82128b938b95ac74a30ae1315fac167bf8 (patch)
tree544e42b51935b7e744cc6c610957ff84616be6e6 /src/java/com
parente6f3acefd378d699fb4188226f0e722c235f3942 (diff)
downloadjackcess-748e2e82128b938b95ac74a30ae1315fac167bf8.tar.gz
jackcess-748e2e82128b938b95ac74a30ae1315fac167bf8.zip
fix sort order reading in v1997; set col sort order to db default when writing (if unspecified)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@547 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/healthmarketscience/jackcess/Column.java12
-rw-r--r--src/java/com/healthmarketscience/jackcess/Database.java12
-rw-r--r--src/java/com/healthmarketscience/jackcess/JetFormat.java7
3 files changed, 28 insertions, 3 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java
index 420c581..13954cd 100644
--- a/src/java/com/healthmarketscience/jackcess/Column.java
+++ b/src/java/com/healthmarketscience/jackcess/Column.java
@@ -1747,7 +1747,11 @@ public class Column implements Comparable<Column> {
JetFormat format)
{
short value = buffer.getShort(position);
- byte version = buffer.get(position + 3);
+ byte version = 0;
+ if(format.SIZE_SORT_ORDER == 4) {
+ version = buffer.get(position + 3);
+ }
+
if(value == 0) {
// probably a file we wrote, before handling sort order
return format.DEFAULT_SORT_ORDER;
@@ -1773,8 +1777,10 @@ public class Column implements Comparable<Column> {
sortOrder = format.DEFAULT_SORT_ORDER;
}
buffer.putShort(sortOrder.getValue());
- buffer.put((byte)0x00); // unknown
- buffer.put(sortOrder.getVersion());
+ if(format.SIZE_SORT_ORDER == 4) {
+ buffer.put((byte)0x00); // unknown
+ buffer.put(sortOrder.getVersion());
+ }
}
/**
diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java
index 5c38561..46a148d 100644
--- a/src/java/com/healthmarketscience/jackcess/Database.java
+++ b/src/java/com/healthmarketscience/jackcess/Database.java
@@ -1057,6 +1057,13 @@ public class Database
_format.MAX_COLUMNS_PER_TABLE + " columns");
}
+ Column.SortOrder dbSortOrder = null;
+ try {
+ dbSortOrder = getDefaultSortOrder();
+ } catch(IOException e) {
+ // ignored, just use the jet format default
+ }
+
Set<String> colNames = new HashSet<String>();
// next, validate the column definitions
for(Column column : columns) {
@@ -1065,6 +1072,11 @@ public class Database
throw new IllegalArgumentException("duplicate column name: " +
column.getName());
}
+
+ // set the sort order to the db default (if unspecified)
+ if(column.getType().isTextual() && (column.getTextSortOrder() == null)) {
+ column.setTextSortOrder(dbSortOrder);
+ }
}
List<Column> autoCols = Table.getAutoNumberColumns(columns);
diff --git a/src/java/com/healthmarketscience/jackcess/JetFormat.java b/src/java/com/healthmarketscience/jackcess/JetFormat.java
index 173d96c..d1041a5 100644
--- a/src/java/com/healthmarketscience/jackcess/JetFormat.java
+++ b/src/java/com/healthmarketscience/jackcess/JetFormat.java
@@ -176,6 +176,7 @@ public abstract class JetFormat {
public final int OFFSET_PASSWORD;
public final int SIZE_PASSWORD;
public final int OFFSET_SORT_ORDER;
+ public final int SIZE_SORT_ORDER;
public final int OFFSET_ENCODING_KEY;
public final int OFFSET_NEXT_TABLE_DEF_PAGE;
public final int OFFSET_NUM_ROWS;
@@ -303,6 +304,7 @@ public abstract class JetFormat {
OFFSET_PASSWORD = defineOffsetPassword();
SIZE_PASSWORD = defineSizePassword();
OFFSET_SORT_ORDER = defineOffsetSortOrder();
+ SIZE_SORT_ORDER = defineSizeSortOrder();
OFFSET_ENCODING_KEY = defineOffsetEncodingKey();
OFFSET_NEXT_TABLE_DEF_PAGE = defineOffsetNextTableDefPage();
OFFSET_NUM_ROWS = defineOffsetNumRows();
@@ -398,6 +400,7 @@ public abstract class JetFormat {
protected abstract int defineOffsetPassword();
protected abstract int defineSizePassword();
protected abstract int defineOffsetSortOrder();
+ protected abstract int defineSizeSortOrder();
protected abstract int defineOffsetEncodingKey();
protected abstract int defineOffsetNextTableDefPage();
protected abstract int defineOffsetNumRows();
@@ -528,6 +531,8 @@ public abstract class JetFormat {
@Override
protected int defineOffsetSortOrder() { return 58; }
@Override
+ protected int defineSizeSortOrder() { return 2; }
+ @Override
protected int defineOffsetEncodingKey() { return 62; }
@Override
protected int defineOffsetNextTableDefPage() { return 4; }
@@ -730,6 +735,8 @@ public abstract class JetFormat {
@Override
protected int defineOffsetSortOrder() { return 110; }
@Override
+ protected int defineSizeSortOrder() { return 4; }
+ @Override
protected int defineOffsetEncodingKey() { return 62; }
@Override
protected int defineOffsetNextTableDefPage() { return 4; }