org.geworkbench.util
Class BinaryEncodeDecode

java.lang.Object
  extended by org.geworkbench.util.BinaryEncodeDecode

public class BinaryEncodeDecode
extends java.lang.Object

Title: Binary Encoder Decoder

Description: The class has several method for encoding decoding ints into bytes

Copyright: Copyright (c) 2004

Company:

Version:
1.0
Author:
not attributable

Field Summary
static int MASK
           
static int SIZE_OF_INT
           
 
Constructor Summary
BinaryEncodeDecode()
           
 
Method Summary
static int decodeUnsignedInt32(byte[] bytes, int offset)
           
static int[] decodeUnsignedInt32(byte[] array, int offset, int length)
          Decode byte array into an int arrray
static void encodeUnsignedInt32(byte[] array, int index, int value)
          Encodes a int into a byte array starting at index.
static byte[] encodeUnsignedInt32(int[] value)
          Encode an int array into a byte array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE_OF_INT

public static final int SIZE_OF_INT
See Also:
Constant Field Values

MASK

public static final int MASK
See Also:
Constant Field Values
Constructor Detail

BinaryEncodeDecode

public BinaryEncodeDecode()
Method Detail

encodeUnsignedInt32

public static void encodeUnsignedInt32(byte[] array,
                                       int index,
                                       int value)
Encodes a int into a byte array starting at index. Note: assume 4 bytes for a int, so the encoding will start at index and will end at offset index+3.

Parameters:
array - byte[]
index - the index to start encoding #param value the int to encode

encodeUnsignedInt32

public static byte[] encodeUnsignedInt32(int[] value)
Encode an int array into a byte array

Parameters:
value - int[] the values to encode
Returns:
byte[] the result of the encoding

decodeUnsignedInt32

public static int[] decodeUnsignedInt32(byte[] array,
                                        int offset,
                                        int length)
Decode byte array into an int arrray

Parameters:
array - byte[] array to decde
offset - int begining of decoding
length - int number of ints(!) to decode
Returns:
int[]

decodeUnsignedInt32

public static int decodeUnsignedInt32(byte[] bytes,
                                      int offset)