diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2019-08-06 21:34:01 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2019-08-06 21:34:01 +0000 |
commit | 4de28011309dd39bf767692ce732440de5d850ca (patch) | |
tree | d4e027109943174034b24384c61b80f731c6dd3a | |
parent | b1d61725129f0f3f94255c13eff4710d3489aee0 (diff) | |
download | jackcess-4de28011309dd39bf767692ce732440de5d850ca.tar.gz jackcess-4de28011309dd39bf767692ce732440de5d850ca.zip |
add new sort order for legacy 97 collation order
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/a97_indexes@1308 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java | 35 | ||||
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java | 7 |
2 files changed, 27 insertions, 15 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java index 212b912..07c798b 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java @@ -160,18 +160,25 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte private static final short GENERAL_SORT_ORDER_VALUE = 1033; /** + * the "general" text sort order, version (access 1997) + * @usage _intermediate_field_ + */ + public static final SortOrder GENERAL_97_SORT_ORDER = + new SortOrder(GENERAL_SORT_ORDER_VALUE, (short)-1); + + /** * the "general" text sort order, legacy version (access 2000-2007) * @usage _intermediate_field_ */ public static final SortOrder GENERAL_LEGACY_SORT_ORDER = - new SortOrder(GENERAL_SORT_ORDER_VALUE, (byte)0); + new SortOrder(GENERAL_SORT_ORDER_VALUE, (short)0); /** * the "general" text sort order, latest version (access 2010+) * @usage _intermediate_field_ */ public static final SortOrder GENERAL_SORT_ORDER = - new SortOrder(GENERAL_SORT_ORDER_VALUE, (byte)1); + new SortOrder(GENERAL_SORT_ORDER_VALUE, (short)1); /** pattern matching textual guid strings (allows for optional surrounding '{' and '}') */ @@ -2077,22 +2084,26 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte JetFormat format) { short value = buffer.getShort(position); - 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; } + short version = format.DEFAULT_SORT_ORDER.getVersion(); + if(format.SIZE_SORT_ORDER == 4) { + version = buffer.get(position + 3); + } + if(value == GENERAL_SORT_ORDER_VALUE) { + if(version == GENERAL_SORT_ORDER.getVersion()) { + return GENERAL_SORT_ORDER; + } if(version == GENERAL_LEGACY_SORT_ORDER.getVersion()) { return GENERAL_LEGACY_SORT_ORDER; } - if(version == GENERAL_SORT_ORDER.getVersion()) { - return GENERAL_SORT_ORDER; + if(version == GENERAL_97_SORT_ORDER.getVersion()) { + return GENERAL_97_SORT_ORDER; } } return new SortOrder(value, version); @@ -2128,7 +2139,7 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte buffer.putShort(sortOrder.getValue()); if(format.SIZE_SORT_ORDER == 4) { buffer.put((byte)0x00); // unknown - buffer.put(sortOrder.getVersion()); + buffer.put((byte)sortOrder.getVersion()); } } @@ -2563,9 +2574,9 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte public static final class SortOrder { private final short _value; - private final byte _version; + private final short _version; - public SortOrder(short value, byte version) { + public SortOrder(short value, short version) { _value = value; _version = version; } @@ -2574,7 +2585,7 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte return _value; } - public byte getVersion() { + public short getVersion() { return _version; } diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java b/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java index 6ca0dd1..2d2f0af 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; @@ -544,7 +545,7 @@ public abstract class JetFormat { protected boolean defineReadOnly() { return true; } @Override - protected boolean defineIndexesSupported() { return false; } + protected boolean defineIndexesSupported() { return true; } @Override protected CodecType defineCodecType() { @@ -740,7 +741,7 @@ public abstract class JetFormat { @Override protected ColumnImpl.SortOrder defineDefaultSortOrder() { - return ColumnImpl.GENERAL_LEGACY_SORT_ORDER; + return ColumnImpl.GENERAL_97_SORT_ORDER; } @Override @@ -973,7 +974,7 @@ public abstract class JetFormat { protected boolean defineLegacyNumericIndexes() { return true; } @Override - protected Charset defineCharset() { return Charset.forName("UTF-16LE"); } + protected Charset defineCharset() { return StandardCharsets.UTF_16LE; } @Override protected ColumnImpl.SortOrder defineDefaultSortOrder() { |