Java EE 5 SDK

com.sun.appserv.management.util.misc
Class ArrayConversion

java.lang.Object
  extended by com.sun.appserv.management.util.misc.ArrayConversion

public final class ArrayConversion
extends Object

Provides: - methods to convert arrays of primitive types to corresponding arrays of Object types - conversion to/from Set


Method Summary
static
<T> Set<T>
arrayToSet(T[] names)
           
static Object[] createObjectArrayType(Class elementType, int size)
          Create an array whose type is elementType[] of specified size.
static boolean hasIdenticalElementClasses(Object[] a)
           
static Object[] setToArray(Set<?> s)
          Convert a Set to an Object[].
static Object[] setToArray(Set<?> s, boolean specialize)
          Convert a Set to an array.
static Object[] setToArray(Set<?> s, Object[] out)
          Convert a Set to an Object[].
static Object[] specializeArray(Object[] a)
          Specialize the type of the array (if possible).
static Object[] subArray(Object[] in, int start, int end)
           
static Object[] toAppropriateType(Object array)
          Convert an an array of primitive types to an array of Objects of non-primitive types eg int to Integer.
static Boolean[] toBooleans(boolean[] array)
           
static Byte[] toBytes(byte[] array)
           
static Character[] toCharacters(char[] array)
           
static Double[] toDoubles(double[] array)
           
static Float[] toFloats(float[] array)
           
static Integer[] toIntegers(int[] array)
           
static Long[] toLongs(long[] array)
           
static
<T> Set<T>
toSet(T[] array)
           
static Short[] toShorts(short[] array)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toAppropriateType

public static Object[] toAppropriateType(Object array)
Convert an an array of primitive types to an array of Objects of non-primitive types eg int to Integer.

Parameters:
array - the array to convert

toBooleans

public static Boolean[] toBooleans(boolean[] array)

toCharacters

public static Character[] toCharacters(char[] array)

toBytes

public static Byte[] toBytes(byte[] array)

toShorts

public static Short[] toShorts(short[] array)

toIntegers

public static Integer[] toIntegers(int[] array)

toLongs

public static Long[] toLongs(long[] array)

toFloats

public static Float[] toFloats(float[] array)

toDoubles

public static Double[] toDoubles(double[] array)

createObjectArrayType

public static Object[] createObjectArrayType(Class elementType,
                                             int size)
Create an array whose type is elementType[] of specified size.

Parameters:
elementType - the type of each entry of the array
size - the number of elements

subArray

public static Object[] subArray(Object[] in,
                                int start,
                                int end)

toSet

public static <T> Set<T> toSet(T[] array)

hasIdenticalElementClasses

public static boolean hasIdenticalElementClasses(Object[] a)

specializeArray

public static Object[] specializeArray(Object[] a)
Specialize the type of the array (if possible). For example, if the array is an Object[] of Integer, return an Integer[] of Integer.

Parameters:
a - the array to specialize
Returns:
a specialized array (if possible) otherwise the original array

setToArray

public static Object[] setToArray(Set<?> s,
                                  boolean specialize)
Convert a Set to an array. If specialize is true, then provide the most specialized type possible via specializeArray()

Parameters:
s - the Set to convert
specialize - decide whether to specialize the type or not

setToArray

public static Object[] setToArray(Set<?> s)
Convert a Set to an Object[].

Parameters:
s - the Set to convert

setToArray

public static Object[] setToArray(Set<?> s,
                                  Object[] out)
Convert a Set to an Object[].

Parameters:
s - the Set to convert
out - the output array, must be of size s.size()

arrayToSet

public static <T> Set<T> arrayToSet(T[] names)

Java EE 5 SDK

Submit a bug or feature

Copyright 2006 Sun Microsystems, Inc. All rights reserved.