ParamListpublic class ParamList extends Object implements SerializableParamList 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. |
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 void | addParam(Param param)Adds a new paramater to the list. If the same
parameter is passed again, it will replace the existing one.
//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 void | addParam(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.
this.addParam( new Param (name, value ) );
| public java.util.Iterator | getElements()Returns an Iterator which can be used to iterate through all Params
in the list.
// rely on built-in capability of vector
return ( mParams.iterator( ) );
| public Param | getParam(java.lang.String name)Finds a parameter, given its name. Names are case-sensitive.
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.String | toString()Constructs a String representation of the ParamList.
The resulting String is of the form:
"name: value, name: value, ..."
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 ) );
|
|