org.zkoss.util
Class ArraysX

java.lang.Object
  extended by org.zkoss.util.ArraysX

public class ArraysX
extends java.lang.Object

Utilities for handling arrays.

Author:
henrichen

Constructor Summary
ArraysX()
           
 
Method Summary
static
<T> java.util.List<T>
asList(T[] ary)
          Returns a mutable list.
static
<T> java.util.List<java.util.List<T>>
asList(T[][] ary)
          Returns a two dimensional mutable list.
static java.lang.Object clone(java.lang.Object ary)
          Deprecated. As of release 6.0.0, replaced with duplicate(Object).
static java.lang.Object concat(java.lang.Object ary, java.lang.Object ary1)
          Concatenates the two specified array.
static
<T> T[]
concat(T[] ary, T[] ary1)
          Concatenates the two specified generic array.
static java.lang.Object duplicate(java.lang.Object ary)
          Duplicates the specified array.
static java.lang.Object duplicate(java.lang.Object ary, int jb, int je)
          Duplicates the specified array.
static
<T> T[]
duplicate(T[] ary)
          Duplicates the specified generic array.
static
<T> T[]
duplicate(T[] ary, int jb, int je)
          Duplicates the specified generic array.
static java.lang.Object resize(java.lang.Object ary, int size)
          Resizes the specified array.
static
<T> T[]
resize(T[] ary, int size)
          Resizes the specified generic array.
static java.lang.Object shrink(java.lang.Object ary, int jb, int je)
          Shrink the specified array.
static
<T> T[]
shrink(T[] ary, int jb, int je)
          Shrink the specified array.
static java.lang.String toHexString(byte[] array)
          Returns the hex String representation of a byte array without prefix 0x.
static java.lang.String toOctalString(byte[] array, java.lang.String prefix)
          Returns the octal String representation of a byte array with optional prefix.
static java.lang.String toString(boolean[] array)
          Converts an array of boolean to a readable string (for debugging purpose).
static java.lang.String toString(byte[] array)
          Converts an array of byte to a readable string (for debugging purpose).
static java.lang.String toString(char[] array)
          Converts an array of char to a readable string (for debugging purpose).
static java.lang.String toString(double[] array)
          Converts an array of char to a readable string (for debugging purpose).
static java.lang.String toString(float[] array)
          Converts an array of float to a readable string (for debugging purpose).
static java.lang.String toString(int[] array)
          Converts an array of int to a readable string (for debugging purpose).
static java.lang.String toString(long[] array)
          Converts an array of long to a readable string (for debugging purpose).
static java.lang.String toString(java.lang.Object[] array)
          Converts an array to a readable string (for debugging purpose).
static java.lang.String toString(short[] array)
          Converts an array of short to a readable string (for debugging purpose).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArraysX

public ArraysX()
Method Detail

toString

public static final java.lang.String toString(java.lang.Object[] array)
Converts an array to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(int[] array)
Converts an array of int to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(long[] array)
Converts an array of long to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(short[] array)
Converts an array of short to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(byte[] array)
Converts an array of byte to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(char[] array)
Converts an array of char to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(boolean[] array)
Converts an array of boolean to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(float[] array)
Converts an array of float to a readable string (for debugging purpose).


toString

public static final java.lang.String toString(double[] array)
Converts an array of char to a readable string (for debugging purpose).


toHexString

public static final java.lang.String toHexString(byte[] array)
Returns the hex String representation of a byte array without prefix 0x. The String is formed by making value[0] the leftmost two digits and value[value.length-1] the rightmost two digits.

Parameters:
array - the byte array

toOctalString

public static final java.lang.String toOctalString(byte[] array,
                                                   java.lang.String prefix)
Returns the octal String representation of a byte array with optional prefix. The String is formed by making value[0] the leftmost three digits and value[value.length-1] the rightmost three digits.

Parameters:
array - the byte array

duplicate

public static final java.lang.Object duplicate(java.lang.Object ary,
                                               int jb,
                                               int je)
Duplicates the specified array.

The array could be an array of objects or primitives.

