net.sourceforge.jpalm
Class Utilities

java.lang.Object
  extended by net.sourceforge.jpalm.Utilities

public class Utilities
extends java.lang.Object

Utility methods for the jpalm package.


Method Summary
static java.lang.String byteArrayToHexString(byte[] bytes)
          Converts a byte array to a hexadecimal string.
static java.lang.String byteToHexString(byte bite)
          Converts a byte to a hexadecimal string.
static int indexOf(byte[] bytes, int start, byte value)
          Gets the index of the first occurrence of value in bytes.
static boolean isEqual(byte[] one, byte[] two)
          Determines if two byte arrays are equal.
static boolean isMatch(java.lang.String string, java.lang.String regex)
          Determines if a string matches a regular expression.
static byte[] subbyte(byte[] bytes, int start, int length)
          Gets a new byte array that is a subset of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

byteArrayToHexString

public static java.lang.String byteArrayToHexString(byte[] bytes)
Converts a byte array to a hexadecimal string. Hexadecimal letters are lowercase.

Parameters:
bytes - a byte array to convert
Returns:
a hexadecimal string

byteToHexString

public static java.lang.String byteToHexString(byte bite)
Converts a byte to a hexadecimal string. Hexadecimal letters are lowercase.

Parameters:
bite - a byte to convert
Returns:
a hexadecimal string

subbyte

public static byte[] subbyte(byte[] bytes,
                             int start,
                             int length)
Gets a new byte array that is a subset of bytes.

Parameters:
bytes - the byte array to sub
start - the start index
length - the number of bytes to include
Returns:
a subset byte array

indexOf

public static int indexOf(byte[] bytes,
                          int start,
                          byte value)
Gets the index of the first occurrence of value in bytes.

Parameters:
bytes - the byte array
start - the index to start searching from
value - the value to search for
Returns:
the index of value or -1 if value could not be found.

isMatch

public static boolean isMatch(java.lang.String string,
                              java.lang.String regex)
Determines if a string matches a regular expression.

Parameters:
string - the string to test
regex - the regular expression
Returns:
true if the string matches; false otherwise

isEqual

public static boolean isEqual(byte[] one,
                              byte[] two)
Determines if two byte arrays are equal.

Parameters:
one - a byte array
two - a byte array
Returns:
true if the arrays are equal; false otherwise