diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2010-03-17 04:21:49 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2010-03-17 04:21:49 +0000 |
commit | 611b3cd61a3771613449d6082be6c18585e0cc24 (patch) | |
tree | 789b846c07f081e2200dd1590f7f0a60ed27b8a9 /src | |
parent | 16b40c192f4d9af7f36500bd0dd832d812b148ad (diff) | |
download | jackcess-611b3cd61a3771613449d6082be6c18585e0cc24.tar.gz jackcess-611b3cd61a3771613449d6082be6c18585e0cc24.zip |
fix handling of numeric column indexes for v2007 databases
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/newformats@449 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Index.java | 26 | ||||
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/JetFormat.java | 15 |
2 files changed, 34 insertions, 7 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java index b629049..f72377a 100644 --- a/src/java/com/healthmarketscience/jackcess/Index.java +++ b/src/java/com/healthmarketscience/jackcess/Index.java @@ -1540,17 +1540,31 @@ public abstract class Index implements Comparable<Index> { boolean isNegative = ((valueBytes[0] & 0x80) != 0); // bit twiddling rules: - // isAsc && !isNeg => setReverseSignByte - // isAsc && isNeg => flipBytes, setReverseSignByte - // !isAsc && !isNeg => flipBytes, setReverseSignByte - // !isAsc && isNeg => setReverseSignByte + // isAsc && !isNeg => setReverseSignByte => FF 00 00 ... + // isAsc && isNeg => flipBytes, setReverseSignByte => 00 FF FF ... + // !isAsc && !isNeg => flipBytes, setReverseSignByte => FF FF FF ... + // !isAsc && isNeg => setReverseSignByte => 00 00 00 ... + // v2007 bit twiddling rules: + // isAsc && !isNeg => setSignByte 0xFF => FF 00 00 ... + // isAsc && isNeg => setSignByte 0xFF, flipBytes => 00 FF FF ... + // !isAsc && !isNeg => setSignByte 0xFF => FF 00 00 ... + // !isAsc && isNeg => setSignByte 0xFF, flipBytes => 00 FF FF ... + + boolean alwaysRevFirstByte = getColumn().getFormat().REVERSE_FIRST_BYTE_IN_DESC_NUMERIC_INDEXES; + if(alwaysRevFirstByte) { + // reverse the sign byte (before any byte flipping) + valueBytes[0] = (byte)0xFF; + } + if(isNegative == isAscending()) { flipBytes(valueBytes); } - // reverse the sign byte (after any previous byte flipping) - valueBytes[0] = (isNegative ? (byte)0x00 : (byte)0xFF); + if(!alwaysRevFirstByte) { + // reverse the sign byte (after any previous byte flipping) + valueBytes[0] = (isNegative ? (byte)0x00 : (byte)0xFF); + } bout.write(valueBytes); } diff --git a/src/java/com/healthmarketscience/jackcess/JetFormat.java b/src/java/com/healthmarketscience/jackcess/JetFormat.java index afb1804..62ce992 100644 --- a/src/java/com/healthmarketscience/jackcess/JetFormat.java +++ b/src/java/com/healthmarketscience/jackcess/JetFormat.java @@ -130,6 +130,8 @@ public abstract class JetFormat { public final int MAX_TABLE_NAME_LENGTH; public final int MAX_COLUMN_NAME_LENGTH; public final int MAX_INDEX_NAME_LENGTH; + + public final boolean REVERSE_FIRST_BYTE_IN_DESC_NUMERIC_INDEXES; public final Charset CHARSET; @@ -230,7 +232,8 @@ public abstract class JetFormat { MAX_TABLE_NAME_LENGTH = defineMaxTableNameLength(); MAX_COLUMN_NAME_LENGTH = defineMaxColumnNameLength(); MAX_INDEX_NAME_LENGTH = defineMaxIndexNameLength(); - + + REVERSE_FIRST_BYTE_IN_DESC_NUMERIC_INDEXES = defineReverseFirstByteInDescNumericIndexes(); CHARSET = defineCharset(); } @@ -305,6 +308,8 @@ public abstract class JetFormat { protected abstract Charset defineCharset(); + protected abstract boolean defineReverseFirstByteInDescNumericIndexes(); + @Override public String toString() { return _name; @@ -449,6 +454,9 @@ public abstract class JetFormat { protected int defineMaxIndexNameLength() { return 64; } @Override + protected boolean defineReverseFirstByteInDescNumericIndexes() { return false; } + + @Override protected Charset defineCharset() { return Charset.forName("UTF-16LE"); } } @@ -462,5 +470,10 @@ public abstract class JetFormat { private Jet5Format() { super("VERSION_5"); } + + @Override + protected boolean defineReverseFirstByteInDescNumericIndexes() { return true; } + } + } |