|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.knowceans.util.ArrayUtils
public class ArrayUtils
ArrayUtils provides functionality for conversion between primitive and object arrays and lists as well as a copying method for arrays of arbitrary type and dimensions. For array arguments, reflection and Object arguments are chosen as an alternative to overloading. Hopefully, this class will be obsolete in Java 1.6...
Field Summary | |
---|---|
static java.lang.Class[][] |
types
|
Constructor Summary | |
---|---|
ArrayUtils()
|
Method Summary | |
---|---|
static java.util.List<?> |
asList(java.lang.Object array)
Convert an array of primitive-type elements into a list of its wrapper-type elements. |
static java.lang.Object |
asPrimitiveArray(java.util.List<? extends java.lang.Object> objects)
Convert an list of objects into an array of primitive types. |
static java.lang.Object |
asPrimitiveArray(java.util.List<? extends java.lang.Object> objects,
java.lang.Class<?> type)
Convert an list of objects into an array of primitive types. |
static java.lang.Object[] |
convert(java.lang.Object array)
Get an array of the wrapper type corresponding to the primitive element type of the argument. |
static java.lang.Object |
convert(java.lang.Object[] objects)
Get an array of the number type corresponding to the element type of the argument. |
static java.lang.Object |
copy(java.lang.Object array)
Create a copy of the argument array. |
static void |
copy(java.lang.Object target,
java.lang.Object array)
Create a copy of the argument array in the pointer provided, which is assumed to be of the same dimensions than array. |
static boolean |
isArray(java.lang.Object s)
determines whether an object is an array and has nonzero length |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Class[][] types
Constructor Detail |
---|
public ArrayUtils()
Method Detail |
---|
public static void main(java.lang.String[] args)
public static java.lang.Object convert(java.lang.Object[] objects)
The contract is that the element runtime type is equal for all elements in the array and no null element is included, otherwise runtime exceptions will be thrown. If the array has size 0, the class type is determined by the component type, resulting in null return value if the array was not initialised as an Wrapper[] where wrapper is one of the primitive wrapper object types excluding Void.
objects
- object array with elements of primitive wrapper classes
excluding Void.
public static java.lang.Object[] convert(java.lang.Object array)
array
- array of a primitive type
public static java.util.List<?> asList(java.lang.Object array)
array
-
public static java.lang.Object asPrimitiveArray(java.util.List<? extends java.lang.Object> objects)
objects
-
public static java.lang.Object asPrimitiveArray(java.util.List<? extends java.lang.Object> objects, java.lang.Class<?> type)
objects
- sample
- object (instantiate primitive array[0] if objects.size = 0)
public static java.lang.Object copy(java.lang.Object array)
array
-
public static void copy(java.lang.Object target, java.lang.Object array)
Note: This method is rather slow. Use System.arraycopy for scalability.
array
- whose content is copiedtarget
- array whose content is overwritten (same size as array).public static boolean isArray(java.lang.Object s)
s
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |