at.knowcenter.wag.exactparser
Class ByteArrayUtils

java.lang.Object
  extended by at.knowcenter.wag.exactparser.ByteArrayUtils

public abstract class ByteArrayUtils
extends Object

Abstract class that contains utility methods for handling byte arrays.

Author:
wprinz

Field Summary
static String BYTE_ARRAY_ENCODING
           
 
Constructor Summary
ByteArrayUtils()
           
 
Method Summary
static boolean compareByteArrays(byte[] data, int index, byte[] search)
          Compares the two byte arrays for equality.
static boolean contains(byte[] byte_array, byte data)
          Checks, if the sought data byte is contained within the byte array.
static String convertByteArrayToString(byte[] data)
          Converts the byte array to a String.
static int indexOf(byte[] data, int index, byte[] search)
          Finds the first occurance of search in data starting to search from the given index.
static int lastIndexOf(byte[] data, byte[] search)
          Finds the last occurance of the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTE_ARRAY_ENCODING

public static final String BYTE_ARRAY_ENCODING
See Also:
Constant Field Values
Constructor Detail

ByteArrayUtils

public ByteArrayUtils()
Method Detail

convertByteArrayToString

public static String convertByteArrayToString(byte[] data)
                                       throws UnsupportedEncodingException
Converts the byte array to a String.

Parameters:
data - The byte array.
Returns:
Returns the String.
Throws:
UnsupportedEncodingException - Forwarded exception

indexOf

public static int indexOf(byte[] data,
                          int index,
                          byte[] search)
Finds the first occurance of search in data starting to search from the given index.

Parameters:
data - The big array.
index - The index to start searching from.
search - The sought array.
Returns:
Returns the index of the found occurence or -1 if nothing was found.

lastIndexOf

public static int lastIndexOf(byte[] data,
                              byte[] search)
Finds the last occurance of the array.

Parameters:
data - The source array to be searched.
search - The sought array.
Returns:
Returns the index of the last occurance - or -1 if nothing was found.

compareByteArrays

public static boolean compareByteArrays(byte[] data,
                                        int index,
                                        byte[] search)
Compares the two byte arrays for equality.

Parameters:
data - The source array.
index - In index into the source array marking where the comparison should start.
search - The sought array.
Returns:
Returns true if the first search.length bytes of data+index and search match exactly. Returns false otherwise.

contains

public static boolean contains(byte[] byte_array,
                               byte data)
Checks, if the sought data byte is contained within the byte array.

Parameters:
byte_array - The byte array.
data - A data byte sought within the byte array.
Returns:
Returns true, if the data byte was found (at least once) in the byte array, false otherwise.


Copyright © 2006-2007 EGIZ - E-Government Innovationszentrum. All Rights Reserved.