|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractList
org.mmbase.util.functions.Parameters
Parameters for functions, a way to make variable arguments in Java. In fact this class does nothing more then providing a convenient way to create a List, by 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.
Parameter,
Parameters(Parameter[])| Field Summary | |
protected boolean |
autoCasting
|
protected java.util.Map |
backing
The contents of this List are stored in this HashMap. |
protected Parameter[] |
definition
This array maps integers (position in array) to map keys, making it possible to implement List. |
static Parameters |
VOID
No need to bother for the functions with no parameters. |
| Fields inherited from class java.util.AbstractList |
modCount |
| Constructor Summary | |
Parameters(Parameter[] def)
Constructor, taking an Parameter[] array argument. |
|
Parameters(Parameter[] def,
java.util.List values)
If you happen to have a List of parameters, then you can wrap it into an Parameters with this constructor. |
|
| Method Summary | |
void |
checkRequiredParameters()
Throws IllegalArgumentException if one of the required parameters is null. |
protected static java.util.List |
define(Parameter[] def,
java.util.List list)
Adds the definitions to a List. |
java.lang.Object |
get(int i)
|
java.lang.Object |
get(Parameter arg)
|
static Parameters |
get(Parameter[] def,
java.util.List args)
Converts a certain List to an Parameters if it is not already one. |
java.lang.Object |
get(java.lang.String arg)
|
java.lang.String |
getString(Parameter arg)
|
java.lang.String |
getString(java.lang.String arg)
|
boolean |
hasParameter(Parameter arg)
Checks wether a certain parameter is available. |
boolean |
isAutoCasting()
Whether this Parameters object is 'automaticly casting'. |
java.lang.Object |
set(int i,
java.lang.Object value)
|
Parameters |
set(Parameter arg,
java.lang.Object value)
|
Parameters |
set(java.lang.String arg,
java.lang.Object value)
Sets the value of an argument. |
Parameters |
setAll(java.util.Map map)
|
void |
setAutoCasting(boolean ac)
Sets the 'auto casting' property (which on default is false) |
Parameters |
setIfDefined(java.lang.String arg,
java.lang.Object value)
Sets the value of an argument, if the argument is defined, otherwise do nothing. |
int |
size()
|
java.lang.Class[] |
toClassArray()
When using reflection, you might need the Parameters as a Class[]. |
java.util.Map |
toMap()
Gives the arguments back as a (unmodifiable) map. |
java.lang.String |
toString()
|
| Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, subList, toArray, toArray |
| Field Detail |
public static final Parameters VOID
protected java.util.Map backing
protected Parameter[] definition
protected boolean autoCasting
| Constructor Detail |
public Parameters(Parameter[] def)
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
};
public Parameters(Parameter[] def,
java.util.List values)
java.lang.NullPointerException - if definition is nullParameters(Parameter[])| Method Detail |
public static Parameters get(Parameter[] def,
java.util.List args)
public java.lang.String toString()
public java.lang.Class[] toClassArray()
java.lang.NullPointerException - if definition is null
protected static java.util.List define(Parameter[] def,
java.util.List list)
public void setAutoCasting(boolean ac)
isAutoCasting()public boolean isAutoCasting()
public int size()
size in interface java.util.Listpublic java.lang.Object get(int i)
get in interface java.util.List
public java.lang.Object set(int i,
java.lang.Object value)
set in interface java.util.Listpublic void checkRequiredParameters()
public boolean hasParameter(Parameter arg)
public Parameters set(java.lang.String arg,
java.lang.Object value)
java.lang.IllegalArgumentException - if either the argument name is unknown to this Parameters, or the value is of the wrong type.
java.lang.NullPointerException - if definition not set
public Parameters set(Parameter arg,
java.lang.Object value)
public Parameters setAll(java.util.Map map)
public Parameters setIfDefined(java.lang.String arg,
java.lang.Object value)
java.lang.NullPointerException - if definition not setpublic java.lang.Object get(java.lang.String arg)
public java.lang.Object get(Parameter arg)
public java.lang.String getString(java.lang.String arg)
public java.lang.String getString(Parameter arg)
public java.util.Map toMap()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||