public class Parameters extends AbstractList(Code)
This class implemements the Parameters interface.
It provides a convenient way to create a List that allows the use of 'named parameters'.
This List is therefore backed by a HashMap, but it behaves as a list. So if you set
a parameter with a certain name, it always appears in the same location of the List.
This List is modifiable but not resizeable. It is always the size of the definition array.
author: Michiel Meeuwissen since: MMBase-1.7 version: $Id: Parameters.java,v 1.39 2008/01/22 16:43:41 michiel Exp $ See Also:Parameter See Also:Parameters.Parameters(Parameter[])
Parameters(Parameter>... def) Constructor, taking an Parameter[] array argument.
The Parameter may also be Parameter.Wrapper
(to implement overriding of functions).
public
Parameters(Parameter>[] def, Collection> values) If you happen to have a List of parameters, then you can wrap it into an Parameters with this constructor.
Parameters: values - Collection with values.
Constructor, taking an Parameter[] array argument.
The Parameter may also be Parameter.Wrapper
(to implement overriding of functions). The idea is that these array arguments are defined
as constants in the classes which define a function with variable arguments.
The Parameter[] array could e.g. be somewhere defined as a constant, like this:
public final static Parameter[] MYFUNCTION_PARAMETERS = {
new Parameter("type", Integer.class),
new Parameter("text", String.class),
Parameter.CLOUD, // a predefined parameter
new Parameter.Wrapper(OTHERFUNCTION_PARAMETERS) // a way to include another definition in this one
};
If you happen to have a List of parameters, then you can wrap it into an Parameters with this constructor.
Parameters: values - Collection with values. This Collection should have a predictable iteration order. throws: NullPointerException - if definition is null See Also:Parameters.Parameters(Parameter[])
Throws an IllegalArgumentException if one of the required parameters was not entered.
containsParameter
public boolean containsParameter(Parameter> parameter)(Code)
Checks wether a certain parameter is available, using the Parameter as a qualifier.
Parameters: parameter - the parameter true if a parameter exists.
containsParameter
public boolean containsParameter(String parameterName)(Code)
Checks wether a certain parameter is available, using the parameter name as a qualifier.
Parameters: parameterName - the name of the parameter true if a parameter exists.
Returns the position of a parameter in the parameters list, using the Parameter as a qualifier.
you can tehn acecss that paramter with
Parameters.get(int) .
Parameters: parameter - the parameter the index of the parameter, or -1 if it doesn't exist
indexOfParameter
public int indexOfParameter(String parameterName)(Code)
Returns the position of a parameter in the parameters list, using the parameter name as a qualifier.
you can then acecss that paramter with
Parameters.get(int) .
Parameters: parameterName - the name of the parameter the index of the parameter, or -1 if it doesn't exist
Sets the value of a parameter.
Parameters: parameter - the Parameter describing the parameter to set Parameters: value - the object value to set throws: IllegalArgumentException - if either the argument name is unknown to this Parameters, or the value is of the wrong type.
Sets the value of a parameter.
Parameters: parameterName - the name of the parameter to set Parameters: value - the object value to set throws: IllegalArgumentException - if either the argument name is unknown to this Parameters, or the value is of the wrong type.
Sets the value of an argument, if the argument is defined, otherwise do nothing.
Parameters: parameter - the parameter to set Parameters: value - the object value to set
Sets the value of an argument, if the argument is defined, otherwise do nothing.
Parameters: parameterName - the name of the parameter to set Parameters: value - the object value to set
Returns the Parameters as an unmodifiable List of Map.Entrys with predictable iteration order
(the same order of this Parameters, which is a List of the values only, itself)
since: MMBase-1.9