org.jboss.soa.esb.nagios.util
Class ByteOps

java.lang.Object
  extended by org.jboss.soa.esb.nagios.util.ByteOps

public class ByteOps
extends java.lang.Object

Byte manipulation utility methods


Constructor Summary
ByteOps()
           
 
Method Summary
static int bytesToInt(byte[] b, int offset, int size)
          Convert portion of an array of bytes into an int
static void copyIntoArray(byte[] src, byte[] dst, int offset, int length, boolean terminator)
          Convert a long to some number of bytes and store them in an array.
static byte[] intToBytes(int num, int len, byte[] b, int offset)
          Convert an int to some number of bytes and store them in an array.
static byte[] longToBytes(long num, int len, byte[] b, int offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteOps

public ByteOps()
Method Detail

bytesToInt

public static int bytesToInt(byte[] b,
                             int offset,
                             int size)
Convert portion of an array of bytes into an int

Parameters:
b - byte array containing data
offset - offset into array to start conversion
size - number of bytes in array to use for conversion
Returns:
the int value

intToBytes

public static byte[] intToBytes(int num,
                                int len,
                                byte[] b,
                                int offset)
Convert an int to some number of bytes and store them in an array. If no array is provided (ie null) a new one will be allocated.

Parameters:
num - number to convert
len - length of bytes to use
b - array to store value into (optional, if null one will be created)
offset - position in array to store into
Returns:
original array provided, or new array created (if none provided)

longToBytes

public static final byte[] longToBytes(long num,
                                       int len,
                                       byte[] b,
                                       int offset)

copyIntoArray

public static void copyIntoArray(byte[] src,
                                 byte[] dst,
                                 int offset,
                                 int length,
                                 boolean terminator)
Convert a long to some number of bytes and store them in an array. If no array is provided (ie null) a new one will be allocated.

Parameters:
num - number to convert
len - length of bytes to use
b - array to store value into (optional, if null one will be created)
offset - position in array to store into