Class Transformer

  • All Implemented Interfaces:
    TransformTool

    class Transformer
    extends java.lang.Object
    implements TransformTool

    Class responsible for actual transformation of documents.

    Note that this class is not threadsafe.

    Author:
      • Field Summary

        Fields 
        Modifier and Type Field Description
        private java.util.Map appValue
        HashMap to hold application values
        private org.apache.velocity.context.Context baseContext
        basic context passed to us - can contain tools and such for use.
        private DVSLNodeContext currentContext
        context used during processing.
        private org.dom4j.io.SAXReader saxReader
        SAXReader that we reuse for every document.
        private TemplateHandler templateHandler  
        private org.apache.velocity.app.VelocityEngine ve
        Instance of VelocityEngine we are currently using.
      • Constructor Summary

        Constructors 
        Modifier Constructor Description
        private Transformer()
        "Sealed for your protection."
          Transformer​(org.apache.velocity.app.VelocityEngine ve, TemplateHandler th, org.apache.velocity.context.Context context, java.util.Map applicationValues, boolean validate)
        Sole public CTOR.
      • Method Summary

        All Methods Instance Methods Concrete Methods 
        Modifier and Type Method Description
        java.lang.String applyTemplates()  
        java.lang.String applyTemplates​(java.lang.String path)
        Applies templates in the current stylesheet to the nodeset returned by the XPath expression
        java.lang.String applyTemplates​(DVSLNode node)  
        java.lang.String applyTemplates​(DVSLNode node, java.lang.String xpath)  
        java.lang.String copy()  
        java.lang.Object get​(java.lang.String key)  
        java.lang.Object getAppValue​(java.lang.Object key)  
        private void invoke​(DVSLNode element, java.io.Writer writer)  
        java.lang.Object putAppValue​(java.lang.Object key, java.lang.Object value)  
        (package private) long transform​(java.io.Reader reader, java.io.Writer writer)
        Method that performs the transformation on a document
        protected long transform​(DVSLNode root, java.io.Writer writer)  
        (package private) long transform​(org.dom4j.Document dom4jdoc, java.io.Writer writer)  
        • Methods inherited from class java.lang.Object

          clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ve

        private org.apache.velocity.app.VelocityEngine ve
        Instance of VelocityEngine we are currently using. This must be reset with a stylesheeet change
      • saxReader

        private org.dom4j.io.SAXReader saxReader
        SAXReader that we reuse for every document. Much faster.
      • baseContext

        private org.apache.velocity.context.Context baseContext
        basic context passed to us - can contain tools and such for use. Is protected from change via wrapping
      • currentContext

        private DVSLNodeContext currentContext
        context used during processing. Wraps the baseContext
      • appValue

        private java.util.Map appValue
        HashMap to hold application values
    • Constructor Detail

      • Transformer

        public Transformer​(org.apache.velocity.app.VelocityEngine ve,
                           TemplateHandler th,
                           org.apache.velocity.context.Context context,
                           java.util.Map applicationValues,
                           boolean validate)
        Sole public CTOR. We rely on the caller to give us a VelocityEngine ready with all macros registered. The context is the callers context with all tools and style drek.
      • Transformer

        private Transformer()
        "Sealed for your protection."
    • Method Detail

      • transform

        long transform​(java.io.Reader reader,
                       java.io.Writer writer)
                throws java.lang.Exception
        Method that performs the transformation on a document
        Parameters:
        reader - XML document char stream
        writer - Writer to output transformation to
        Throws:
        java.lang.Exception
      • transform

        long transform​(org.dom4j.Document dom4jdoc,
                       java.io.Writer writer)
                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • transform

        protected long transform​(DVSLNode root,
                                 java.io.Writer writer)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • invoke

        private void invoke​(DVSLNode element,
                            java.io.Writer writer)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • get

        public java.lang.Object get​(java.lang.String key)
        Specified by:
        get in interface TransformTool
      • applyTemplates

        public java.lang.String applyTemplates​(DVSLNode node,
                                               java.lang.String xpath)
                                        throws java.lang.Exception
        Specified by:
        applyTemplates in interface TransformTool
        Throws:
        java.lang.Exception
      • applyTemplates

        public java.lang.String applyTemplates​(DVSLNode node)
                                        throws java.lang.Exception
        Specified by:
        applyTemplates in interface TransformTool
        Throws:
        java.lang.Exception
      • applyTemplates

        public java.lang.String applyTemplates()
                                        throws java.lang.Exception
        Specified by:
        applyTemplates in interface TransformTool
        Throws:
        java.lang.Exception
      • applyTemplates

        public java.lang.String applyTemplates​(java.lang.String path)
                                        throws java.lang.Exception
        Description copied from interface: TransformTool

        Applies templates in the current stylesheet to the nodeset returned by the XPath expression

        Specified by:
        applyTemplates in interface TransformTool
        Parameters:
        path - XPath expression to select nodes
        Returns:
        The rendered result
        Throws:
        java.lang.Exception
      • copy

        public java.lang.String copy()
        Specified by:
        copy in interface TransformTool
      • getAppValue

        public java.lang.Object getAppValue​(java.lang.Object key)
        Specified by:
        getAppValue in interface TransformTool
      • putAppValue

        public java.lang.Object putAppValue​(java.lang.Object key,
                                            java.lang.Object value)
        Specified by:
        putAppValue in interface TransformTool