net.sourceforge.jpcap.util
Class ArrayHelper

java.lang.Object
  extended bynet.sourceforge.jpcap.util.ArrayHelper

public class ArrayHelper
extends java.lang.Object

Utility functions for populating and manipulating arrays.


Constructor Summary
ArrayHelper()
           
 
Method Summary
static int extractInteger(byte[] bytes, int pos, int cnt)
          Extract an integer from a byte array.
static long extractLong(byte[] bytes, int pos, int cnt)
          Extract a long from a byte array.
static void insertLong(byte[] bytes, long value, int pos, int cnt)
          Insert data contained in a long integer into an array.
static byte[] join(byte[] a, byte[] b)
          Join two arrays.
static byte[] toBytes(long value, int cnt)
          Convert a long integer into an array of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayHelper

public ArrayHelper()
Method Detail

join

public static byte[] join(byte[] a,
                          byte[] b)
Join two arrays.


extractLong

public static long extractLong(byte[] bytes,
                               int pos,
                               int cnt)
Extract a long from a byte array.

Parameters:
bytes - an array.
pos - the starting position where the integer is stored.
cnt - the number of bytes which contain the integer.
Returns:
the long, or 0 if the index/length to use would cause an ArrayOutOfBoundsException

extractInteger

public static int extractInteger(byte[] bytes,
                                 int pos,
                                 int cnt)
Extract an integer from a byte array.

Parameters:
bytes - an array.
pos - the starting position where the integer is stored.
cnt - the number of bytes which contain the integer.
Returns:
the integer, or 0 if the index/length to use would cause an ArrayOutOfBoundsException

insertLong

public static void insertLong(byte[] bytes,
                              long value,
                              int pos,
                              int cnt)
Insert data contained in a long integer into an array.

Parameters:
bytes - an array.
value - the long to insert into the array.
pos - the starting position into which the long is inserted.
cnt - the number of bytes to insert.

toBytes

public static byte[] toBytes(long value,
                             int cnt)
Convert a long integer into an array of bytes.

Parameters:
value - the long to convert.
cnt - the number of bytes to convert.