com.flexive.shared.configuration.parameters
Class ParameterFactory

java.lang.Object
  extended by com.flexive.shared.configuration.parameters.ParameterFactory

public final class ParameterFactory
extends java.lang.Object

This factory beans provides methods for instantiating new parameter objects to be used with flexive's configuration API. To create a typesafe parameter definition, you must supply the parameter class (e.g. Long) and the attributes describing the parameter itself, such as the (global) path it's stored under and its scope (e.g. user- or division-scoped).

:

 // define a boolean parameter "booleanParam" for path "/configuration" with a default value of false
 Parameter<Boolean> bp = ParameterFactory.newInstance(Boolean.class, "/configuration", ParameterScope.USER, "booleanParam", false);

 // define a long parameter with a default value of 25
 Parameter<Long> lp = ParameterFactory.newInstance(Long.class, "/configuration", ParameterScope.USER, "longParam", 25L);

 // define an object parameter for QueryRootNode.class with no default value that works by serializing the objects via XStream
 Parameter<QueryRootNode> DEFAULT_QUERY = ParameterFactory.newInstance(QueryRootNode.class, "/configuration", ParameterScope.USER, "defaultQuery", null);
 
More examples can be found in SystemParameters.

Version:
$Rev: 2906 $
Author:
Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Method Summary
static
<T> Parameter<T>
newInstance(java.lang.Class<T> cls, ParameterData<T> data)
          Creates a new parameter from a ParameterData instance.
static
<T> Parameter<T>
newInstance(java.lang.Class<T> cls, ParameterPath path, boolean cached, T defaultValue)
          Create a new parameter without a specific key and a default value.
static
<T> Parameter<T>
newInstance(java.lang.Class<T> cls, ParameterPath path, java.lang.String key, boolean cached, T defaultValue)
          Create a new parameter with key and default value, using path information from a ParameterPath object.
static
<T> Parameter<T>
newInstance(java.lang.Class<T> cls, ParameterPath path, java.lang.String key, T defaultValue)
          Create a new parameter with key and default value, using path information from a ParameterPath object.
static
<T> Parameter<T>
newInstance(java.lang.Class<T> cls, ParameterPath path, T defaultValue)
          Create a new parameter without a specific key and a default value.
static
<T> Parameter<T>
newInstance(java.lang.Class<T> cls, java.lang.String path, ParameterScope scope, java.lang.String key, T defaultValue)
          Create a new parameter for a path with key and default value.
static
<T> Parameter<T>
newInstance(java.lang.Class<T> cls, java.lang.String path, ParameterScope scope, T defaultValue)
          Create a new parameter for a path with a default value, but without a fixed key.
static Parameter newInstance(java.lang.String className, ParameterData data)
          Return a generic parameter using a fully qualified class name.
static
<T> Parameter<T>
newXStreamInstance(java.lang.Class<T> cls, ParameterPath path, java.lang.String key, boolean cached, T defaultValue, com.thoughtworks.xstream.XStream instance)
          Create a new parameter that uses a custom XStream instance for serialization.
static
<T> Parameter<T>
newXStreamInstance(java.lang.Class<T> cls, java.lang.String path, ParameterScope scope, java.lang.String key, boolean cached, T defaultValue, com.thoughtworks.xstream.XStream instance)
          Create a new parameter that uses a custom XStream instance for serialization.
static Parameter newXStreamInstance(java.lang.String className, ParameterData data, com.thoughtworks.xstream.XStream instance)
          Return a generic parameter using a fully qualified class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static <T> Parameter<T> newInstance(java.lang.Class<T> cls,
                                           ParameterData<T> data)
Creates a new parameter from a ParameterData instance.

Parameters:
cls - the parameter type class
data - the bean holding all parameter properties
Returns:
a new parameter instance

newInstance

public static <T> Parameter<T> newInstance(java.lang.Class<T> cls,
                                           ParameterPath path,
                                           java.lang.String key,
                                           T defaultValue)
Create a new parameter with key and default value, using path information from a ParameterPath object.

Parameters:
cls - the parameter type class
path - the path description
key - the parameter key
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance

newInstance

