Class ParameterAccessor
- java.lang.Object
-
- org.smooks.engine.resource.config.ParameterAccessor
-
public abstract class ParameterAccessor extends Object
Accessor class for looking up global parameters. Profile specific parameters are stored under the "global-parameters" selector (seeResourceConfig). The parameter values are stored in the <param> elements within this Content Delivery Resource definition. This class iterates over the list ofResourceConfigelements targeted at theExecutionContextprofile. It looks for a definition of the named parameter. If the <param> has a type attribute theParameterDecoderfor that type can be applied to the attribute value through the#getParameterObject(String, ContentDeliveryConfig)method, returning whatever Java type defined by theParameterDecoderimplementation. As an example, seeTokenizedStringParameterDecoder.- Author:
- tfennelly
-
-
Field Summary
Fields Modifier and Type Field Description static StringGLOBAL_PARAMETERSDevice parameters .cdrl lookup string.
-
Constructor Summary
Constructors Constructor Description ParameterAccessor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Parameter<T>getParameter(String name, Class<T> valueType, Map<String,List<ResourceConfig>> resourceConfigsBySelector)Get the named parameter from the supplied resource config map.static <T> Parameter<T>getParameter(String name, Class<T> valueType, ContentDeliveryConfig config)Get the named parameter.static <T> TgetParameterValue(String name, Class<T> valueType, Map<String,List<ResourceConfig>> resourceConfigsBySelector)Get the named parameter from the supplied resource config map.static <T> TgetParameterValue(String name, Class<T> valueClass, ContentDeliveryConfig config)Get the named parameter String value.static <T> TgetParameterValue(String name, Class<T> valueType, T defaultVal, Map<String,List<ResourceConfig>> config)static <T> TgetParameterValue(String name, Class<T> valueClass, T defaultVal, ContentDeliveryConfig config)Get the named parameter String value.static voidremoveParameter(String name, Smooks smooks)static voidsetParameter(String name, Object value, Smooks smooks)
-
-
-
Field Detail
-
GLOBAL_PARAMETERS
public static final String GLOBAL_PARAMETERS
Device parameters .cdrl lookup string.- See Also:
- Constant Field Values
-
-
Method Detail
-
getParameterValue
public static <T> T getParameterValue(String name, Class<T> valueClass, ContentDeliveryConfig config)
Get the named parameter String value.- Parameters:
name- Name of parameter to get.config- TheContentDeliveryConfigfor the requesting device.- Returns:
- Parameter value, or null if not set.
-
getParameterValue
public static <T> T getParameterValue(String name, Class<T> valueClass, T 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- TheContentDeliveryConfigfor the requesting device.- Returns:
- Parameter value, or null if not set.
-
getParameter
public static <T> Parameter<T> getParameter(String name, Class<T> valueType, ContentDeliveryConfig config)
Get the named parameter. CallsContentDeliveryConfig.getResourceConfigs()to get the configurations map and then passes that togetParameter(String, Class valueType, 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 <T> Parameter<T> getParameter(String name, Class<T> valueType, Map<String,List<ResourceConfig>> resourceConfigsBySelector)
Get the named parameter from the supplied resource config map.- Parameters:
name- The parameter name.resourceConfigsBySelector- The resource configuration map.- Returns:
- The parameter value, or null if not found.
-
getParameterValue
public static <T> T getParameterValue(String name, Class<T> valueType, T defaultVal, Map<String,List<ResourceConfig>> config)
-
getParameterValue
public static <T> T getParameterValue(String name, Class<T> valueType, Map<String,List<ResourceConfig>> resourceConfigsBySelector)
Get the named parameter from the supplied resource config map.- Parameters:
name- The parameter name.resourceConfigsBySelector- The resource configuration map.- Returns:
- The parameter value, or null if not found.
-
-