Class ParameterAccessor


  • public abstract class ParameterAccessor
    extends Object
    Accessor class for looking up global parameters.

    Profile specific parameters are stored under the "global-parameters" selector (see ResourceConfig). The parameter values are stored in the <param> elements within this Content Delivery Resource definition. This class iterates over the list of ResourceConfig 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, ContentDeliveryConfig) method, returning whatever Java type defined by the ParameterDecoder implementation. As an example, see TokenizedStringParameterDecoder.

    Author:
    tfennelly
    • 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

      • 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 - The ContentDeliveryConfig for 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 - The ContentDeliveryConfig for the requesting device.
        Returns:
        Parameter value, or null if not set.
      • 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,
                                              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.
      • setParameter

        public static void setParameter​(String name,
                                        Object value,
                                        Smooks smooks)
      • removeParameter

        public static void removeParameter​(String name,
                                           Smooks smooks)