FileDocCategorySizeDatePackage
ArrayConversion.javaAPI DocGlassfish v2 API5479Fri May 04 22:25:56 BST 2007com.sun.enterprise.admin.util

ArrayConversion

public final class ArrayConversion extends Object

Fields Summary
Constructors Summary
private ArrayConversion()

		// disallow instantiation
	
Methods Summary
private static java.lang.Object[]convert(java.lang.Object simpleArray)

		final String className	= simpleArray.getClass().getName();
		
		//final String	memberClassName	= ClassUtil.getArrayMemberClassName( className );
		
		final Class		theClass = ClassUtil.getArrayElementClass( simpleArray.getClass() );
		
		final int numItems	= Array.getLength( simpleArray );
		
		final Class elementClass	= ClassUtil.PrimitiveClassToObjectClass( theClass );
		
		final Object []	result	= (Object [])Array.newInstance( elementClass, numItems );
		
		for( int i = 0; i < numItems; ++i )
		{
			result[ i ]	= Array.get( simpleArray, i );
		}
		
		return( result );
	
public static java.lang.Object[]createObjectArrayType(java.lang.Class elementType, int size)

		final Object [] result	= (Object []) Array.newInstance( elementType, size );
		
		return( result );
	
public static java.lang.Object[]setToArray(java.util.Set s)

		final java.util.Iterator	iter	= s.iterator();
		
		final Object []	out	= new Object [ s.size() ];
		
		return( setToArray( s, out ) );
	
public static java.lang.Object[]setToArray(java.util.Set s, java.lang.Object[] out)

		final java.util.Iterator	iter	= s.iterator();
		
		if ( out.length != s.size() )
		{
			throw new IllegalArgumentException();
		}
		
		int	i = 0;
		while ( iter.hasNext() )
		{
			out[ i ]	= iter.next();
			++i;
		}
		
		return( out );
	
public static java.lang.Object[]toAppropriateType(java.lang.Object array)

		return( (Object [])convert( array ) );
	
public static java.lang.Boolean[]toBooleans(boolean[] array)

		return( (Boolean [])convert( array ) );
	
public static java.lang.Byte[]toBytes(byte[] array)

		return( (Byte [])convert( array ) );
	
public static java.lang.Character[]toCharacters(char[] array)

		return( (Character [])convert( array ) );
	
public static java.lang.Double[]toDoubles(double[] array)

		return( (Double [])convert( array ) );
	
public static java.lang.Float[]toFloats(float[] array)

		return( (Float [])convert( array ) );
	
public static java.lang.Integer[]toIntegers(int[] array)

		return( (Integer [])convert( array ) );
	
public static java.lang.Long[]toLongs(long[] array)

		return( (Long [])convert( array ) );
	
public static java.util.SettoSet(java.lang.Object[] array)

		java.util.Set	theSet	= null;
		if ( array.length == 0 )
		{
			theSet	= java.util.Collections.EMPTY_SET;
		}
		else if ( array.length == 1 )
		{
			theSet	= java.util.Collections.singleton( array[ 0 ] );
		}
		else
		{
			theSet	= new java.util.HashSet();
			for( int i = 0; i < array.length; ++i )
			{
				theSet.add( array[ i ] );
			}
		}
		return( theSet );
	
public static java.lang.Short[]toShorts(short[] array)

		return( (Short [])convert( array ) );