public class ToolContext extends Object implements org.apache.velocity.context.Context
Context
implementation that keeps a list of Toolbox
es
and returns them as requested, using its internal context Map as the
dynamic properties passed to the requested tools when they are first
created.Modifier and Type | Field and Description |
---|---|
static String |
CATCH_EXCEPTIONS_KEY |
static String |
CONTEXT_KEY |
static String |
ENGINE_KEY |
static String |
LOCALE_KEY |
static String |
LOG_KEY |
static String |
PATH_KEY |
static String |
TOOLKEY_KEY |
Constructor and Description |
---|
ToolContext() |
ToolContext(Map<String,Object> toolProps)
Creates an instance starting with the specified tool properties.
|
ToolContext(org.apache.velocity.app.VelocityEngine engine)
Creates an instance that automatically has the specified
VelocityEngine and related tool properties set.
|
Modifier and Type | Method and Description |
---|---|
void |
addToolbox(Toolbox toolbox) |
boolean |
containsKey(String key) |
protected Object |
findTool(String key) |
Object |
get(String key) |
String[] |
getKeys() |
Map<String,Object> |
getToolbox()
Returns a
Map of all tools available to this
context. |
protected List<Toolbox> |
getToolboxes() |
Map<String,Class> |
getToolClassMap()
Gets a map of keys to classes for all available tools.
|
protected Map<String,Object> |
getToolProperties() |
boolean |
getUserCanOverwriteTools()
Default is
true . |
protected Object |
internalGet(String key) |
Set<String> |
keySet() |
Object |
put(String key,
Object value) |
void |
putAll(Map context) |
void |
putToolProperties(Map<String,Object> props) |
Object |
putToolProperty(String key,
Object value) |
void |
putVelocityEngine(org.apache.velocity.app.VelocityEngine engine)
Puts the specified VelocityEngine in the tool properties,
as well as the Log for that engine.
|
Object |
remove(String key) |
void |
setUserCanOverwriteTools(boolean overwrite)
Set whether or not tool references can be overwritten within a template.
|
public static final String PATH_KEY
public static final String CONTEXT_KEY
public static final String ENGINE_KEY
public static final String LOCALE_KEY
public static final String LOG_KEY
public static final String TOOLKEY_KEY
public static final String CATCH_EXCEPTIONS_KEY
public ToolContext()
public ToolContext(org.apache.velocity.app.VelocityEngine engine)
engine
- VelocityEngine instancepublic void setUserCanOverwriteTools(boolean overwrite)
true
. Set this to false if you want to
ensure that your tool references are never replaced within the course
of a template.overwrite
- flag valuepublic boolean getUserCanOverwriteTools()
true
.setUserCanOverwriteTools(boolean)
public void addToolbox(Toolbox toolbox)
public Map<String,Object> getToolbox()
Map
of all tools available to this
context. NOTE: this is not a cheap operation as it will
request and initialize an instance of every available tool.public Map<String,Class> getToolClassMap()
public void putVelocityEngine(org.apache.velocity.app.VelocityEngine engine)
CATCH_EXCEPTIONS_KEY
to false in the tool properties.engine
- VelocityEngine instancepublic Object put(String key, Object value)
put
in interface org.apache.velocity.context.Context
public Object get(String key)
get
in interface org.apache.velocity.context.Context
public boolean containsKey(String key)
containsKey
in interface org.apache.velocity.context.Context
public String[] getKeys()
getKeys
in interface org.apache.velocity.context.Context
public Object remove(String key)
remove
in interface org.apache.velocity.context.Context
public void putAll(Map context)
Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.