org.jutil
Class TArray

java.lang.Object
  extended by org.jutil.TArray

public final class TArray
extends java.lang.Object

This is the TArray utility code class.


Constructor Summary
TArray()
          Ensure that no one can create instances of this Class.
 
Method Summary
static byte[] concat(byte[] array0, byte[] array1)
          Appends the contents of array1 to the end of array0
static int[] concat(int[] array0, int[] array1)
          Appends the contents of array1 to the end of array0
static java.lang.Object[] concat(java.lang.Object[] array, java.lang.Object obj)
          Appends the Object obj to the end of array0
static java.lang.Object[] concat(java.lang.Object[] array0, java.lang.Object[] array1)
          Appends the contents of array1 to the end of array0
static boolean contains(byte[] array, byte b)
          Check to see if the byte[] array contains the byte b
static boolean contains(int[] array, int i)
          Check to see if the array contains the int i
static boolean contains(java.lang.Object[] array, java.lang.Object obj)
           
static void dump(byte[] array, java.io.OutputStream out)
          Dump contents of array to OutputStream
static void dump(java.lang.Object[] array, java.io.OutputStream out)
          Dump contents of array to OutputStream
static void dumpCompare(byte[] array0, byte[] array1, java.io.OutputStream out)
          Dump and compare the contents of array0 and aaray1 to OutputStream
static boolean equals(byte[] array0, byte[] array1)
          Compares the contents of the byte arrays for equality, uses the == operator
static byte[] extract(byte[] array0, int size)
          extract: extracts size bytes from array0 starting at index 0 usage: byte[] bytes = org.jutil.TByteArray.extract(array0, 10);
static byte[] extract(byte[] array0, int size, int index)
          extract: extracts size bytes from array0 starting at index usage: byte[] bytes = org.jutil.TByteArray.extract(array0, 10, 5);
static void fill(byte[] array, byte value)
          fill: fill all array elements with value
static int indexOf(byte[] array, byte b)
          Find the position of the byte in the array
static int indexOf(int[] array, int i)
          Find the position of the int in the array
static int indexOf(java.lang.Object[] array, java.lang.Object obj)
          Find the position of the obj in the array, uses the Object's equals() method
static int intAt(byte[] array, int index)
          Read an int value from an array; usage: org.jutil.TByteArray.intAt(byte[] array, int index);
static void setIntAt(byte[] array, int i, int index)
          Write an int value from an array; usage: org.jutil.TByteArray.setIntAt(byte[] array, int i, int index);
static java.lang.String toString(byte[] array0)
          usage: String str = org.jutil.TByteArray.toString(array0);
static java.lang.String toString(byte[] array0, java.lang.String enc)
          usage: String str = org.jutil.TByteArray.toString(array0, "iso-8859-1");
static java.lang.String toString(java.lang.Object[] array)
          Concat an Object[] to a String dividing with the delim char ',', using the objects default .toString() method
static java.lang.String toString(java.lang.Object[] array, char delim)
          Concat an Object[] to a String dividing with the delim char, using the objects default .toString()
static byte[] valueOf(java.lang.String string)
          usage: byte[] bytes = org.jutil.TByteArray.valueOf(string);
static byte[] valueOf(java.lang.String string, java.lang.String enc)
          usage: byte[] bytes = org.jutil.TByteArray.valueOf(string, "iso-8859-1");
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TArray

public TArray()
Ensure that no one can create instances of this Class.

Method Detail

contains

public static final boolean contains(java.lang.Object[] array,
                                     java.lang.Object obj)

indexOf

public static final int indexOf(java.lang.Object[] array,
                                java.lang.Object obj)
Find the position of the obj in the array, uses the Object's equals() method

Usage:

 int pos = org.jutil.TArray.indexOf(array, obj); 
 

Parameters:
array - Object[]
obj - Object
Returns:
int -1 indicate not found otherwise the position in the array
Throws:
NullPointerException - if the array or the obj is null.

concat

public static final java.lang.Object[] concat(java.lang.Object[] array,
                                              java.lang.Object obj)
Appends the Object obj to the end of array0

Usage:

 org.jutil.TArray.concat(array0, obj);
 

Parameters:
array0 - Object[]
obj - Object
Returns:
Object[]
Throws:
NullPointerException - if the array is null.

concat

public static final java.lang.Object[] concat(java.lang.Object[] array0,
                                              java.lang.Object[] array1)
Appends the contents of array1 to the end of array0

Usage:

 org.jutil.TArray.concat(array0, array1);
 

Parameters:
array0 - Object[]
array1 - Object[]
Returns:
Object[]
Throws:
NullPointerException - if the array0 or array1 is null.

dump

public static final void dump(java.lang.Object[] array,
                              java.io.OutputStream out)
                       throws java.io.IOException
Dump contents of array to OutputStream

Usage:

 org.jutil.TArray.dump(array, System.out);
 

Parameters:
array - Object[]
out - java.io.OutputStream
Throws:
NullPointerException - if the array or out is null.
java.io.IOException

toString

public static final java.lang.String toString(java.lang.Object[] array)
Concat an Object[] to a String dividing with the delim char ',', using the objects default .toString() method

Usage:

 String str = org.jutil.TArray.toString(array);
 

Parameters:
array - Object[]
Returns:
String
Throws:
NullPointerException - if the array is null.

toString

public static final java.lang.String toString(java.lang.Object[] array,
                                              char delim)
