org.apache.commons.jexl3.internal
Class TemplateEngine

java.lang.Object
  extended by org.apache.commons.jexl3.JxltEngine
      extended by org.apache.commons.jexl3.internal.TemplateEngine

public final class TemplateEngine
extends JxltEngine

A JxltEngine implementation.

Since:
3.0

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.jexl3.JxltEngine
JxltEngine.Exception, JxltEngine.Expression, JxltEngine.Template
 
Constructor Summary
TemplateEngine(Engine aJexl, boolean noScript, int cacheSize, char immediate, char deferred)
          Creates a new instance of JxltEngine creating a local cache.
 
Method Summary
 void clearCache()
          Clears the cache.
 JxltEngine.Expression createExpression(JexlInfo info, String expression)
          Creates a a JxltEngine.Expression from an expression string.
 TemplateScript createTemplate(JexlInfo info, String prefix, Reader source, String... parms)
          Creates a new template.
 Engine getEngine()
          Gets the JexlEngine underlying this JxltEngine.
protected static Iterator<CharSequence> readLines(Reader reader)
          Read lines from a (buffered / mark-able) reader keeping all new-lines and line-feeds.
protected  List<org.apache.commons.jexl3.internal.TemplateEngine.Block> readTemplate(String prefix, Reader source)
          Reads lines of a template grouping them by typed blocks.
protected  int startsWith(CharSequence sequence, CharSequence pattern)
          Whether a sequence starts with a given set of characters (following spaces).
 
Methods inherited from class org.apache.commons.jexl3.JxltEngine
createExpression, createTemplate, createTemplate, createTemplate, createTemplate, createTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateEngine

public TemplateEngine(Engine aJexl,
                      boolean noScript,
                      int cacheSize,
                      char immediate,
                      char deferred)
Creates a new instance of JxltEngine creating a local cache.

Parameters:
aJexl - the JexlEngine to use.
noScript - whether this engine only allows JEXL expressions or scripts
cacheSize - the number of expressions in this cache, default is 256
immediate - the immediate template expression character, default is '$'
deferred - the deferred template expression character, default is '#'
Method Detail

getEngine

public Engine getEngine()
Gets the JexlEngine underlying this JxltEngine.

Specified by:
getEngine in class JxltEngine
Returns:
the JexlEngine

clearCache

public void clearCache()
Clears the cache.

Specified by:
clearCache in class JxltEngine

createExpression

public JxltEngine.Expression createExpression(JexlInfo info,
                                              String expression)
Description copied from class: JxltEngine
Creates a a JxltEngine.Expression from 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.

Specified by:
createExpression in class JxltEngine
Parameters:
info - the JexlInfo source information
expression - the JxltEngine.Template string expression
Returns:
the JxltEngine.Expression, null if silent and an error occured

startsWith

protected int startsWith(CharSequence sequence,
                         CharSequence pattern)
Whether a sequence starts with a given set of characters (following spaces).

Space characters at beginning of line before the pattern are discarded.

Parameters:
sequence - the sequence
pattern - the pattern to match at start of sequence
Returns:
the first position after end of pattern if it matches, -1 otherwise

readLines

protected static Iterator<CharSequence> readLines(Reader reader)
Read lines from a (buffered / mark-able) reader keeping all new-lines and line-feeds.

Parameters:
reader - the reader
Returns:
the line iterator

readTemplate

protected List<org.apache.commons.jexl3.internal.TemplateEngine.Block> readTemplate(String prefix,
                                                                                    Reader source)
Reads lines of a template grouping them by typed blocks.

Parameters:
prefix - the directive prefix
source - the source reader
Returns:
the list of blocks

createTemplate

public TemplateScript createTemplate(JexlInfo info,
                                     String prefix,
                                     Reader source,
                                     String... parms)
Description copied from class: JxltEngine
Creates a new template.

Specified by:
createTemplate in class JxltEngine
Parameters:
info - the jexl info (file, line, column)
prefix - the directive prefix
source - the source
parms - the parameter names
Returns:
the template


Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.