diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2009-10-27 01:26:46 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2009-10-27 01:26:46 +0000 |
commit | 03de09743b2d808221dcc30795d329d45a6fae21 (patch) | |
tree | fd93ba9b6be1fc568af07884b9dadc20c2c7b639 /src/java/com/healthmarketscience/jackcess/Index.java | |
parent | 24b20e6d8c454e7296b8e5700a0e9ed15e2e745a (diff) | |
download | jackcess-03de09743b2d808221dcc30795d329d45a6fae21.tar.gz jackcess-03de09743b2d808221dcc30795d329d45a6fae21.zip |
initial support for guid indexes and guid autonumbers
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@406 f203690c-595d-4dc9-a70b-905162fa7fd2
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 |