diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2006-09-23 18:45:11 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2006-09-23 18:45:11 +0000 |
commit | 23423a0a369af9187e74615f09299c39fd337e60 (patch) | |
tree | f47a43153de355342269a4482012b56522cf14a1 /src/java/com/healthmarketscience/jackcess/ByteUtil.java | |
parent | 78c26cb7fe9a4e20b7e6dfca3e375a3c0c927134 (diff) | |
download | jackcess-23423a0a369af9187e74615f09299c39fd337e60.tar.gz jackcess-23423a0a369af9187e74615f09299c39fd337e60.zip |
fix ordering of byte code comparator
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@120 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 | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/ByteUtil.java b/src/java/com/healthmarketscience/jackcess/ByteUtil.java index c1b260e..d6a7f67 100644 --- a/src/java/com/healthmarketscience/jackcess/ByteUtil.java +++ b/src/java/com/healthmarketscience/jackcess/ByteUtil.java @@ -126,9 +126,9 @@ public final class ByteUtil { offset += 2; } - int rtn = buffer.get(offset) & 0xFF; - rtn += ((((int) buffer.get(offset + (1 * offInc))) & 0xFF) << 8); - rtn += ((((int) buffer.get(offset + (2 * offInc))) & 0xFF) << 16); + int rtn = toUnsignedInt(buffer.get(offset)); + rtn += (toUnsignedInt(buffer.get(offset + (1 * offInc))) << 8); + rtn += (toUnsignedInt(buffer.get(offset + (2 * offInc))) << 16); rtn &= 0xFFFFFF; return rtn; } @@ -230,5 +230,12 @@ public final class ByteUtil { writer.close(); } } - + + /** + * @return the byte value converted to an unsigned int value + */ + public static int toUnsignedInt(byte b) { + return (int)b & 0xFF; + } + } |