Class ToolContext
java.lang.Object
org.apache.velocity.tools.ToolContext
- All Implemented Interfaces:
org.apache.velocity.context.Context
Context implementation that keeps a list of Toolboxes
and returns them as requested, using its internal context Map as the
dynamic properties passed to the requested tools when they are first
created.- Version:
- $Id: ToolContext.java 511959 2007-02-26 19:24:39Z nbubna $
- Author:
- Nathan Bubna
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionToolContext(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToolbox(Toolbox toolbox) booleancontainsKey(String key) protected ObjectString[]getKeys()Returns aMapof all tools available to this context.Gets a map of keys to classes for all available tools.booleanDefault istrue.protected ObjectinternalGet(String key) keySet()voidvoidputToolProperties(Map<String, Object> props) putToolProperty(String key, Object value) voidputVelocityEngine(org.apache.velocity.app.VelocityEngine engine) Puts the specified VelocityEngine in the tool properties, as well as the Log for that engine.voidsetUserCanOverwriteTools(boolean overwrite) Set whether or not tool references can be overwritten within a template.
-
Field Details
-
PATH_KEY
- See Also:
-
CONTEXT_KEY
- See Also:
-
ENGINE_KEY
- See Also:
-
LOCALE_KEY
- See Also:
-
LOG_KEY
- See Also:
-
TOOLKEY_KEY
- See Also:
-
CATCH_EXCEPTIONS_KEY
- See Also:
-
-
Constructor Details
-
ToolContext
public ToolContext() -
ToolContext
public ToolContext(org.apache.velocity.app.VelocityEngine engine) Creates an instance that automatically has the specified VelocityEngine and related tool properties set.- Parameters:
engine- VelocityEngine instance
-
ToolContext
-
-
Method Details
-
setUserCanOverwriteTools
public void setUserCanOverwriteTools(boolean overwrite) Set whether or not tool references can be overwritten within a template. The default value istrue. Set this to false if you want to ensure that your tool references are never replaced within the course of a template.- Parameters:
overwrite- flag value
-
getUserCanOverwriteTools
public boolean getUserCanOverwriteTools()Default istrue.- Returns:
- flag value
- See Also:
-
addToolbox
-
getToolbox
-
getToolClassMap
-
getToolboxes
-
getToolProperties
-
putVelocityEngine
public void putVelocityEngine(org.apache.velocity.app.VelocityEngine engine) Puts the specified VelocityEngine in the tool properties, as well as the Log for that engine. Last, if the specified engine has a MethodExceptionEventHandler configured, then this will automatically setCATCH_EXCEPTIONS_KEYto false in the tool properties.- Parameters:
engine- VelocityEngine instance
-
putToolProperty
-
putToolProperties
-
put
-
get
-
internalGet
-
findTool
-
keySet
-
containsKey
- Specified by:
containsKeyin interfaceorg.apache.velocity.context.Context
-
getKeys
- Specified by:
getKeysin interfaceorg.apache.velocity.context.Context
-
remove
-
putAll
-