public class ToolboxFactory
extends java.lang.Object
This class is the central point of action for VelocityTools.
It manages the configured and scoped ToolInfo and Data
and is meant to stick around for the life of the application.
It works like this:
FactoryConfiguration(s)ToolboxFactory instanceconfigure(org.apache.velocity.tools.config.FactoryConfiguration)createToolbox(java.lang.String)
to create the Toolbox for that scope and put that toolbox
somewhere appropriate to that scope.Toolbox and
ask it for the tool you want (e.g. toolbox.get("math")).
Of course, most users will not have to do any of this
as much of it is handled for them by some combination of
ToolManager or VelocityView
and a ToolContext or ViewToolContext.
NOTE: While you are free to pass in new configuration info
at any time, that data will only affect Toolboxes created subsequently.
Any previously created toolboxes will have to be re-created and replaced to
reflect the changes to the configuration.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
data |
static java.lang.String |
DEFAULT_SCOPE |
private java.util.Map<java.lang.String,java.lang.Object> |
globalProperties |
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> |
scopedProperties |
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,ToolInfo>> |
scopedToolInfo |
| Constructor and Description |
|---|
ToolboxFactory() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToolInfo(java.lang.String scope,
ToolInfo tool) |
void |
configure(FactoryConfiguration config) |
Toolbox |
createToolbox(java.lang.String scope) |
java.util.Map<java.lang.String,java.lang.Object> |
getData() |
java.lang.Object |
getGlobalProperty(java.lang.String name) |
protected java.util.Map<java.lang.String,ToolInfo> |
getToolInfo(java.lang.String scope) |
boolean |
hasTools(java.lang.String scope) |
protected java.lang.Object |
putData(java.lang.String key,
java.lang.Object value) |
protected void |
putGlobalProperties(java.util.Map<java.lang.String,java.lang.Object> props) |
protected void |
putProperties(java.lang.String scope,
java.util.Map<java.lang.String,java.lang.Object> props) |
public static final java.lang.String DEFAULT_SCOPE
private final java.util.Map<java.lang.String,java.util.Map<java.lang.String,ToolInfo>> scopedToolInfo
private final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> scopedProperties
private java.util.Map<java.lang.String,java.lang.Object> data
private java.util.Map<java.lang.String,java.lang.Object> globalProperties
public void configure(FactoryConfiguration config)
protected java.lang.Object putData(java.lang.String key,
java.lang.Object value)
protected void addToolInfo(java.lang.String scope,
ToolInfo tool)
protected java.util.Map<java.lang.String,ToolInfo> getToolInfo(java.lang.String scope)
protected void putGlobalProperties(java.util.Map<java.lang.String,java.lang.Object> props)
protected void putProperties(java.lang.String scope,
java.util.Map<java.lang.String,java.lang.Object> props)
public java.lang.Object getGlobalProperty(java.lang.String name)
public java.util.Map<java.lang.String,java.lang.Object> getData()
public boolean hasTools(java.lang.String scope)
public Toolbox createToolbox(java.lang.String scope)
Copyright (c) 2003-2007 Apache Software Foundation