Class DVSL

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  DVSL.LogAdapter  
    • Constructor Summary

      Constructors 
      Constructor Description
      DVSL()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      private void configureVelocityEngine​(org.apache.velocity.app.VelocityEngine ve, java.util.Map map)
      Adds the allowed properties from the Properties to the velocity engine
      java.lang.Object getAppValue​(java.lang.Object key)
      Gets the application value for the specified key
      static void main​(java.lang.String[] args)
      Allows command-line access.
      protected void makeReady()
      sets up all the context goodies
      java.lang.Object putAppValue​(java.lang.Object key, java.lang.Object value)
      Sets the application value for the specified key
      void setClassLoader​(java.lang.ClassLoader classLoader)
      Specify a classloader for loading the Toolbox classes.
      void setLogChute​(org.apache.velocity.runtime.log.LogChute logger)
      lets the user specify a class instance for logging.
      void setLogFile​(java.io.File logFile)
      lets the user specify a filename for logging.
      void setLogSystem​(org.apache.velocity.runtime.log.LogSystem logger)
      Deprecated.
      use setLogChute instead
      void setStylesheet​(java.io.File stylesheet)
      Convenience function.
      void setStylesheet​(java.io.File stylesheet, java.lang.String stylesheetEncoding)
      Convenience function.
      void setStylesheet​(java.io.Reader styleReader)
      Sets the stylesheet for this transformation set
      void setStylesheet​(java.lang.String stylesheet)
      Convenience function.
      void setToolbox​(java.util.Properties p)
      Loads the toolbox from the input Properties.
      void setUserContext​(org.apache.velocity.context.Context ctx)
      Sets the user context.
      void setValidatingParser​(boolean validate)
      Uses a validating parser on all input documents
      void setVelocityConfig​(java.util.Map map)
      lets the user pass a java.util.Properties containing properties for the configuration of the VelocityEngine used by DVSL
      long transform​(java.io.File f, java.io.Writer writer)  
      long transform​(java.io.InputStream is, java.io.Writer writer)  
      long transform​(java.io.Reader reader, java.io.Writer writer)  
      long transform​(java.lang.String infile, java.io.Writer writer)  
      long transform​(org.dom4j.Document dom4jdoc, java.io.Writer writer)
      Transforms the given dom4j Document into the writer.
      protected long xform​(java.io.Reader reader, java.io.Writer writer)
      does the transformation of the inputstream into the output writer
      protected long xform​(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

      • TOOL_PROP_PREFIX

        private static java.lang.String TOOL_PROP_PREFIX
      • STRING_PROP_PREFIX

        private static java.lang.String STRING_PROP_PREFIX
      • INTEGER_PROP_PREFIX

        private static java.lang.String INTEGER_PROP_PREFIX
      • TOOLBOX_NAME

        private static java.lang.String TOOLBOX_NAME
      • ve

        private org.apache.velocity.app.VelocityEngine ve
      • currentDocument

        private org.dom4j.Document currentDocument
      • currentWriter

        private java.io.Writer currentWriter
      • toolContext

        private org.apache.velocity.context.Context toolContext
      • userContext

        private org.apache.velocity.context.Context userContext
      • styleContext

        private org.apache.velocity.context.Context styleContext
      • classLoader

        private java.lang.ClassLoader classLoader
      • ready

        private boolean ready
      • velConfig

        private java.util.Map velConfig
      • logFile

        private java.io.File logFile
      • logger

        private org.apache.velocity.runtime.log.LogChute logger
      • appVals

        private java.util.Map appVals
      • validate

        boolean validate
    • Constructor Detail

      • DVSL

        public DVSL()
    • Method Detail

      • setLogFile

        public void setLogFile​(java.io.File logFile)

        lets the user specify a filename for logging.

      • setLogSystem

        public void setLogSystem​(org.apache.velocity.runtime.log.LogSystem logger)
        Deprecated.
        use setLogChute instead

        lets the user specify a class instance for logging.

      • setLogChute

        public void setLogChute​(org.apache.velocity.runtime.log.LogChute logger)

        lets the user specify a class instance for logging.

      • setVelocityConfig

        public void setVelocityConfig​(java.util.Map map)

        lets the user pass a java.util.Properties containing properties for the configuration of the VelocityEngine used by DVSL

      • setUserContext

        public void setUserContext​(org.apache.velocity.context.Context ctx)

        Sets the user context. The user context is a Velocity Context containing user-supplied objects and data that are to be made available in the template

        Parameters:
        ctx - User context of data
      • setValidatingParser

        public void setValidatingParser​(boolean validate)

        Uses a validating parser on all input documents

        Parameters:
        validate -
      • setClassLoader

        public void setClassLoader​(java.lang.ClassLoader classLoader)

        Specify a classloader for loading the Toolbox classes. Setting to null resets to the default ClassLoader.

        Parameters:
        classLoader - ClassLoader or null for default ClassLoader
      • setToolbox

        public void setToolbox​(java.util.Properties p)
                        throws java.lang.ClassNotFoundException,
                               java.lang.InstantiationException,
                               java.lang.IllegalAccessException

        Loads the toolbox from the input Properties.

        Currently supports specification of the Toolbox name in the context, creating classes, and string and integer values. Ex :

          toolbox.contextname = floyd
          toolbox.tool.footool = Footool
          toolbox.string.mystring = Hello there!
          toolbox.integer.myint = 7
          toolbox.string.sourcebase = ./xdocs/
          

        So in template, this toolbox and it's values would be accessed as :

            $context.floyd.footool.getFoo()
            $context.floyd.mystring
            $context.floyd.myint
          
        Throws:
        java.lang.ClassNotFoundException
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • setStylesheet

        public void setStylesheet​(java.lang.String stylesheet)
                           throws java.lang.Exception
        Convenience function. See...
        Throws:
        java.lang.Exception
      • setStylesheet

        public void setStylesheet​(java.io.File stylesheet)
                           throws java.lang.Exception
        Convenience function. See...
        Throws:
        java.lang.Exception
      • setStylesheet

        public void setStylesheet​(java.io.File stylesheet,
                                  java.lang.String stylesheetEncoding)
                           throws java.lang.Exception
        Convenience function. See...
        Throws:
        java.lang.Exception
      • setStylesheet

        public void setStylesheet​(java.io.Reader styleReader)
                           throws java.lang.Exception

        Sets the stylesheet for this transformation set

        Note that don't need this for each document you want to transform. Just do it once, and transform away...

        Parameters:
        styleReader - Reader with stylesheet char stream
        Throws:
        java.lang.Exception
      • configureVelocityEngine

        private void configureVelocityEngine​(org.apache.velocity.app.VelocityEngine ve,
                                             java.util.Map map)

        Adds the allowed properties from the Properties to the velocity engine

        So far, we support, in RuntimeConstant parlance :

        • VM_LIBRARY
        • FILE_RESOURCE_LOADER_PATH
        • RUNTIME_LOG
        • RUNTIME_LOG_LOGSYSTEM
        • RUNTIME_LOG_LOGSYSTEM_CLASS

        If you are going to use this, ensure you do it *before* setting the stylesheet, as that creates the VelocityEngine

      • makeReady

        protected void makeReady()
        sets up all the context goodies
      • xform

        protected long xform​(java.io.Reader reader,
                             java.io.Writer writer)
                      throws java.lang.Exception
        does the transformation of the inputstream into the output writer
        Throws:
        java.lang.Exception
      • xform

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

        public long transform​(java.io.File f,
                              java.io.Writer writer)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • transform

        public long transform​(java.io.Reader reader,
                              java.io.Writer writer)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • transform

        public long transform​(java.io.InputStream is,
                              java.io.Writer writer)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • transform

        public long transform​(org.dom4j.Document dom4jdoc,
                              java.io.Writer writer)
                       throws java.lang.Exception
        Transforms the given dom4j Document into the writer.
        Parameters:
        dom4jdoc - dom4j Document object
        writer - Writer for output
        Throws:
        java.lang.Exception
      • transform

        public long transform​(java.lang.String infile,
                              java.io.Writer writer)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getAppValue

        public java.lang.Object getAppValue​(java.lang.Object key)
        Gets the application value for the specified key
        Parameters:
        key - key to use to retrieve value
        Returns:
        value if found, null otherwise
      • putAppValue

        public java.lang.Object putAppValue​(java.lang.Object key,
                                            java.lang.Object value)
        Sets the application value for the specified key
        Parameters:
        key - key to use to store value
        value - value to be stored
        Returns:
        old value if any, null otherwise
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception

        Allows command-line access.

        Usage : java -jar dvsl.jar -STYLE stylesheeet [-IN infile] [-OUT outfile] [-TOOL toolboxname]

        Throws:
        java.lang.Exception