Class VelocityScriptEngineFactory

  • All Implemented Interfaces:
    javax.script.ScriptEngineFactory

    public class VelocityScriptEngineFactory
    extends java.lang.Object
    implements javax.script.ScriptEngineFactory
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.List<java.lang.String> extensions  
      private static java.util.List<java.lang.String> mimeTypes  
      private static java.util.List<java.lang.String> names  
      private static java.util.Properties parameters  
      private static java.lang.String VELOCITY_LANGUAGE  
      private static java.lang.String VELOCITY_NAME  
      private static java.lang.String VELOCITY_VERSION  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getEngineName()
      get engine name
      java.lang.String getEngineVersion()
      get engine version
      java.util.List<java.lang.String> getExtensions()
      get the list of file extensions handled by Velocity: vm, vtl, vhtml
      java.lang.String getLanguageName()
      get language name
      java.lang.String getLanguageVersion()
      get language version (same as engine version)
      java.lang.String getMethodCallSyntax​(java.lang.String obj, java.lang.String m, java.lang.String... args)
      get Velocity syntax for calling method 'm' on object 'obj' with provided arguments
      java.util.List<java.lang.String> getMimeTypes()
      get the list of Velocity mime types
      java.util.List<java.lang.String> getNames()
      get the list of names
      java.lang.String getOutputStatement​(java.lang.String toDisplay)
      get VTL expression used to display specified string
      java.lang.String getParameter​(java.lang.String key)
      get engine parameter for provided key
      java.lang.String getProgram​(java.lang.String... statements)
      get whole VTL program given VTL lines
      javax.script.ScriptEngine getScriptEngine()
      get a Velocity script engine
      • Methods inherited from class java.lang.Object

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

      • VELOCITY_VERSION

        private static final java.lang.String VELOCITY_VERSION
        See Also:
        Constant Field Values
      • VELOCITY_LANGUAGE

        private static final java.lang.String VELOCITY_LANGUAGE
        See Also:
        Constant Field Values
      • names

        private static java.util.List<java.lang.String> names
      • extensions

        private static java.util.List<java.lang.String> extensions
      • mimeTypes

        private static java.util.List<java.lang.String> mimeTypes
      • parameters

        private static java.util.Properties parameters
    • Constructor Detail

      • VelocityScriptEngineFactory

        public VelocityScriptEngineFactory()
    • Method Detail

      • getEngineName

        public java.lang.String getEngineName()
        get engine name
        Specified by:
        getEngineName in interface javax.script.ScriptEngineFactory
        Returns:
        engine name, aka "Velocity"
      • getEngineVersion

        public java.lang.String getEngineVersion()
        get engine version
        Specified by:
        getEngineVersion in interface javax.script.ScriptEngineFactory
        Returns:
        engine version string
      • getExtensions

        public java.util.List<java.lang.String> getExtensions()
        get the list of file extensions handled by Velocity: vm, vtl, vhtml
        Specified by:
        getExtensions in interface javax.script.ScriptEngineFactory
        Returns:
        extensions list
      • getLanguageName

        public java.lang.String getLanguageName()
        get language name
        Specified by:
        getLanguageName in interface javax.script.ScriptEngineFactory
        Returns:
        language name, aka "VTL"
      • getLanguageVersion

        public java.lang.String getLanguageVersion()
        get language version (same as engine version)
        Specified by:
        getLanguageVersion in interface javax.script.ScriptEngineFactory
        Returns:
        language version string
      • getMethodCallSyntax

        public java.lang.String getMethodCallSyntax​(java.lang.String obj,
                                                    java.lang.String m,
                                                    java.lang.String... args)
        get Velocity syntax for calling method 'm' on object 'obj' with provided arguments
        Specified by:
        getMethodCallSyntax in interface javax.script.ScriptEngineFactory
        Parameters:
        obj -
        m -
        args -
        Returns:
        VTL call ${obj.m(args...)}
      • getMimeTypes

        public java.util.List<java.lang.String> getMimeTypes()
        get the list of Velocity mime types
        Specified by:
        getMimeTypes in interface javax.script.ScriptEngineFactory
        Returns:
        singleton { 'text/x-velocity' }
      • getNames

        public java.util.List<java.lang.String> getNames()
        get the list of names
        Specified by:
        getNames in interface javax.script.ScriptEngineFactory
        Returns:
        { 'velocity', 'Velocity' }
      • getOutputStatement

        public java.lang.String getOutputStatement​(java.lang.String toDisplay)
        get VTL expression used to display specified string
        Specified by:
        getOutputStatement in interface javax.script.ScriptEngineFactory
        Parameters:
        toDisplay -
        Returns:
        escaped string #[[toDisplay]]#
      • getParameter

        public java.lang.String getParameter​(java.lang.String key)
        get engine parameter for provided key
        Specified by:
        getParameter in interface javax.script.ScriptEngineFactory
        Parameters:
        key -
        Returns:
        found parameter, or null
      • getProgram

        public java.lang.String getProgram​(java.lang.String... statements)
        get whole VTL program given VTL lines
        Specified by:
        getProgram in interface javax.script.ScriptEngineFactory
        Parameters:
        statements - VTL lines
        Returns:
        lines concatenated with carriage returns
      • getScriptEngine

        public javax.script.ScriptEngine getScriptEngine()
        get a Velocity script engine
        Specified by:
        getScriptEngine in interface javax.script.ScriptEngineFactory
        Returns:
        a new Velocity script engine