org.mmbase.util.functions
Class Parameter

java.lang.Object
  extended byorg.mmbase.util.functions.Parameter
Direct Known Subclasses:
Parameter.Wrapper

public class Parameter
extends java.lang.Object

Entry for Parameters. A (function) argument is specified by a name and type.

Since:
MMBase-1.7
Version:
$Id: Parameter.java,v 1.6.2.1 2004/09/08 15:24:54 michiel Exp $
Author:
Michiel Meeuwissen, Daniel Ockeloen (MMFunctionParam)
See Also:
Parameters

Nested Class Summary
static class Parameter.Wrapper
          A Parameter.Wrapper wraps one Parameter around a Parameter[] (then you can put it in a Parameter[]).
 
Field Summary
static Parameter CLOUD
           
static Parameter LANGUAGE
          Parameter which might be needed in lots of Parameter definitions.
static Parameter LOCALE
           
static Parameter REQUEST
           
static Parameter RESPONSE
           
static Parameter USER
           
 
Constructor Summary
protected Parameter()
           
  Parameter(Parameter p, boolean required)
          Copy-constructor, just to copy it with different requiredness
  Parameter(Parameter p, java.lang.Object defaultValue)
          Copy-constructor, just to copy it with different defaultValue (which implies that it is not required now)
  Parameter(java.lang.String name, java.lang.Class type)
          Create a Parameter object
  Parameter(java.lang.String name, java.lang.Class type, boolean required)
          Create a Parameter object
  Parameter(java.lang.String name, java.lang.Class type, java.lang.Object defaultValue)
          Create a Parameter object
 
Method Summary
protected  java.lang.Object autoCast(java.lang.Object value)
          Tries to 'cast' an object for use with this parameter.
 void checkType(java.lang.Object value)
          Checks if the passed object is of the correct class (compatible with the type of this Parameter), and throws an IllegalArgumentException if it doesn't.
 boolean equals(java.lang.Object o)
          Whether parameter equals to other parameter.
 java.lang.Object getDefaultValue()
          Returns the default value of this parameter.
 java.lang.String getDescription()
          Returns the description of this parameter.
 java.lang.String getName()
          Returns the name or 'key' of this parameter.
 java.lang.Class getType()
          Returns the type of values that this parameter accepts.
 boolean isRequired()
          Returns whether the parameter requires a value.
 void setDefaultValue(java.lang.Object def)
          Sets the default value of this parameter.
 void setDescription(java.lang.String description)
          Sets the description of this parameter.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LANGUAGE

public static final Parameter LANGUAGE
Parameter which might be needed in lots of Parameter definitions.


LOCALE

public static final Parameter LOCALE

USER

public static final Parameter USER

RESPONSE

public static final Parameter RESPONSE

REQUEST

public static final Parameter REQUEST

CLOUD

public static final Parameter CLOUD
Constructor Detail

Parameter

protected Parameter()

Parameter

public Parameter(java.lang.String name,
                 java.lang.Class type)
Create a Parameter object

Parameters:
name - the name of the parameter
type - the class of the parameter's possible value

Parameter

public Parameter(java.lang.String name,
                 java.lang.Class type,
                 boolean required)
Create a Parameter object

Parameters:
name - the name of the parameter
type - the class of the parameter's possible value
required - whether the parameter requires a value (default is false)

Parameter

public Parameter(java.lang.String name,
                 java.lang.Class type,
                 java.lang.Object defaultValue)
Create a Parameter object

Parameters:
name - the name of the parameter
type - the class of the parameter's possible value
defaultValue - the value to use if the parameter has no value set (default is null)

Parameter

public Parameter(Parameter p,
                 boolean required)
Copy-constructor, just to copy it with different requiredness


Parameter

public Parameter(Parameter p,
                 java.lang.Object defaultValue)
Copy-constructor, just to copy it with different defaultValue (which implies that it is not required now)

Method Detail

getName

public java.lang.String getName()
Returns the name or 'key' of this parameter.

Returns:
the name as a String

getDescription

public java.lang.String getDescription()
Returns the description of this parameter.

Returns:
the description as a String

setDescription

public void setDescription(java.lang.String description)
Sets the description of this parameter.

Parameters:
description - the description as a String

getDefaultValue

public java.lang.Object getDefaultValue()
Returns the default value of this parameter.

Returns:
the default value

setDefaultValue

public void setDefaultValue(java.lang.Object def)
Sets the default value of this parameter.

Parameters:
def - the default value

getType

public java.lang.Class getType()
Returns the type of values that this parameter accepts.

Returns:
the type as a Class

isRequired

public boolean isRequired()
Returns whether the parameter requires a value.

Returns:
true if a value is required

checkType

public void checkType(java.lang.Object value)
Checks if the passed object is of the correct class (compatible with the type of this Parameter), and throws an IllegalArgumentException if it doesn't.

Parameters:
value - teh value whose type (class) to check
Throws:
java.lang.IllegalArgumentException - if the type is not compatible

autoCast

protected java.lang.Object autoCast(java.lang.Object value)
Tries to 'cast' an object for use with this parameter. E.g. if value is a String, but this parameter is of type Integer, then the string can be parsed to Integer.

Parameters:
value - The value to be filled in in this Parameter.

equals

public boolean equals(java.lang.Object o)
Whether parameter equals to other parameter. Only key and type are consided. DefaultValue and required propererties are only 'utilities'.

Returns:
true if o is Parameter of which key and type equal to this' key and type.

toString

public java.lang.String toString()


MMBase build 1.7.4.20050922