to.etc.util
Class ByteArrayUtil

java.lang.Object
  extended by to.etc.util.ByteArrayUtil

public final class ByteArrayUtil
extends java.lang.Object


Method Summary
static int compare(byte[] a, int astart, byte[] b, int bstart, int len)
           
static int compare(byte[] a, int from, int to, byte[] b)
          Compares a byte array part with an array.
static int findKey(java.util.List<byte[]> v, int start, byte[] key)
          Find a key by means of a binary search.
static int getInt(byte[] ba, int offset)
          Returns an integer packed into a byte array.
static long getLong(byte[] ba, int offset)
          Return a long value from bytearray "ar" starting at the offset "offset".
static short getShort(byte[] ba, int offset)
           
static java.lang.String getString(byte[] ar, int offset, int length)
          Returns a string from the thingy.
static java.sql.Timestamp getTimestamp(byte[] ar, int offset)
          Return a Timestamp value from bytearray "ar" starting at the offset "offset".
static void setInt(byte[] ba, int offset, int val)
           
static void setLong(byte[] ba, int offset, long val)
          Put a long value "val" in a byte array "ba" starting at the offset "offset"
static void setShort(byte[] ba, int offset, short val)
           
static void setString(byte[] ba, int offset, java.lang.String s, int length)
          Sets a string converted to 8-bit ascii into an array.
static void setTimestamp(byte[] ba, int offset, java.sql.Timestamp val)
          Put a Timestamp value "val" in a byte array "ba" starting at the offset "offset"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLong

public static void setLong(byte[] ba,
                           int offset,
                           long val)
Put a long value "val" in a byte array "ba" starting at the offset "offset"

Parameters:
ba -
offset -
val -

getLong

public static long getLong(byte[] ba,
                           int offset)
Return a long value from bytearray "ar" starting at the offset "offset".

Parameters:
ar -
offset -
length -
Returns:

setTimestamp

public static void setTimestamp(byte[] ba,
                                int offset,
                                java.sql.Timestamp val)
Put a Timestamp value "val" in a byte array "ba" starting at the offset "offset"

Parameters:
ba -
offset -
val -

getTimestamp

public static java.sql.Timestamp getTimestamp(byte[] ar,
                                              int offset)
Return a Timestamp value from bytearray "ar" starting at the offset "offset".

Parameters:
ar -
offset -
length -
Returns:

setShort

public static void setShort(byte[] ba,
                            int offset,
                            short val)

getShort

public static short getShort(byte[] ba,
                             int offset)

setInt

public static void setInt(byte[] ba,
                          int offset,
                          int val)

getInt

public static int getInt(byte[] ba,
                         int offset)
Returns an integer packed into a byte array.


setString

public static void setString(byte[] ba,
                             int offset,
                             java.lang.String s,
                             int length)
Sets a string converted to 8-bit ascii into an array. If the string is smaller than the allotted length the rest is padded with binary zeroes.


getString

public static java.lang.String getString(byte[] ar,
                                         int offset,
                                         int length)
Returns a string from the thingy.


compare

public static int compare(byte[] a,
                          int from,
                          int to,
                          byte[] b)
Compares a byte array part with an array.


compare

public static int compare(byte[] a,
                          int astart,
                          byte[] b,
                          int bstart,
                          int len)

findKey

public static int findKey(java.util.List<byte[]> v,
                          int start,
                          byte[] key)
Find a key by means of a binary search. post: index if found, -1 if not

Parameters:
v - vector containing the element to search for
start - location where to start comparing the bytes
key - The key to look for.