diff options
Diffstat (limited to 'src/java/com/healthmarketscience/jackcess/Index.java')
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Index.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java index 5363894..97315d6 100644 --- a/src/java/com/healthmarketscience/jackcess/Index.java +++ b/src/java/com/healthmarketscience/jackcess/Index.java @@ -1186,6 +1186,8 @@ public abstract class Index implements Comparable<Index> { return new ByteColumnDescriptor(col, flags); case BOOLEAN: return new BooleanColumnDescriptor(col, flags); + case GUID: + return new GuidColumnDescriptor(col, flags); default: // FIXME we can't modify this index at this point in time @@ -1481,6 +1483,41 @@ public abstract class Index implements Comparable<Index> { } /** + * ColumnDescriptor for guid columns. + */ + private static final class GuidColumnDescriptor extends ColumnDescriptor + { + private GuidColumnDescriptor(Column column, byte flags) + throws IOException + { + super(column, flags); + } + + @Override + protected void writeNonNullValue( + Object value, ByteArrayOutputStream bout) + throws IOException + { + byte[] valueBytes = encodeNumberColumnValue(value, getColumn()); + + // index format <8-bytes> 0x09 <8-bytes> 0x08 + + // bit twiddling rules: + // - isAsc => nothing + // - !isAsc => flipBytes, _but keep 09 unflipped_! + if(!isAscending()) { + flipBytes(valueBytes); + } + + bout.write(valueBytes, 0, 8); + bout.write(MID_GUID); + bout.write(valueBytes, 8, 8); + bout.write(isAscending() ? ASC_END_GUID : DESC_END_GUID); + } + } + + + /** * ColumnDescriptor for columns which we cannot currently write. */ private static final class ReadOnlyColumnDescriptor extends ColumnDescriptor |