public final class ArrayUtil
extends java.lang.Object
| Constructor and Description |
|---|
ArrayUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
allElementsSameType(java.lang.Object[] array)
An utility method that checks whether all the elements in the array are of the same type
it returns false if the array contains a mix of classes and sub-classes of the Array component type.
|
static java.lang.Object |
concatArrays(java.lang.Object[][] origMatrix)
An utility method that concatenates many arrays to one.
|
static java.lang.Object |
concatArrays(java.lang.Object[][] origMatrix,
int totalLength)
An utility method that concatenates many arrays to one.
|
static java.lang.Object |
concatArrays(java.lang.Object[] one,
java.lang.Object[] two,
java.lang.Class componentType)
An utility method that concatenates two arrays to one
|
static java.lang.Object |
concatArrays(java.lang.Object[] one,
java.lang.Object[] two,
java.lang.Object[] three,
java.lang.Class componentType)
An utility method that concatenates three arrays to one
|
static void |
printArray(java.lang.Object[] array,
int indent)
utility method, prints out an array using the toString() method of the members.
|
static java.lang.Object |
pruneNullElements(java.lang.Object[] array)
A utility method that cuts off null-elements at the end of an array.
|
static java.lang.Object |
pruneNullElements(java.lang.Object[] array,
boolean onlyAtEnd)
prunes the null elements at the tail of an array.
|
static void |
sleep(long millis)
Utility method, sleeps for the indicated millis.
|
static java.lang.String |
toString(java.lang.Object[] array,
int indent,
boolean oneLine,
boolean numbered)
utility method, transforms the array into a String that can either be multi-line or
on one line.
|
public static java.lang.Object concatArrays(java.lang.Object[] one,
java.lang.Object[] two,
java.lang.Class componentType)
one - the first arraytwo - the second arraycomponentType - the class of the component of the array to be returnedpublic static java.lang.Object concatArrays(java.lang.Object[] one,
java.lang.Object[] two,
java.lang.Object[] three,
java.lang.Class componentType)
one - the first arraytwo - the second arraythree - the third arraycomponentType - the class of the component of the array to be returnedpublic static java.lang.Object concatArrays(java.lang.Object[][] origMatrix)
origMatrix - an array of arrays (a Matrix)public static java.lang.Object concatArrays(java.lang.Object[][] origMatrix,
int totalLength)
origMatrix - an array of arrays (a Matrix), can contain null elementstotalLength - the length of the resulting array, must be large enoughpublic static void printArray(java.lang.Object[] array,
int indent)
array - can be nullindent - the level of indents (tabs) that precede the output, can be negativepublic static java.lang.String toString(java.lang.Object[] array,
int indent,
boolean oneLine,
boolean numbered)
array - the array to be transformed, can be nullindent - the number of tabs to be used for indentingoneLine - if true, a String containing a single line is returned, if false, return characters
("\n") are integrated into the returned string.numbered - if true, each element is preceded by its index in the arraypublic static java.lang.Object pruneNullElements(java.lang.Object[] array)
public static java.lang.Object pruneNullElements(java.lang.Object[] array,
boolean onlyAtEnd)
array - the array to be prunedonlyAtEnd - -- must be truepublic static boolean allElementsSameType(java.lang.Object[] array)
array - the array to be checkedpublic static void sleep(long millis)
millis - the milliseconds to sleep