|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.btw.commons.ArrayUtils
public final class ArrayUtils
Array utilities.
| Nested Class Summary | |
|---|---|
static class |
ArrayUtils.ArrayEnumeration
Converts given object into an enumeration. |
| Method Summary | |
|---|---|
static void |
addAll(Vector vector,
Object copyFrom)
Appends all items from given array after last item of the vector. |
static void |
addAll(Vector vector,
Object[] copyFrom)
Appends all items from given array after last item of the vector. |
static void |
addAll(Vector vector,
Vector copyFrom)
Appends all items from given array after last item of the vector. |
static Enumeration |
arrayToEnumeration(Object array)
Creates an enumeration from given object. |
static String |
arrayToString(Object array)
Converts given array to a string representation. |
static void |
checkIsArray(Object array,
boolean allowEnumeration)
Checks if given object is an array, as per isArray(Object). |
static Object |
clone(Object array,
boolean deep)
Clones given array. |
static boolean |
equals(Enumeration enum1,
Enumeration enum2)
Compares two enumerations if they contain equal objects in correct order. |
static boolean |
equals(Enumeration enum1,
Object[] enum2)
Compares two enumerations if they contain equal objects in correct order. |
static boolean |
equals(Object[] enum1,
Object[] enum2)
Compares two arrays if they contain equal objects in correct order. |
static boolean |
equals(Object enum1,
Object enum2)
Compares two arrays if they contain equal objects in correct order. |
static boolean |
equalsObjects(Object o1,
Object o2)
The ultimate comparator. |
static Object |
getElementAt(Object array,
int index)
Retrieves item from given array. |
static int |
getLength(Object array)
Returns length of given array. |
static int |
hashCode(Object object)
Computes correct hashcode for given object. |
static int |
indexOf(Vector vector,
Object obj)
Finds first occurence of given object in given vector. |
static boolean |
isArray(Object array)
Returns true if given object is an array or a Queue, a
Vector or an ArrayUtils.ArrayEnumeration. |
static void |
setElementAt(Object array,
int index,
Object object)
Sets item into given array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static int indexOf(Vector vector,
Object obj)
Object.equals(Object) is used.
vector - vectorobj - object to find, may be null.
public static void addAll(Vector vector,
Object[] copyFrom)
vector - here all items will be appended.copyFrom - array to append.
public static void addAll(Vector vector,
Object copyFrom)
vector - here all items will be appended.copyFrom - array to append. See arrayToEnumeration(Object) for
details. Does not support ArrayUtils.ArrayEnumeration.
public static void addAll(Vector vector,
Vector copyFrom)
vector - here all items will be appended.copyFrom - vector to append.
public static boolean equals(Enumeration enum1,
Enumeration enum2)
enum1 - first enumerationenum2 - second enumeration
true if two enumerations match, false
otherwise.
public static boolean equalsObjects(Object o1,
Object o2)
nulls and arrays
correctly.
o1 - first object.o2 - second object.
true if objects equals, false
otherwise.
public static boolean equals(Enumeration enum1,
Object[] enum2)
enum1 - first enumerationenum2 - second enumeration
true if two enumerations match, false
otherwise.
public static boolean equals(Object[] enum1,
Object[] enum2)
enum1 - first arrayenum2 - second array
true if two enumerations match, false
otherwise.
public static boolean equals(Object enum1,
Object enum2)
arrayToEnumeration(Object).
enum1 - first arrayenum2 - second array
true if two enumerations match, false
otherwise.
IllegalArgumentException - if the object is not an array.public static int hashCode(Object object)
object - the object to compute hash from. It will compute correct
hashcode from arrays and enumerations aswell.
0 if null was given.public static Enumeration arrayToEnumeration(Object array)
Queue or a Vector then
their enumerations are returned instead.
array - the object to convert to an enumeration.
IllegalArgumentException - if the object is none of the above.public static boolean isArray(Object array)
Queue, a
Vector or an ArrayUtils.ArrayEnumeration.
array - the array instance.
true if given object is an array,
false if it is a regular object or
null.
public static void checkIsArray(Object array,
boolean allowEnumeration)
isArray(Object).
array - the array to checkallowEnumeration - if true then enumeration is allowed as a valid
array type.
IllegalArgumentException - if given object is not array.public static int getLength(Object array)
Returns length of given array.
Note: there is no way to get number of items for Enumeration but to walk through it. This effectively 'destroys' given enumeration instance as it is no longer usable.
array - the array to check. See arrayToEnumeration(Object)
for details.
public static Object getElementAt(Object array,
int index)
array - the array instance. For details please see
arrayToEnumeration(Object).index - the index of array.
public static void setElementAt(Object array,
int index,
Object object)
array - the array instance. For details please see
arrayToEnumeration(Object). Note that Queue
does not support setting of arbitrary item.index - the index of array.object - object to set.
public static Object clone(Object array,
boolean deep)
arrayToEnumeration(Object).
array - the array to clone. ArrayUtils.ArrayEnumerations are not supported.deep - if true then sub-arrays are cloned aswell. Note
that if you introduce a nesting cycle the function will
recurse until stack overflow is reached.
null if
null array was given.public static String arrayToString(Object array)
array - the array to convert.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||