FileDocCategorySizeDatePackage
ListUtil.javaAPI DocGlassfish v2 API5108Fri May 04 22:31:06 BST 2007com.sun.appserv.management.util.misc

ListUtil

public final class ListUtil extends Object

Fields Summary
Constructors Summary
private ListUtil()

		// disallow instantiation
	
Methods Summary
public static voidaddArray(java.util.List list, T[] array)
Add all items in an array to a list.

		for( int i = 0; i < array.length; ++i )
		{
			list.add( array[ i ] );
		}
	
public static java.util.ListnewList(T m1, T m2, T m3, T m4, T m5)
Create a new List with four members.

		final List<T> 	list	= new ArrayList<T> ();
		
		list.add( m1 );
		list.add( m2 );
		list.add( m3 );
		list.add( m4 );
		list.add( m5 );
		
		return( list );
	
public static java.util.ListnewList(T m1)
Create a new List with one member.

		final List<T>	list	= new ArrayList<T>();
		
		list.add( m1 );
		
		return( list );
	
public static java.util.ListnewList(T m1, T m2)
Create a new List with two members.

		final List<T>	list	= new ArrayList<T>();
		
		list.add( m1 );
		list.add( m2 );
		
		return( list );
	
public static java.util.ListnewList(T m1, T m2, T m3)
Create a new List with three members.

		final List<T> 	list	= new ArrayList<T>();
		
		list.add( m1 );
		list.add( m2 );
		list.add( m3 );
		
		return( list );
	
public static java.util.ListnewList(T m1, T m2, T m3, T m4)
Create a new List with four members.

		final List<T> 	list	= new ArrayList<T> ();
		
		list.add( m1 );
		list.add( m2 );
		list.add( m3 );
		list.add( m4 );
		
		return( list );
	
public static java.util.ListnewListFromArray(T[] items)

		final List<T>	list	= new ArrayList<T>();
		
		for( int i = 0; i < items.length; ++i )
		{
			list.add( items[ i ] );
		}

		return( list );
	
public static java.util.ListnewListFromCollection(java.util.Collection c)
Create a new List from a Collection

		final List<T>	list	= new ArrayList<T>();
		
		list.addAll( c );
		
		return( list );
	
public static java.util.ListnewListFromIterator(java.util.Iterator iter)
Create a new List from a Collection

		final List<T>	list	= new ArrayList<T>();
		
		while ( iter.hasNext() )
		{
			list.add( iter.next() );
		}
		
		return( list );
	
public static java.util.Listreverse(java.util.List list)
Return a new List in reverse order. Because the List is new, it works on any list, modifiable or not.

		final int	numItems	= list.size();
		final List<T> result		= new ArrayList<T>( numItems );
		
		for( int i = 0; i < numItems; ++i )
		{
			result.add( list.get( numItems - i -1 ) );
		}
		
		return( result );
	
public static java.lang.String[]toStringArray(java.util.List list)
Convert a List to a String[]

		final String[]	names	= new String[ list.size() ];
		
		int i   = 0;
		for( final Object o : list )
		{
		    names[ i ] = "" + o;
		    ++i;
		}
		
		return( names );