Parameters:
ary - the array
jb - the beginning index (included)
je - the ending index (excluded)
Returns:
an array duplicated from ary
Throws:
java.lang.IllegalArgumentException - if ary is not any array
java.lang.IndexOutOfBoundsException - if out of bounds

duplicate

public static final <T> T[] duplicate(T[] ary,
                                      int jb,
                                      int je)
Duplicates the specified generic array.

The array could be an array of objects or primitives.

Parameters:
ary - the array
jb - the beginning index (included)
je - the ending index (excluded)
Returns:
an array duplicated from ary
Throws:
java.lang.IllegalArgumentException - if ary is not any array
java.lang.IndexOutOfBoundsException - if out of bounds
Since:
6.0.0

duplicate

public static final java.lang.Object duplicate(java.lang.Object ary)
Duplicates the specified array.

Parameters:
ary - the array
Returns:
an array duplicated from ary
Throws:
java.lang.IllegalArgumentException - if ary is not any array
java.lang.IndexOutOfBoundsException - if out of bounds

duplicate

public static final <T> T[] duplicate(T[] ary)
Duplicates the specified generic array.

Parameters:
ary - the array
Returns:
an array duplicated from ary
Throws:
java.lang.IllegalArgumentException - if ary is not any array
java.lang.IndexOutOfBoundsException - if out of bounds
Since:
6.0.0

concat

public static final java.lang.Object concat(java.lang.Object ary,
                                            java.lang.Object ary1)
Concatenates the two specified array.

The array could be an array of objects or primitives.

Parameters:
ary - the array
ary1 - the array
Returns:
an array concatenating the ary and ary1
Throws:
java.lang.IllegalArgumentException - if ary and ary1 component types are not compatible

concat

public static final <T> T[] concat(T[] ary,
                                   T[] ary1)
Concatenates the two specified generic array.

The array could be an array of objects or primitives.

Parameters:
ary - the array
ary1 - the array
Returns:
an array concatenating the ary and ary1
Throws:
java.lang.IllegalArgumentException - if ary and ary1 component types are not compatible
Since:
6.0.0

shrink

public static final java.lang.Object shrink(java.lang.Object ary,
                                            int jb,
                                            int je)
Shrink the specified array. It is similar to duplicate, except it returns the previous instance if je==length && jb==0.

Parameters:
ary - the array
jb - the beginning index (included)
je - the ending index (excluded)
Returns:
ary or an array duplicated from ary
Throws:
java.lang.IllegalArgumentException - if ary is not any array
java.lang.IndexOutOfBoundsException - if out of bounds

shrink

public static final <T> T[] shrink(T[] ary,
                                   int jb,
                                   int je)
Shrink the specified array. It is similar to duplicate, except it returns the previous instance if je==length && jb==0.

Parameters:
ary - the array
jb - the beginning index (included)
je - the ending index (excluded)
Returns:
ary or an array duplicated from ary
Throws:
java.lang.IllegalArgumentException - if ary is not any array
java.lang.IndexOutOfBoundsException - if out of bounds
Since:
6.0.0

asList

public static final <T> java.util.List<T> asList(T[] ary)
Returns a mutable list.

Never be null.

Parameters:
ary - the data array
Returns:
a list view of the specified array
Since:
6.0.1

asList

public static final <T> java.util.List<java.util.List<T>> asList(T[][] ary)
Returns a two dimensional mutable list.

Never be null.

Parameters:
ary - the two dimensional data array
Returns:
a two dimensional list view of the specified array
Since:
6.0.1
See Also:
asList(Object[])

resize

public static final java.lang.Object resize(java.lang.Object ary,
                                            int size)
Resizes the specified array. Similar to shrink(java.lang.Object, int, int), but it can enlarge and it keeps elements from the first.


resize

public static final <T> T[] resize(T[] ary,
                                   int size)
Resizes the specified generic array.

Since:
6.0.0

clone

public static final java.lang.Object clone(java.lang.Object ary)
Deprecated. As of release 6.0.0, replaced with duplicate(Object).



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo