Class TransformerBaseTag<T>

  • Type Parameters:
    T - the type of service object created by this tag
    All Implemented Interfaces:
    ConditionalTag, PropertiesSupport, PropertySupport, org.apache.commons.jelly.DynaTag, org.apache.commons.jelly.impl.BeanSource, org.apache.commons.jelly.Tag
    Direct Known Subclasses:
    TransformerTag, ValidatorBaseTag

    public abstract class TransformerBaseTag<T>
    extends UseBeanBaseTag
    implements PropertiesSupport

    A base class for tags that create transformers or validators.

    This class provides common functionality for creating service objects for field handlers. It determines the InputComponentTag this tag is nested inside and prepares the passing of the newly created transformer or validator. Concrete sub classes only have to call the correct set method on the input component tag.

    The transformer or validator itself is created using the functionality provided by the ancestor UseBeanTag. This results in a reference to a bean. For this bean properties can be defined by tags specified in the body of this tag. When the bean is invoked these properties are then taken into account.

    Version:
    $Id: TransformerBaseTag.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • TransformerBaseTag

        public TransformerBaseTag()
        Creates a new instance of TransformerBaseTag.
      • TransformerBaseTag

        public TransformerBaseTag​(Class<?> defClass)
        Creates a new instance of TransformerBaseTag and sets the default class.
        Parameters:
        defClass - the default class
    • Method Detail

      • getProperties

        public Map<String,​Object> getProperties()
        Returns properties for the created bean.
        Returns:
        properties
      • setProperties

        public void setProperties​(Map<String,​Object> properties)
        Sets properties for the created bean. It is possible to define properties for a specific transformer or validator. These properties are stored and are available through the TransformerContext interface. Using this mechanism it is possible to customize the behavior of a transformer or validator for a specific invocation.
        Specified by:
        setProperties in interface PropertiesSupport
        Parameters:
        properties - the properties for the current bean
      • getTransformerContext

        protected TransformerContext getTransformerContext()
        Returns a TransformerContext for the managed bean. If no properties have been set, the global context is returned. Otherwise a wrapped context is created that takes the properties into account.
        Returns:
        a TransformerContext to be used for the managed bean
      • handleOtherParent

        protected boolean handleOtherParent​(org.apache.commons.jelly.Tag parent,
                                            T bean)
                                     throws org.apache.commons.jelly.JellyTagException
        Processes the parent tag. This method is called if the parent of this tag is no InputComponentTag. This base implementation will simply return false in this case (because per default only input component tags are supported as parents). If a derived class supports other parent tags, this method can be overridden.
        Parameters:
        parent - the parent tag
        bean - the bean created by this tag
        Returns:
        a flag whether the parent tag is supported
        Throws:
        org.apache.commons.jelly.JellyTagException - if an error occurs
      • passResults

        protected boolean passResults​(Object bean)
                               throws org.apache.commons.jelly.JellyTagException
        Passes the bean to its target. This implementation checks whether the parent of this tag is an InputComponentTag. If yes, handleInputComponentTag() will be called. Otherwise handleOtherParent() is invoked.
        Overrides:
        passResults in class UseBeanBaseTag
        Parameters:
        bean - the affected bean
        Returns:
        a flag whether the bean could be passed to a target
        Throws:
        org.apache.commons.jelly.JellyTagException - if an error occurs
      • handleInputComponentTag

        protected abstract void handleInputComponentTag​(InputComponentTag tag,
                                                        T bean)
                                                 throws org.apache.commons.jelly.JellyTagException
        Passes the bean to the given InputComponentTag. This method is called when this tag is placed inside the body of an InputComponentTag. Derived classes can here perform the necessary steps to initialize the input component tag.
        Parameters:
        tag - the input component tag
        bean - the bean
        Throws:
        org.apache.commons.jelly.JellyTagException - if an error occurs