public static <T> Parameter<T> newInstance(java.lang.Class<T> cls,
                                           ParameterPath path,
                                           java.lang.String key,
                                           boolean cached,
                                           T defaultValue)
Create a new parameter with key and default value, using path information from a ParameterPath object.

Parameters:
cls - the parameter type class
path - the path description
key - the parameter key
cached - if the value should be cached once it has been retrieved (default: true)
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance
Since:
3.1.4

newInstance

public static <T> Parameter<T> newInstance(java.lang.Class<T> cls,
                                           ParameterPath path,
                                           T defaultValue)
Create a new parameter without a specific key and a default value. The key has to be specified in configuration queries. This is useful for dynamic keys, e.g. for storing user preferences for different pages (using the page path for the key).

Parameters:
cls - the parameter type class
path - the path description
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance

newInstance

public static <T> Parameter<T> newInstance(java.lang.Class<T> cls,
                                           ParameterPath path,
                                           boolean cached,
                                           T defaultValue)
Create a new parameter without a specific key and a default value. The key has to be specified in configuration queries. This is useful for dynamic keys, e.g. for storing user preferences for different pages (using the page path for the key).

Parameters:
cls - the parameter type class
path - the path description
cached - if the value should be cached once it has been retrieved (default: true)
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance
Since:
3.1.4

newInstance

public static <T> Parameter<T> newInstance(java.lang.Class<T> cls,
                                           java.lang.String path,
                                           ParameterScope scope,
                                           java.lang.String key,
                                           T defaultValue)
Create a new parameter for a path with key and default value.

Parameters:
cls - the parameter type class
path - the path description
scope - the parameter scope (user, division, or global)
key - the parameter key
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance

newInstance

public static <T> Parameter<T> newInstance(java.lang.Class<T> cls,
                                           java.lang.String path,
                                           ParameterScope scope,
                                           T defaultValue)
Create a new parameter for a path with a default value, but without a fixed key. The key has to be specified in configuration queries. This is useful for dynamic keys, e.g. for storing user preferences for different pages (using the page path for the key).

Parameters:
cls - the parameter type class
path - the path description
scope - the parameter scope (user, division, or global)
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance

newInstance

public static Parameter newInstance(java.lang.String className,
                                    ParameterData data)
Return a generic parameter using a fully qualified class name.

Parameters:
className - the class name for the value type of the parameter
data - the parameter data bean
Returns:

newXStreamInstance

public static Parameter newXStreamInstance(java.lang.String className,
                                           ParameterData data,
                                           com.thoughtworks.xstream.XStream instance)
Return a generic parameter using a fully qualified class name.

Parameters:
className - the class name for the value type of the parameter
data - the parameter data bean
instance - XStream instance to use for object parameters
Returns:
Parameter

newXStreamInstance

public static <T> Parameter<T> newXStreamInstance(java.lang.Class<T> cls,
                                                  ParameterPath path,
                                                  java.lang.String key,
                                                  boolean cached,
                                                  T defaultValue,
                                                  com.thoughtworks.xstream.XStream instance)
Create a new parameter that uses a custom XStream instance for serialization.

Type Parameters:
T - the parameter type (must not be a boxed primitive type, e.g. Integer, which is never handled with XStream)
Parameters:
cls - the parameter type class
path - the path description
key - the parameter key
cached - if the value should be cached once it has been retrieved (default: true)
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance
Since:
3.2.0

newXStreamInstance

public static <T> Parameter<T> newXStreamInstance(java.lang.Class<T> cls,
                                                  java.lang.String path,
                                                  ParameterScope scope,
                                                  java.lang.String key,
                                                  boolean cached,
                                                  T defaultValue,
                                                  com.thoughtworks.xstream.XStream instance)
Create a new parameter that uses a custom XStream instance for serialization.

Type Parameters:
T - the parameter type (must not be a boxed primitive type, e.g. Integer, which is never handled with XStream)
Parameters:
cls - the parameter type class
path - the path
scope - the scope
key - the parameter key
cached - if the value should be cached once it has been retrieved (default: true)
defaultValue - the default value (if null, no default value will be used)
Returns:
a new parameter instance
Since:
3.2.0