aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/healthmarketscience
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2010-10-14 02:22:49 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2010-10-14 02:22:49 +0000
commit6b500b7dbf54df647fad11bf640785e914e9e5c5 (patch)
tree963066cd27a0b45678a13266938ce7a305280583 /src/java/com/healthmarketscience
parentd540734522032635486d12cc650a2a7c2da7ca5f (diff)
downloadjackcess-6b500b7dbf54df647fad11bf640785e914e9e5c5.tar.gz
jackcess-6b500b7dbf54df647fad11bf640785e914e9e5c5.zip
minor refactor
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@485 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java/com/healthmarketscience')
-rw-r--r--src/java/com/healthmarketscience/jackcess/Column.java11
-rw-r--r--src/java/com/healthmarketscience/jackcess/Index.java16
2 files changed, 15 insertions, 12 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java
index 71fb379..a0391e7 100644
--- a/src/java/com/healthmarketscience/jackcess/Column.java
+++ b/src/java/com/healthmarketscience/jackcess/Column.java
@@ -454,7 +454,7 @@ public class Column implements Comparable<Column> {
* @return The deserialized Object
*/
public Object read(byte[] data) throws IOException {
- return read(data, ByteOrder.LITTLE_ENDIAN);
+ return read(data, PageChannel.DEFAULT_BYTE_ORDER);
}
/**
@@ -516,8 +516,8 @@ public class Column implements Comparable<Column> {
private byte[] readLongValue(byte[] lvalDefinition)
throws IOException
{
- ByteBuffer def = ByteBuffer.wrap(lvalDefinition);
- def.order(ByteOrder.LITTLE_ENDIAN);
+ ByteBuffer def = ByteBuffer.wrap(lvalDefinition)
+ .order(PageChannel.DEFAULT_BYTE_ORDER);
int length = ByteUtil.get3ByteInt(def);
// bail out gracefully here as we don't understand the format
if (length < 0)
@@ -1047,14 +1047,15 @@ public class Column implements Comparable<Column> {
}
/**
- * Serialize an Object into a raw byte value for this column in little endian order
+ * Serialize an Object into a raw byte value for this column in little
+ * endian order
* @param obj Object to serialize
* @return A buffer containing the bytes
*/
public ByteBuffer write(Object obj, int remainingRowLength)
throws IOException
{
- return write(obj, remainingRowLength, ByteOrder.LITTLE_ENDIAN);
+ return write(obj, remainingRowLength, PageChannel.DEFAULT_BYTE_ORDER);
}
/**
diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java
index 32e1b42..2c0645c 100644
--- a/src/java/com/healthmarketscience/jackcess/Index.java
+++ b/src/java/com/healthmarketscience/jackcess/Index.java
@@ -82,6 +82,8 @@ public abstract class Index implements Comparable<Index> {
private static final int MAX_TEXT_INDEX_CHAR_LENGTH =
(JetFormat.TEXT_FIELD_MAX_LENGTH / JetFormat.TEXT_FIELD_UNIT_SIZE);
+
+ private static final ByteOrder ENTRY_BYTE_ORDER = ByteOrder.BIG_ENDIAN;
/** type attributes for Entries which simplify comparisons */
public enum EntryType {
@@ -815,7 +817,7 @@ public abstract class Index implements Comparable<Index> {
List<Entry> entries = new ArrayList<Entry>();
TempBufferHolder tmpEntryBufferH =
TempBufferHolder.newHolder(TempBufferHolder.Type.HARD, true,
- ByteOrder.BIG_ENDIAN);
+ ENTRY_BYTE_ORDER);
Entry prevEntry = FIRST_ENTRY;
for (int i = 0; i < entryMaskLength; i++) {
@@ -1027,7 +1029,7 @@ public abstract class Index implements Comparable<Index> {
throws IOException
{
// always write in big endian order
- return column.write(value, 0, ByteOrder.BIG_ENDIAN).array();
+ return column.write(value, 0, ENTRY_BYTE_ORDER).array();
}
/**
@@ -1759,7 +1761,7 @@ public abstract class Index implements Comparable<Index> {
buffer.get(_entryBytes);
// read the rowId
- int page = ByteUtil.get3ByteInt(buffer, ByteOrder.BIG_ENDIAN);
+ int page = ByteUtil.get3ByteInt(buffer, ENTRY_BYTE_ORDER);
int row = ByteUtil.getUnsignedByte(buffer);
_rowId = new RowId(page, row);
@@ -1811,7 +1813,7 @@ public abstract class Index implements Comparable<Index> {
buffer.put(_entryBytes, prefix.length,
(_entryBytes.length - prefix.length));
ByteUtil.put3ByteInt(buffer, getRowId().getPageNumber(),
- ByteOrder.BIG_ENDIAN);
+ ENTRY_BYTE_ORDER);
} else if(prefix.length <= (_entryBytes.length + 3)) {
@@ -1819,7 +1821,7 @@ public abstract class Index implements Comparable<Index> {
// and copy last bytes to output buffer
ByteBuffer tmp = ByteBuffer.allocate(3);
ByteUtil.put3ByteInt(tmp, getRowId().getPageNumber(),
- ByteOrder.BIG_ENDIAN);
+ ENTRY_BYTE_ORDER);
tmp.flip();
tmp.position(prefix.length - _entryBytes.length);
buffer.put(tmp);
@@ -1935,7 +1937,7 @@ public abstract class Index implements Comparable<Index> {
// we need 4 trailing bytes for the sub-page number
super(buffer, entryLen, 4);
- _subPageNumber = ByteUtil.getInt(buffer, ByteOrder.BIG_ENDIAN);
+ _subPageNumber = ByteUtil.getInt(buffer, ENTRY_BYTE_ORDER);
}
@Override
@@ -1957,7 +1959,7 @@ public abstract class Index implements Comparable<Index> {
@Override
protected void write(ByteBuffer buffer, byte[] prefix) throws IOException {
super.write(buffer, prefix);
- ByteUtil.putInt(buffer, _subPageNumber, ByteOrder.BIG_ENDIAN);
+ ByteUtil.putInt(buffer, _subPageNumber, ENTRY_BYTE_ORDER);
}
@Override