From: James Ahlborn Date: Tue, 8 Aug 2006 13:12:27 +0000 (+0000) Subject: more tweaks to index reading/writing X-Git-Tag: rel_1_1_7~29 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b49706433dd0db688e679766ae5a85fc33dcf7d0;p=jackcess.git more tweaks to index reading/writing git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@100 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java index 69ca1e5..b532f51 100644 --- a/src/java/com/healthmarketscience/jackcess/Index.java +++ b/src/java/com/healthmarketscience/jackcess/Index.java @@ -59,7 +59,7 @@ public class Index implements Comparable { * Map of characters to bytes that Access uses in indexes (not ASCII) * (Character -> Byte) */ - private static BidiMap CODES = new DualHashBidiMap(); + private static final BidiMap CODES = new DualHashBidiMap(); static { //These values are prefixed with a '43' CODES.put('^', (byte) 2); @@ -403,6 +403,8 @@ public class Index implements Comparable { private Column _column; /** Column value */ private Comparable _value; + /** extra column bytes */ + private byte[] _extraBytes; /** * Create a new EntryColumn @@ -435,7 +437,20 @@ public class Index implements Comparable { sb.append(c.charValue()); } } - buffer.get(); //Forward past 0x00 + //Forward past 0x00 (in some cases, there is more data here, which + //we don't currently understand) + byte endByte = buffer.get(); + if(endByte != 0x00) { + int startPos = buffer.position() - 1; + int endPos = buffer.position(); + while(buffer.get(endPos) != 0x00) { + ++endPos; + } + _extraBytes = new byte[endPos - startPos]; + buffer.position(startPos); + buffer.get(_extraBytes); + buffer.get(); + } _value = sb.toString(); } else { byte[] data = new byte[col.getType().getSize()]; @@ -482,6 +497,9 @@ public class Index implements Comparable { } } buffer.put((byte) 1); + if(_extraBytes != null) { + buffer.put(_extraBytes); + } buffer.put((byte) 0); } else { Comparable value = _value; @@ -503,11 +521,15 @@ public class Index implements Comparable { for (int i = 0; i < s.length(); i++) { rtn++; if (s.charAt(i) == '^' || s.charAt(i) == '_' || s.charAt(i) == '{' || - s.charAt(i) == '|' || s.charAt(i) == '}' || s.charAt(i) == '-') + s.charAt(i) == '|' || s.charAt(i) == '}' || s.charAt(i) == '~') { + // account for the magic 43 rtn++; } } + if(_extraBytes != null) { + rtn += _extraBytes.length; + } return rtn; } else { return _column.getType().getSize();