ewe.database
Class EncodedUTF8String

java.lang.Object
  extended byewe.database.EncodedUTF8String

public class EncodedUTF8String
extends Object


Field Summary
 byte[] data
           
 int start
           
 
Constructor Summary
EncodedUTF8String()
           
 
Method Summary
static String load(byte[] source, int sourceOffset)
          Load a Utf8 String as saved by storeUtf8String().
static int load(byte[] source, int sourceOffset, char[] chars, int offset)
          Load a Utf8 String as saved by store().
static CharArray load(byte[] source, int sourceOffset, CharArray dest)
          Load a Utf8 String as saved by storeUtf8String() and return it in a CharArray
static SubString load(byte[] source, int sourceOffset, SubString dest)
          Load a Utf8 String as saved by storeUtf8String() and return it in a CharArray
static char[] loadChars(byte[] source, int sourceOffset)
          Load a Utf8 String as saved by storeUtf8String() as a char array.
 EncodedUTF8String set(byte[] source, int sourceStart)
           
static int store(char[] chars, int offset, int length, byte[] dest, int destOffset)
          Store a String as UTF, prepending the lengh of the String as a short integer and appending a zero byte, or find out the number of bytes required.
static byte[] store(String theString)
           
static int store(String theString, byte[] dest, int offset)
          Store a String as UTF, prepending the lengh of the String as a short integer and appending a zero byte, or find out the number of bytes required.
 String toString()
          Return a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Field Detail

data

public byte[] data

start

public int start
Constructor Detail

EncodedUTF8String

public EncodedUTF8String()
Method Detail

store

public static int store(char[] chars,
                        int offset,
                        int length,
                        byte[] dest,
                        int destOffset)
Store a String as UTF, prepending the lengh of the String as a short integer and appending a zero byte, or find out the number of bytes required.

Parameters:
chars - the characters to write.
offset - the first character to write.
length - the number of characters to write.
dest - the destination byte array, or null to just find out the number of bytes needed.
Returns:
the number of bytes required. A null char array will require 2 bytes, an empty string will require 3 bytes.

load

public static int load(byte[] source,
                       int sourceOffset,
                       char[] chars,
                       int offset)
Load a Utf8 String as saved by store().

Parameters:
source - The byte encoded String.
sourceOffset - the start of the byte encoded String.
chars - the destination for the String characters.
offset - the offset in the destination for the characters.
Returns:
The number of characters loaded or needed if chars is null. If this return -1 then this indicates a null String which is different to an empty String which returns 0.

store

public static int store(String theString,
                        byte[] dest,
                        int offset)
Store a String as UTF, prepending the lengh of the String as a short integer and appending a zero byte, or find out the number of bytes required.

Parameters:
theString - the String to write.
dest - the destination byte array, or null to just find out the number of bytes needed.
offset - the location in the destinatin to write to.
Returns:
the number of bytes required. A null String will require 2 bytes, an empty String will require 3 bytes.

store

public static byte[] store(String theString)

loadChars

public static char[] loadChars(byte[] source,
                               int sourceOffset)
Load a Utf8 String as saved by storeUtf8String() as a char array.

Parameters:
source - The byte encoded String.
sourceOffset - the start of the byte encoded String.
Returns:
The char array holding the characters, or null if a null string was stored.

load

public static String load(byte[] source,
                          int sourceOffset)
Load a Utf8 String as saved by storeUtf8String().

Parameters:
source - The byte encoded String.
sourceOffset - the start of the byte encoded String.
Returns:
The String saved, which may be null.

load

public static CharArray load(byte[] source,
                             int sourceOffset,
                             CharArray dest)
Load a Utf8 String as saved by storeUtf8String() and return it in a CharArray

Parameters:
source - The byte encoded String.
sourceOffset - the start of the byte encoded String.
dest - the CharArray to store in or a new one if dest is null. The CharArray will be cleared before the data is written to it.
Returns:
The saved, which may be null.

load

public static SubString load(byte[] source,
                             int sourceOffset,
                             SubString dest)
Load a Utf8 String as saved by storeUtf8String() and return it in a CharArray

Parameters:
source - The byte encoded String.
sourceOffset - the start of the byte encoded String.
dest - the SubString to store in or a new one if dest is null.
Returns:
The String as a SubString saved, which may be null.

toString

public String toString()
Description copied from class: Object
Return a String representation of this object.

Overrides:
toString in class Object
Returns:
a String representing this object.

set

public EncodedUTF8String set(byte[] source,
                             int sourceStart)