@Deprecated public class XMLToolboxManager extends Object implements ToolboxManager
A toolbox manager is responsible for automatically filling the Velocity context with a set of view tools. This class provides the following features:
Configuration
The toolbox manager is configured through an XML-based configuration
file. The configuration file is passed to the load(java.io.InputStream input)
method. The format is shown in the following example:
<?xml version="1.0"?> <toolbox> <tool> <key>date</key> <class>org.apache.velocity.tools.generic.DateTool</class> </tool> <data type="Number"> <key>luckynumber</key> <value>1.37</value> </data> <data type="String"> <key>greeting</key> <value>Hello World!</value> </data> </toolbox>
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
LOG
Deprecated.
|
Constructor and Description |
---|
XMLToolboxManager()
Deprecated.
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addData(ToolInfo info)
Deprecated.
Adds a data object for the context.
|
void |
addTool(ToolInfo info)
Deprecated.
Adds a tool to be managed
|
protected org.apache.commons.digester.RuleSet |
getRuleSet()
Deprecated.
Retrieves the rule set Digester should use to parse and load
the toolbox for this manager.
|
Map |
getToolbox(Object initData)
Deprecated.
Retrieves a map of the tools and data being managed.
|
void |
load(InputStream input)
Deprecated.
Reads an XML document from an
InputStream
and sets up the toolbox from that. |
void |
load(String path)
Deprecated.
Reads an XML document from the specified file path
and sets up the toolbox from that.
|
protected boolean |
validateToolInfo(ToolInfo info)
Deprecated.
Checks whether an object described by a ToolInfo passes
some basic sanity checks.
|
public void addTool(ToolInfo info)
ToolboxManager
addTool
in interface ToolboxManager
public void addData(ToolInfo info)
ToolboxManager
addData
in interface ToolboxManager
info
- An object that implements ToolInfoprotected boolean validateToolInfo(ToolInfo info)
info
- A ToolInfo objectpublic Map getToolbox(Object initData)
ToolboxManager
getToolbox
in interface ToolboxManager
initData
- data used to initialize toolspublic void load(String path) throws Exception
Reads an XML document from the specified file path
and sets up the toolbox from that. If the file does not
exist, an IllegalArgumentException
will be thrown.
path
- the path to the file to be read fromException
public void load(InputStream input) throws Exception
Reads an XML document from an InputStream
and sets up the toolbox from that.
input
- the InputStream to read fromException
protected org.apache.commons.digester.RuleSet getRuleSet()
Retrieves the rule set Digester should use to parse and load the toolbox for this manager.
The DTD corresponding to the default ToolboxRuleSet is:
<?xml version="1.0"?> <!ELEMENT toolbox (tool*,data*,#PCDATA)> <!ELEMENT tool (key,class,parameter*,#PCDATA)> <!ELEMENT data (key,value)> <!ATTLIST data type (string|number|boolean) "string"> <!ELEMENT key (#CDATA)> <!ELEMENT class (#CDATA)> <!ELEMENT parameter (EMPTY)> <!ATTLIST parameter name CDATA #REQUIRED> <!ATTLIST parameter value CDATA #REQUIRED> <!ELEMENT value (#CDATA)>
Copyright © 2002–2016 Apache Software Foundation. All rights reserved.