org.shoal.ha.cache.impl.util
Class Utility

java.lang.Object
  extended by org.shoal.ha.cache.impl.util.Utility

public final class Utility
extends java.lang.Object

Author:
V2.x Handy class full of static functions.

Constructor Summary
Utility()
           
 
Method Summary
static int bytesToInt(byte[] array, int offset)
          Unmarshal a byte array to an integer.
static long bytesToLong(byte[] array, int offset)
           
static byte[] intToBytes(int value)
          Marshal an integer to a byte array.
static void intToBytes(int value, byte[] array, int offset)
           
static byte[] longToBytes(long value)
          Unmarshal a byte array to an long.
static void longToBytes(long value, byte[] array, int offset)
          Marshal an long to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utility

public Utility()
Method Detail

bytesToInt

public static final int bytesToInt(byte[] array,
                                   int offset)
Unmarshal a byte array to an integer. Assume the bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+3] is the least-significant-byte.

Parameters:
array - The array of bytes.
offset - The offset from which to start unmarshalling.

intToBytes

public static final byte[] intToBytes(int value)
Marshal an integer to a byte array. The bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+3] is the least-significant-byte.


intToBytes

public static final void intToBytes(int value,
                                    byte[] array,
                                    int offset)

longToBytes

public static final byte[] longToBytes(long value)
Unmarshal a byte array to an long. Assume the bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+7] is the least-significant-byte.


bytesToLong

public static final long bytesToLong(byte[] array,
                                     int offset)

longToBytes

public static final void longToBytes(long value,
                                     byte[] array,
                                     int offset)
Marshal an long to a byte array. The bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+7] is the least-significant-byte.

Parameters:
array - The array of bytes.
offset - The offset from which to start marshalling.


Copyright © 2010. All Rights Reserved.