Knopflerfish OSGi 5.2.0

org.knopflerfish.util
Class ByteArray

java.lang.Object
  extended by org.knopflerfish.util.ByteArray

public class ByteArray
extends java.lang.Object

A converter class used to read primitive datatypes from, or write them to, a bytearray, starting at position index. The data is stored as big-endian in the array (the most significant value in the sequence is stored first at the lowest storage address).


Constructor Summary
ByteArray()
           
 
Method Summary
static byte getByte(byte[] array, int index)
          Returns a byte read from the bytearray, starting at position index.
static double getDouble(byte[] array, int index)
           
static float getFloat(byte[] array, int index)
          Returns a float read from the bytearray, starting at the position index.
static int getInt(byte[] array, int index)
          Returns an integer read from the bytearray, starting at position index.
static long getLong(byte[] array, int index)
          Returns a long read from the bytearray, starting at position index.
static short getShort(byte[] array, int index)
          Returns a short read from the bytearray, starting at position index.
static int setByte(byte b, byte[] array, int index)
          Writes a byte into the bytearray, starting at position index.
static int setDouble(double d, byte[] array, int index)
           
static int setFloat(float f, byte[] array, int index)
           
static int setInt(int i, byte[] array, int index)
          Writes an integer into the bytearray, starting at position index.
static int setLong(long l, byte[] array, int index)
          Writes a long into the bytearray, starting at position index.
static int setShort(short s, byte[] array, int index)
          Writes a short into the bytearray, starting at position index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArray

public ByteArray()
Method Detail

getByte

public static byte getByte(byte[] array,
                           int index)
Returns a byte read from the bytearray, starting at position index.

Parameters:
array - the bytearray to read from
index - the index to start at in the bytearray
Returns:
the byte just read

getShort

public static short getShort(byte[] array,
                             int index)
Returns a short read from the bytearray, starting at position index.

Parameters:
array - the bytearray to read from
index - the index to start at in the bytearray
Returns:
the short just read

getInt

public static int getInt(byte[] array,
                         int index)
Returns an integer read from the bytearray, starting at position index.

Parameters:
array - the bytearray to read from
index - the index to start at in the bytearray
Returns:
the integer just read

getFloat

public static float getFloat(byte[] array,
                             int index)
Returns a float read from the bytearray, starting at the position index.

Parameters:
array - the bytearray to read from
index - the index to start at in the bytearray
Returns:
the float just read

getLong

public static long getLong(byte[] array,
                           int index)
Returns a long read from the bytearray, starting at position index.

Parameters:
array - the bytearray to read from
index - the index to start at in the bytearray
Returns:
the long just read

getDouble

public static double getDouble(byte[] array,
                               int index)

setByte

public static int setByte(byte b,
                          byte[] array,
                          int index)
Writes a byte into the bytearray, starting at position index.

Parameters:
b - the byte to write down
array - the bytearray to write to
index - the index to start at in the bytearray
Returns:
the number of written bytes

setShort

public static int setShort(short s,
                           byte[] array,
                           int index)
Writes a short into the bytearray, starting at position index.

Parameters:
s - the short to write down
array - the bytearray to write to
index - the index to start at in the bytearray
Returns:
the number of written bytes

setInt

public static int setInt(int i,
                         byte[] array,
                         int index)
Writes an integer into the bytearray, starting at position index.

Parameters:
i - the integer to write down
array - the bytearray to write to
index - the index to start at in the bytearray
Returns:
the number of written bytes

setFloat

public static int setFloat(float f,
                           byte[] array,
                           int index)

setLong

public static int setLong(long l,
                          byte[] array,
                          int index)
Writes a long into the bytearray, starting at position index.

Parameters:
l - the long to write down
array - the bytearray to write to
index - the index to start at in the bytearray
Returns:
the number of written bytes

setDouble

public static int setDouble(double d,
                            byte[] array,
                            int index)

Knopflerfish OSGi 5.2.0