public class VelocityScriptEngine extends AbstractScriptEngine implements Compilable
Modifier and Type | Class and Description |
---|---|
protected static class |
VelocityScriptEngine.SingleResourceReader |
Modifier and Type | Field and Description |
---|---|
static String |
VELOCITY_PROPERTIES_KEY
Key used to provide this engine with the pathname of the Velocity properties file.
|
context
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
Constructor and Description |
---|
VelocityScriptEngine()
constructs a new standalone Velocity script engine
|
VelocityScriptEngine(ScriptEngineFactory factory)
constructs a new Velocity script engine, linked to the given factory
|
Modifier and Type | Method and Description |
---|---|
CompiledScript |
compile(Reader script)
Compile a template
|
CompiledScript |
compile(String script)
Compile a template
|
Bindings |
createBindings()
creates a new Bindings to be used with this script
|
Object |
eval(Reader reader,
ScriptContext ctx)
Evaluate the given script.
|
Object |
eval(String str,
ScriptContext ctx)
Evaluate the given script.
|
ScriptEngineFactory |
getFactory()
get the factory used to create this script engine
|
protected static String |
getFilename(ScriptContext ctx) |
protected static VelocityContext |
getVelocityContext(ScriptContext ctx) |
protected RuntimeInstance |
getVelocityEngine()
get the internal Velocity RuntimeInstance
|
protected static Properties |
getVelocityProperties(ScriptContext ctx) |
eval, eval, eval, eval, get, getBindings, getContext, getScriptContext, put, setBindings, setContext
public static final String VELOCITY_PROPERTIES_KEY
public VelocityScriptEngine(ScriptEngineFactory factory)
factory
- public VelocityScriptEngine()
protected RuntimeInstance getVelocityEngine()
public Object eval(String str, ScriptContext ctx) throws ScriptException
eval
in interface ScriptEngine
str
- script sourcectx
- script contextScriptException
public Object eval(Reader reader, ScriptContext ctx) throws ScriptException
eval
in interface ScriptEngine
reader
- script source readerctx
- script contextScriptException
public ScriptEngineFactory getFactory()
getFactory
in interface ScriptEngine
public Bindings createBindings()
createBindings
in interface ScriptEngine
protected static VelocityContext getVelocityContext(ScriptContext ctx)
protected static String getFilename(ScriptContext ctx)
protected static Properties getVelocityProperties(ScriptContext ctx)
public CompiledScript compile(String script) throws ScriptException
compile
in interface Compilable
script
- template sourceScriptException
public CompiledScript compile(Reader script) throws ScriptException
compile
in interface Compilable
script
- template sourceScriptException
Copyright © 2000–2017 The Apache Software Foundation. All rights reserved.