org.milyn.cdr
Class ParameterAccessor

java.lang.Object
  extended by org.milyn.cdr.ParameterAccessor

public abstract class ParameterAccessor
extends Object

Accessor class for looking up profile specific attributes.

Profile specific parameters are stored under the "device-parameters" selector (see SmooksResourceConfiguration). The parameter values are stored in the <param> elements within this Content Delivery Resource definition. This class iterates over the list of SmooksResourceConfiguration elements targeted at the ExecutionContext profile. It looks for a definition of the named parameter. If the <param> has a type attribute the ParameterDecoder for that type can be applied to the attribute value through the getParameterObject(String,org.milyn.delivery.ContentDeliveryConfig) method, returning whatever Java type defined by the ParameterDecoder implementation. As an example, see TokenizedStringParameterDecoder.

Author:
tfennelly

Field Summary
static String GLOBAL_PARAMETERS
          Device parameters .cdrl lookup string.
 
Constructor Summary
ParameterAccessor()
           
 
Method Summary
static boolean getBoolParameter(String name, boolean defaultVal, ContentDeliveryConfig config)
          Get the named SmooksResourceConfiguration parameter as a boolean.
static Parameter getParameter(String name, Map<String,List<SmooksResourceConfiguration>> resourceConfigurations)
          Get the named parameter from the supplied resource config map.
static Object getParameterObject(String name, ContentDeliveryConfig config)
          Get the named parameter instance (decode).
static Parameter getParamter(String name, ContentDeliveryConfig config)
          Get the named parameter.
static String getStringParameter(String name, ContentDeliveryConfig config)
          Get the named parameter String value.
static String getStringParameter(String name, String defaultVal, ContentDeliveryConfig config)
          Get the named parameter String value.
static void setParameter(String name, String value, Smooks smooks)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL_PARAMETERS

public static final String GLOBAL_PARAMETERS
Device parameters .cdrl lookup string.

See Also:
Constant Field Values
Constructor Detail

ParameterAccessor

public ParameterAccessor()
Method Detail

getParameterObject

public static Object getParameterObject(String name,
                                        ContentDeliveryConfig config)
Get the named parameter instance (decode).

Parameters:
name - Parameter name.
config - Device Delivery Configuration.
Returns:
The Parameter instance for the named parameter (decoded to an Object), or null if not defined.

getStringParameter

public static String getStringParameter(String name,
                                        ContentDeliveryConfig config)
Get the named parameter String value.

Parameters:
name - Name of parameter to get.
config - The ContentDeliveryConfig for the requesting device.
Returns:
Parameter value, or null if not set.

getStringParameter

public static String getStringParameter(String name,
                                        String defaultVal,
                                        ContentDeliveryConfig config)
Get the named parameter String value.

Parameters:
name - Name of parameter to get.
defaultVal - Default value returned if the parameter is not defined.
config - The ContentDeliveryConfig for the requesting device.
Returns:
Parameter value, or null if not set.

getBoolParameter

public static boolean getBoolParameter(String name,
                                       boolean defaultVal,
                                       ContentDeliveryConfig config)
Get the named SmooksResourceConfiguration parameter as a boolean.

Parameters:
name - Name of parameter to get.
defaultVal - The default value to be returned if there are no parameters on the this SmooksResourceConfiguration instance, or the parameter is not defined.
config - The ContentDeliveryConfig for the requesting device.
Returns:
true if the parameter is set to true, defaultVal if not defined, otherwise false.

getParamter

public static Parameter getParamter(String name,
                                    ContentDeliveryConfig config)
Get the named parameter.

Calls ContentDeliveryConfig.getSmooksResourceConfigurations() to get the configurations map and then passes that to getParameter(String, java.util.Map), returning its return value.

Parameters:
name - Parameter name.
config - Device Delivery Configuration.
Returns:
The Parameter instance for the named parameter, or null if not defined.

getParameter

public static Parameter getParameter(String name,
                                     Map<String,List<SmooksResourceConfiguration>> resourceConfigurations)
Get the named parameter from the supplied resource config map.

This method works by looking up

Parameters:
name - The parameter name.
resourceConfigurations - The resource configuration map.
Returns:
The parameter value, or null if not found.

setParameter

public static void setParameter(String name,
                                String value,
                                Smooks smooks)


Copyright © 2008. All Rights Reserved.