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/ByteUtil.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/ByteUtil.java')
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/ByteUtil.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/ByteUtil.java b/src/java/com/healthmarketscience/jackcess/ByteUtil.java index 0ea90ce..95c2d8e 100644 --- a/src/java/com/healthmarketscience/jackcess/ByteUtil.java +++ b/src/java/com/healthmarketscience/jackcess/ByteUtil.java @@ -242,7 +242,7 @@ public final class ByteUtil { * @param order the order to insert the bytes of the int */ public static void putInt(ByteBuffer buffer, int val, int offset, - ByteOrder order) + ByteOrder order) { ByteOrder origOrder = buffer.order(); try { @@ -416,5 +416,34 @@ public final class ByteUtil { public static int asUnsignedShort(short s) { return s & 0xFFFF; } + + /** + * Swaps the 4 bytes (changes endianness) of the bytes at the given offset. + * + * @param bytes buffer containing bytes to swap + * @param offset offset of the first byte of the bytes to swap + */ + public static void swap4Bytes(byte[] bytes, int offset) + { + byte b = bytes[offset + 0]; + bytes[offset + 0] = bytes[offset + 3]; + bytes[offset + 3] = b; + b = bytes[offset + 1]; + bytes[offset + 1] = bytes[offset + 2]; + bytes[offset + 2] = b; + } + + /** + * Swaps the 2 bytes (changes endianness) of the bytes at the given offset. + * + * @param bytes buffer containing bytes to swap + * @param offset offset of the first byte of the bytes to swap + */ + public static void swap2Bytes(byte[] bytes, int offset) + { + byte b = bytes[offset + 0]; + bytes[offset + 0] = bytes[offset + 1]; + bytes[offset + 1] = b; + } } |