fulmine.protocol.specification
Class ByteReader

java.lang.Object
  extended by fulmine.protocol.specification.ByteReader

public final class ByteReader
extends Object

Utility methods for reading primitives from a byte[] using the fulmine delta (FD) protocol. Integrals can be compacted using the FD protocol and the logic to correctly reconstruct them is executed in the appropriate integral read method.

Please refer to the "Fulmine Delta Transmission Protocol" specification for a complete description of the fulmine serialisation technique.

Author:
Ramon Servadei
See Also:
ByteWriter

Constructor Summary
ByteReader()
           
 
Method Summary
static String fromBytes(byte[] bytes)
          Get a string from its byte representation in ByteConstants.ENCODING.
static boolean readBoolean(byte[] bytes, int start, int numberOfBytes)
          Reconstruct a boolean from its byte form in the byte[].
static double readDouble(byte[] bytes, int start, int numberOfBytes)
          Reconstruct a double from its byte form in the byte[].
static float readFloat(byte[] bytes, int start, int numberOfBytes)
          Reconstruct a float from its byte form in the byte[].
static int readInteger(byte[] bytes, int start, int numberOfBytes)
          Reconstruct an integer from its byte form in the byte[].
static long readLong(byte[] bytes, int start, int numberOfBytes)
          Reconstruct a long from its byte form in the byte[].
static String readString(byte[] bytes, int start, int numberOfBytes)
          Reconstruct a String from its byte form in the byte[].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteReader

public ByteReader()
Method Detail

readString

public static String readString(byte[] bytes,
                                int start,
                                int numberOfBytes)
Reconstruct a String from its byte form in the byte[].

Parameters:
bytes - the byte[] holding the data in byte form
start - the position in bytes where the data starts
numberOfBytes - the number of bytes that form the data to read
Returns:
a String

readBoolean

public static boolean readBoolean(byte[] bytes,
                                  int start,
                                  int numberOfBytes)
Reconstruct a boolean from its byte form in the byte[].

Parameters:
bytes - the byte[] holding the data in byte form
start - the position in bytes where the data starts
numberOfBytes - the number of bytes that form the data to read
Returns:
a boolean

readFloat

public static float readFloat(byte[] bytes,
                              int start,
                              int numberOfBytes)
Reconstruct a float from its byte form in the byte[].

Parameters:
bytes - the byte[] holding the data in byte form
start - the position in bytes where the data starts
numberOfBytes - the number of bytes that form the data to read
Returns:
a float

readDouble

public static double readDouble(byte[] bytes,
                                int start,
                                int numberOfBytes)
Reconstruct a double from its byte form in the byte[].

Parameters:
bytes - the byte[] holding the data in byte form
start - the position in bytes where the data starts
numberOfBytes - the number of bytes that form the data to read
Returns:
a double

readInteger

public static int readInteger(byte[] bytes,
                              int start,
                              int numberOfBytes)
Reconstruct an integer from its byte form in the byte[].

Parameters:
bytes - the byte[] holding the data in byte form
start - the position in bytes where the data starts
numberOfBytes - the number of bytes that form the data to read
Returns:
an integer

readLong

public static long readLong(byte[] bytes,
                            int start,
                            int numberOfBytes)
Reconstruct a long from its byte form in the byte[].

Parameters:
bytes - the byte[] holding the data in byte form
start - the position in bytes where the data starts
numberOfBytes - the number of bytes that form the data to read
Returns:
a long

fromBytes

public static String fromBytes(byte[] bytes)
Get a string from its byte representation in ByteConstants.ENCODING.
WARNING: System.exit(2) if encoding fails.

Parameters:
bytes - the bytes of the string, encoded in ByteConstants.ENCODING
Returns:
the string, in ByteConstants.ENCODING


Copyright © 2007-2009. All Rights Reserved.