org.netbeans.mdr.persistence.btreeimpl.btreestorage
Class Converter

java.lang.Object
  extended by org.netbeans.mdr.persistence.btreeimpl.btreestorage.Converter

public class Converter
extends java.lang.Object

This class exists only to provide data conversions between primitive types and byte arrays.


Constructor Summary
Converter()
           
 
Method Summary
static byte[] convertStringToUTF8(java.lang.String str)
          convert a String to a byte array
static java.lang.String convertUTF8ToString(byte[] buffer)
          convert a byte array back to a string
static byte readByte(byte[] array, int offst)
          read a byte from an array
static byte readByte(byte[] array, IntHolder offset)
          read a byte from an array
static int readInt(byte[] array, int offst)
          read an int from an array
static int readInt(byte[] array, IntHolder offset)
          read an int from an array
static long readLong(byte[] array, int offst)
          read a long from an array
static long readLong(byte[] array, IntHolder offset)
          read a long from an array
static short readShort(byte[] array, int offst)
          read a short from an array
static short readShort(byte[] array, IntHolder offset)
          read a short from an array
static java.lang.String readString(byte[] array, int offset)
          read a string from an array.
static java.lang.String readString(byte[] array, IntHolder offset)
          read a string from an array.
static int writeByte(byte[] array, int offset, byte data)
          write a byte to an array
static void writeByte(byte[] array, IntHolder offset, byte data)
          write a byte to an array
static void writeInt(byte[] array, IntHolder offset, int data)
          write an int to an array
static int writeInt(byte[] array, int offset, int data)
          write a int to an array
static void writeLong(byte[] array, IntHolder offset, long data)
          write a long to an array
static int writeLong(byte[] array, int offset, long data)
          write a long to an array
static void writeShort(byte[] array, IntHolder offset, short data)
          write a short to an array
static int writeShort(byte[] array, int offset, short data)
          write a short to an array
static void writeString(byte[] array, IntHolder offset, java.lang.String data)
          write a string to an array.
static int writeString(byte[] array, int offset, java.lang.String data)
          write a string to an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Method Detail

writeByte

public static final void writeByte(byte[] array,
                                   IntHolder offset,
                                   byte data)
write a byte to an array

Parameters:
array - array to write to
offset - offset in array at which to write byte. On return, this will point to the next byte in the array
data - byte to write to array

writeByte

public static final int writeByte(byte[] array,
                                  int offset,
                                  byte data)
write a byte to an array

Parameters:
array - array to write to
offset - offset in array at which to write byte
data - byte to write to array
Returns:
offset in array which follows the written byte

writeShort

public static final void writeShort(byte[] array,
                                    IntHolder offset,
                                    short data)
write a short to an array

Parameters:
array - array to write to
offset - offset in array at which to write short. On return, this will point to the next byte in the array
data - short to write to array

writeShort

public static final int writeShort(byte[] array,
                                   int offset,
                                   short data)
write a short to an array

Parameters:
array - array to write to
offset - offset in array at which to write short
data - short to write to array
Returns:
offset in array which follows the written short

writeInt

public static final void writeInt(byte[] array,
                                  IntHolder offset,
                                  int data)
write an int to an array

Parameters:
array - array to write to
offset - offset in array at which to write int. On return, this will point to the next byte in the array
data - int to write to array

writeInt

public static final int writeInt(byte[] array,
                                 int offset,
                                 int data)
write a int to an array

Parameters:
array - array to write to
offset - offset in array at which to write int
data - int to write to array
Returns:
offset in array which follows the written int

writeLong

public static final void writeLong(byte[] array,
                                   IntHolder offset,
                                   long data)
write a long to an array

Parameters:
array - array to write to
offset - offset in array at which to write long. On return, this will point to the next byte in the array
data - long to write to array

writeLong

public static final int writeLong(byte[] array,
                                  int offset,
                                  long data)
write a long to an array

Parameters:
array - array to write to
offset - offset in array at which to write long
data - long to write to array
Returns:
offset in array which follows the written long

writeString

public static final void writeString(byte[] array,
                                     IntHolder offset,
                                     java.lang.String data)
write a string to an array. This uses the same format as DataOutput.WriteUTF, that is, after converting the String to an array of bytes in the Java UTF-8 encoding, write two bytes containing the array length followed by the array itself.

Parameters:
array - array to write to
offset - offset in array at which to write string. On return, this will point to the next byte in the array
data - string to write to array

writeString

public static final int writeString(byte[] array,
                                    int offset,
                                    java.lang.String data)
write a string to an array. This uses the same format as DataOutput.WriteUTF, that is, after converting the String to an array of bytes in the Java UTF-8 encoding, write two bytes containing the array length followed by the array itself.

Parameters:
array - array to write to
offset - offset in array at which to write string
data - string to write to array
Returns:
offset in array which follows the written string

convertStringToUTF8

public static final byte[] convertStringToUTF8(java.lang.String str)
convert a String to a byte array

Parameters:
str - string to convert
Returns:
string in UTF-8 format

readByte

public static final byte readByte(byte[] array,
                                  IntHolder offset)
read a byte from an array

Parameters:
array - array to read from
offset - offset in array from which to read byte. After returning, this points to the offset in the array past the data read.
Returns:
data read from array

readByte

public static final byte readByte(byte[] array,
                                  int offst)
read a byte from an array

Parameters:
array - array to read from
offset - offset in array from which to read byte.
Returns:
data read from array

readShort

public static final short readShort(byte[] array,
                                    IntHolder offset)
read a short from an array

Parameters:
array - array to read from
offset - offset in array from which to read short. After returning, this points to the offset in the array past the data read.
Returns:
data read from array

readShort

public static final short readShort(byte[] array,
                                    int offst)
read a short from an array

Parameters:
array - array to read from
offset - offset in array from which to read short.
Returns:
data read from array

readInt

public static final int readInt(byte[] array,
                                IntHolder offset)
read an int from an array

Parameters:
array - array to read from
offset - offset in array from which to read int. After returning, this points to the offset in the array past the data read.
Returns:
data read from array

readInt

public static final int readInt(byte[] array,
                                int offst)
read an int from an array

Parameters:
array - array to read from
offset - offset in array from which to read int.
Returns:
data read from array

readLong

public static final long readLong(byte[] array,
                                  IntHolder offset)
read a long from an array

Parameters:
array - array to read from
offset - offset in array from which to read long. After returning, this points to the offset in the array past the data read.
Returns:
data read from array

readLong

public static final long readLong(byte[] array,
                                  int offst)
read a long from an array

Parameters:
array - array to read from
offset - offset in array from which to read long.
Returns:
data read from array

readString

public static final java.lang.String readString(byte[] array,
                                                IntHolder offset)
read a string from an array. This will read a string written by WriteString.

Parameters:
array - array to read from
offset - offset in array from which to read string. After returning, this points to the offset in the array past the data read.
Returns:
string read from array

readString

public static final java.lang.String readString(byte[] array,
                                                int offset)
read a string from an array. This will read a string written by WriteString.

Parameters:
array - array to read from
offset - offset in array from which to read string
Returns:
string read from array

convertUTF8ToString

public static final java.lang.String convertUTF8ToString(byte[] buffer)
convert a byte array back to a string

Parameters:
buffer - array of bytes in UTF-8 format to convert
Returns:
string


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.