Concat an Object[] to a String dividing with the delim char, using the objects default .toString()

Usage:

 String str = org.jutil.TArray.toString(array, ',');
 

Parameters:
array - Object[]
delim - char
Returns:
String
Throws:
NullPointerException - if the array is null.

concat

public static final byte[] concat(byte[] array0,
                                  byte[] array1)
Appends the contents of array1 to the end of array0

Usage:

 org.jutil.TArray.concat(array0, array1);
 

Parameters:
array0 - byte[]
array1 - byte[]
Returns:
byte[]
Throws:
NullPointerException - if the array0 or array1 is null.

contains

public static final boolean contains(byte[] array,
                                     byte b)
Check to see if the byte[] array contains the byte b

Usage:

 boolean contains = org.jutil.TArray.contains(array, i);
 

Parameters:
array - byte[]
b - byte
Returns:
boolean
Throws:
NullPointerException - if the array is null.

indexOf

public static final int indexOf(byte[] array,
                                byte b)
Find the position of the byte in the array

Usage:

 int pos = org.jutil.TArray.indexOf(array, b); 
 

Parameters:
array - byte[]
b - byte
Returns:
int -1 indicate not found otherwise the position in the array
Throws:
NullPointerException - if the array is null.

fill

public static final void fill(byte[] array,
                              byte value)
fill: fill all array elements with value

Usage:

 org.jutil.TArray.fill(byte[] array, byte value);
 

Parameters:
array - byte[]
value - byte
Throws:
NullPointerException - if the array is null.

dump

public static final void dump(byte[] array,
                              java.io.OutputStream out)
                       throws java.io.IOException
Dump contents of array to OutputStream

Usage:

 org.jutil.TArray.dump(array, System.err);
 

Parameters:
array - byte[]
out - java.io.OutputStream
Throws:
NullPointerException - if the array or out is null.
java.io.IOException

dumpCompare

public static final void dumpCompare(byte[] array0,
                                     byte[] array1,
                                     java.io.OutputStream out)
                              throws java.io.IOException
Dump and compare the contents of array0 and aaray1 to OutputStream

Usage:

 org.jutil.TArray.dumpCompare(array0, array1, System.out);
 

Parameters:
array0 - byte[]
array1 - byte[]
out - java.io.OutputStream
Throws:
NullPointerException - if the array0, array1 or out is null.
java.io.IOException

equals

public static final boolean equals(byte[] array0,
                                   byte[] array1)
Compares the contents of the byte arrays for equality, uses the == operator

Usage:

 org.jutil.TArray.equals(array0, array1);
 

Parameters:
array0 - byte[]
array1 - byte[]
Returns:
boolean
Throws:
NullPointerException - if the array0 or array1 is null.

toString

public static final java.lang.String toString(byte[] array0)
                                       throws java.io.UnsupportedEncodingException
usage: String str = org.jutil.TByteArray.toString(array0);

Throws:
java.io.UnsupportedEncodingException

toString

public static final java.lang.String toString(byte[] array0,
                                              java.lang.String enc)
                                       throws java.io.UnsupportedEncodingException
usage: String str = org.jutil.TByteArray.toString(array0, "iso-8859-1");

Throws:
java.io.UnsupportedEncodingException

valueOf

public static final byte[] valueOf(java.lang.String string)
                            throws java.io.UnsupportedEncodingException
usage: byte[] bytes = org.jutil.TByteArray.valueOf(string);

Throws:
java.io.UnsupportedEncodingException

valueOf

public static final byte[] valueOf(java.lang.String string,
                                   java.lang.String enc)
                            throws java.io.UnsupportedEncodingException
usage: byte[] bytes = org.jutil.TByteArray.valueOf(string, "iso-8859-1");

Throws:
java.io.UnsupportedEncodingException

extract

public static final byte[] extract(byte[] array0,
                                   int size)
extract: extracts size bytes from array0 starting at index 0 usage: byte[] bytes = org.jutil.TByteArray.extract(array0, 10);


extract

public static final byte[] extract(byte[] array0,
                                   int size,
                                   int index)
extract: extracts size bytes from array0 starting at index usage: byte[] bytes = org.jutil.TByteArray.extract(array0, 10, 5);


intAt

public static final int intAt(byte[] array,
                              int index)
Read an int value from an array; usage: org.jutil.TByteArray.intAt(byte[] array, int index);


setIntAt

public static final void setIntAt(byte[] array,
                                  int i,
                                  int index)
Write an int value from an array; usage: org.jutil.TByteArray.setIntAt(byte[] array, int i, int index);


concat

public static final int[] concat(int[] array0,
                                 int[] array1)
Appends the contents of array1 to the end of array0

Usage:

 org.jutil.TArray.concat(array0, array1);
 

Parameters:
array0 - int[]
array1 - int[]
Returns:
int[]
Throws:
NullPointerException - if the array0 or array1 is null.

contains

public static final boolean contains(int[] array,
                                     int i)
Check to see if the array contains the int i

Usage:

 boolean contains = org.jutil.TArray.contains(array, i);
 

Parameters:
array - int[]
i - int
Returns:
boolean
Throws:
NullPointerException - if the array is null.

indexOf

public static final int indexOf(int[] array,
                                int i)
Find the position of the int in the array

Usage:

 int pos = org.jutil.TArray.indexOf(array, b); 
 

Parameters:
array - int[]
u - int
Returns:
int -1 indicate not found otherwise the position in the array
Throws:
NullPointerException - if the array is null.