FileDocCategorySizeDatePackage
ParamList.javaAPI DocGlassfish v2 API5265Fri May 04 22:33:18 BST 2007com.sun.enterprise.admin.common

ParamList

public class ParamList extends Object implements Serializable
ParamList encapsulates a list of Param objects

The exact storage method is an implementation detail. ParamList is intended to be used by building it, then using it; it is not intended for removal, sorting, etc operations.

author
Lloyd Chambers
version
1.0

Fields Summary
public static long
serialVersionUID
private Vector
mParams
private static final String
kDelimiterString
private static final int
kInitialCapacity
Constructors Summary
public ParamList()
Constructs a new, empty ParamList with a small initial capacity.


			         	
	
		
	
		mParams	= new Vector( kInitialCapacity );
	
Methods Summary
public voidaddParam(Param param)
Adds a new paramater to the list. If the same parameter is passed again, it will replace the existing one.

param
param the Param to be added to the list

            //Assert.insist(param!=null, "null");
            int elementIndex =  mParams.indexOf( param );
            boolean paramExists = ( elementIndex != -1 );
            
            if( paramExists ) 
            {
                mParams.setElementAt ( param, elementIndex );
            }
            else
            {
                mParams.add( param );
            }
	
public voidaddParam(java.lang.String name, java.io.Serializable value)
Adds a new paramater to the end of the list by creating it from the specified name and value.

param
name the name to be used to create the Param
param
value the value to be used to create the Param

		this.addParam( new Param (name, value ) );
	
public java.util.IteratorgetElements()
Returns an Iterator which can be used to iterate through all Params in the list.

return
an Iterator object

		// rely on built-in capability of vector
		return ( mParams.iterator( ) );
	
public ParamgetParam(java.lang.String name)
Finds a parameter, given its name. Names are case-sensitive.

param
name the name of the parameter
return
a Param if found, otherwise null

		Param	resultParam	= null;

		final int	numItems	= mParams.size( );
		
                Iterator iter = getElements( );
                while ( iter.hasNext( ) )
                {
                    Param aParam = ( Param )iter.next( );
                    
                    if( name.equals( aParam.mName ) )
                    {
			resultParam = aParam;
			break;
                    }                    
                }

                return ( resultParam );
	
public java.lang.StringtoString()
Constructs a String representation of the ParamList.

The resulting String is of the form: "name: value, name: value, ..."

return
an String represention of the list

		Iterator	iter	= getElements();

		StringBuffer	buf	= new StringBuffer( 256 );

		while ( iter.hasNext() )
		{
			Param	item	= (Param)iter.next();

			buf.append( item );
			buf.append( kDelimiterString );
		}
		// strip last trailing comma
		if ( buf.length() != 0 )
		{
			buf.setLength( buf.length() - kDelimiterString.length() );
		}

		return( new String( buf ) );