Package org.apache.commons.jexl3
Class JxltEngine
- java.lang.Object
-
- org.apache.commons.jexl3.JxltEngine
-
- Direct Known Subclasses:
TemplateEngine
public abstract class JxltEngine extends java.lang.ObjectA simple "JeXL Template" engine.At the base is an evaluator similar to the Unified EL evaluator used in JSP/JSF based on JEXL. At the top is a template engine inspired by Velocity that uses JEXL (instead of OGNL/VTL) as the scripting language.
The evaluator is intended to be used in configuration modules, XML based frameworks or JSP taglibs and facilitate the implementation of expression evaluation.
The template engine is intended to output any form of text; html, XML, CSV...
- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJxltEngine.ExceptionThe sole type of (runtime) exception the JxltEngine can throw.static interfaceJxltEngine.ExpressionA unified expression that can mix immediate, deferred and nested sub-expressions as well as string constants; The "immediate" syntax is of the form"...${jexl-expr}..."The "deferred" syntax is of the form"...#{jexl-expr}..."The "nested" syntax is of the form"...#{...${jexl-expr0}...}..."The "composite" syntax is of the form"...${jexl-expr0}...static interfaceJxltEngine.TemplateA template is a JEXL script that evaluates by writing its content through a Writer.
-
Constructor Summary
Constructors Constructor Description JxltEngine()Default constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclearCache()Clears the cache.JxltEngine.ExpressioncreateExpression(java.lang.String expression)Creates aJxltEngine.Expressionfrom an expression string.abstract JxltEngine.ExpressioncreateExpression(JexlInfo info, java.lang.String expression)Creates aJxltEngine.Expressionfrom an expression string.JxltEngine.TemplatecreateTemplate(java.lang.String source)Creates a new template.JxltEngine.TemplatecreateTemplate(java.lang.String prefix, java.io.Reader source, java.lang.String... parms)Creates a new template.JxltEngine.TemplatecreateTemplate(java.lang.String source, java.lang.String... parms)Creates a new template.JxltEngine.TemplatecreateTemplate(JexlInfo info, java.lang.String source)Creates a new template.abstract JxltEngine.TemplatecreateTemplate(JexlInfo info, java.lang.String prefix, java.io.Reader source, java.lang.String... parms)Creates a new template.JxltEngine.TemplatecreateTemplate(JexlInfo info, java.lang.String source, java.lang.String... parms)Creates a new template.abstract JexlEnginegetEngine()Gets theJexlEngineunderlying this template engine.
-
-
-
Method Detail
-
clearCache
public abstract void clearCache()
Clears the cache.
-
createExpression
public abstract JxltEngine.Expression createExpression(JexlInfo info, java.lang.String expression)
Creates aJxltEngine.Expressionfrom an expression string. Uses and fills up the expression cache if any.If the underlying JEXL engine is silent, errors will be logged through its logger as warnings.
- Parameters:
info- theJexlInfosource informationexpression- theJxltEngine.Templatestring expression- Returns:
- the
JxltEngine.Expression, null if silent and an error occurred - Throws:
JxltEngine.Exception- if an error occurs and theJexlEngineis not silent
-
createExpression
public JxltEngine.Expression createExpression(java.lang.String expression)
Creates aJxltEngine.Expressionfrom an expression string. Uses and fills up the expression cache if any.If the underlying JEXL engine is silent, errors will be logged through its logger as warnings.
- Parameters:
expression- theJxltEngine.Templatestring expression- Returns:
- the
JxltEngine.Expression, null if silent and an error occurred - Throws:
JxltEngine.Exception- if an error occurs and theJexlEngineis not silent
-
createTemplate
public JxltEngine.Template createTemplate(JexlInfo info, java.lang.String source)
Creates a new template.- Parameters:
info- the source infosource- the source- Returns:
- the template
-
createTemplate
public abstract JxltEngine.Template createTemplate(JexlInfo info, java.lang.String prefix, java.io.Reader source, java.lang.String... parms)
Creates a new template.- Parameters:
info- the jexl info (file, line, column)prefix- the directive prefixsource- the sourceparms- the parameter names- Returns:
- the template
-
createTemplate
public JxltEngine.Template createTemplate(JexlInfo info, java.lang.String source, java.lang.String... parms)
Creates a new template.- Parameters:
info- the source infoparms- the parameter namessource- the source- Returns:
- the template
-
createTemplate
public JxltEngine.Template createTemplate(java.lang.String source)
Creates a new template.- Parameters:
source- the source- Returns:
- the template
-
createTemplate
public JxltEngine.Template createTemplate(java.lang.String prefix, java.io.Reader source, java.lang.String... parms)
Creates a new template.- Parameters:
prefix- the directive prefixsource- the sourceparms- the parameter names- Returns:
- the template
-
createTemplate
public JxltEngine.Template createTemplate(java.lang.String source, java.lang.String... parms)
Creates a new template.- Parameters:
source- the sourceparms- the parameter names- Returns:
- the template
-
getEngine
public abstract JexlEngine getEngine()
Gets theJexlEngineunderlying this template engine.- Returns:
- the JexlEngine
-
-