|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opensha.commons.param.ParameterList
public class ParameterList
Title: ParameterList
Description: List container for parameters. Specialized version of Hashtable. The keys of the hashtable are the names of the parameters. Can add specialized iterators so that it returns only specific types of paramters, i.e. return all DoubleParameters.
This class assumes that two parameters are equal if they have the same name. This implies that parameters have unique names. This must be the case for all functions below that take a String name as an argument would fail if two or more parameters have the same name.
An additional complication is that Parameters can have a constraint with a different name. To handle this a mapping has to be generated such that constraint name can be mapped back to the original parameter name. This is accomplished via a hashtable. This is only performed in the occasional case when the constraint name differs. In most cases the parameter name and constraint name will be identical. Due to uniqueness of parameter names this implies that all constraint names must be unique also, when differing from the constraint name.
Note: Many of these functions are duplicated, where one form takes a Parameter as input, and the second takes the Parameter name as a String as input. THe first case can extract the parameter name, and proxy the method call to the String name form.
4/3/2002 SWR
WARNING - This class needs a little more work and a JUnit test case.
I added constraint names but didn't fully implement updating and removing
parameters with differing constraint names, only implemented addParameter
fully.
| Field Summary | |
|---|---|
protected static String |
C
Class name for debugging. |
protected Hashtable<String,String> |
constraintNameMap
Internal list of constraint name mapped to parameter name. |
protected static boolean |
D
If true print out debug statements. |
protected ArrayList<Parameter<?>> |
params
Internal vector list of parameters. |
| Constructor Summary | |
|---|---|
ParameterList()
no arg constructor. |
|
| Method Summary | ||
|---|---|---|
void |
addParameter(Parameter param)
Adds the parameter to the internal sotrage of parameters if it doesn't exist, else throws exception. |
|
void |
addParameterList(ParameterList list2)
Adds all parameters of the parameterlist to this one, if the named parameter is not already in the list. |
|
void |
clear()
Removes all parameters from the list, making it empty, ready for new parameters. |
|
Object |
clone()
Returns a copy of this list, therefore any changes to the copy cannot affect this original list. |
|
int |
compareTo(Object obj)
compares 2 ParameterList to see if they are equal. |
|
boolean |
containsParameter(Parameter param)
Checks if the parameter exists in the list. |
|
boolean |
containsParameter(String paramName)
Checks if the parameter exists in the list. |
|
boolean |
equalNames(ParameterList list)
Returns true if all the parameters have the same names. |
|
boolean |
equals(Object obj)
Returns true if all the parameters have the same names and values. |
|
|
getParameter(Class<T> type,
String name)
Returns a Parameter of the given name, cast to the given type. |
|
Parameter |
getParameter(String name)
Returns parameter if exist else throws exception. |
|
String |
getParameterListMetadataString()
this function iterates over all the parameters in the parematerList and get their metadata in the string format. |
|
String |
getParameterListMetadataString(String delimiter)
|
|
String |
getParameterName(String name)
Maps back the constraint name to parameter name if this is a constraint name. |
|
ListIterator<String> |
getParameterNamesIterator()
Returns an iterator of all parameter names of the paramters in the list. |
|
ListIterator<Parameter<?>> |
getParametersIterator()
Returns an iterator of all parameters in the list. |
|
String |
getType(String name)
Returns parameter type of named parameter in list, if not exist throws exception. |
|
Object |
getValue(String name)
Returns parameter contained value object if the parameter exist, else throws exception. |
|
Iterator<Parameter<?>> |
iterator()
|
|
void |
removeParameter(Parameter param)
Removes parameter if it exists, else throws exception. |
|
void |
removeParameter(String name)
Removes parameter if it exists, else throws exception. |
|
void |
replaceParameter(String parameterName,
Parameter param)
Searches for the named parameter, then replaces the parameter it is currently editing. |
|
static boolean |
setParamsInListFromXML(ParameterList paramList,
Element paramListEl)
|
|
void |
setValue(String name,
Object value)
Set's a new value to a Parameter in the list if it exists, else throws exception. |
|
int |
size()
Returns the number of parameters in the list. |
|
String |
toString()
Prints out all parameters in this list. |
|
void |
updateParameter(Parameter param)
Updates an existing parameter with the new value. |
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final String C
protected static final boolean D
protected ArrayList<Parameter<?>> params
protected Hashtable<String,String> constraintNameMap
| Constructor Detail |
|---|
public ParameterList()
| Method Detail |
|---|
public void addParameterList(ParameterList list2)
throws ParameterException
ParameterException
public void addParameter(Parameter param)
throws ParameterException
ParameterExceptionpublic String getParameterName(String name)
name - The value to check if it is a constraint
public Parameter getParameter(String name)
throws ParameterException
ParameterException
public <T> Parameter<T> getParameter(Class<T> type,
String name)
getParameter(String.class, "MyStringParameter") would return a
Parameter
type - name -
public Object getValue(String name)
throws ParameterException
ParameterException
public void setValue(String name,
Object value)
throws ParameterException,
ConstraintException
ParameterException
ConstraintException
public String getType(String name)
throws ParameterException
ParameterExceptionpublic boolean containsParameter(Parameter param)
public boolean containsParameter(String paramName)
public void removeParameter(Parameter param)
throws ParameterException
ParameterException
public void removeParameter(String name)
throws ParameterException
ParameterException
public void updateParameter(Parameter param)
throws ParameterException
ParameterExceptionpublic ListIterator<Parameter<?>> getParametersIterator()
public void replaceParameter(String parameterName,
Parameter param)
parameterName - : Name of the parameter that is being removedparam - : New parameter that is replacing the old parameterpublic int compareTo(Object obj)
obj - instance of ParameterList
public ListIterator<String> getParameterNamesIterator()
public void clear()
public int size()
public boolean equals(Object obj)
equals in class Objectpublic boolean equalNames(ParameterList list)
public Object clone()
clone in class Objectpublic String toString()
toString in class Objectpublic String getParameterListMetadataString()
public String getParameterListMetadataString(String delimiter)
public Iterator<Parameter<?>> iterator()
iterator in interface Iterable<Parameter<?>>
public static boolean setParamsInListFromXML(ParameterList paramList,
Element paramListEl)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||