Class XMLToolboxManager
- java.lang.Object
-
- org.apache.velocity.tools.view.XMLToolboxManager
-
- All Implemented Interfaces:
ToolboxManager
- Direct Known Subclasses:
ServletToolboxManager
@Deprecated public class XMLToolboxManager extends Object implements ToolboxManager
Deprecated.A ToolboxManager for loading a toolbox from xml.A toolbox manager is responsible for automatically filling the Velocity context with a set of view tools. This class provides the following features:
- configurable through an XML-based configuration file
- assembles a set of view tools (the toolbox) on request
- supports any class with a public constructor without parameters to be used as a view tool
- supports adding primitive data values to the context(String,Number,Boolean)
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>- Version:
- $Id$
- Author:
- Nathan Bubna, Geir Magnusson Jr., Henning P. Schmiedehausen
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.commons.logging.LogLOGDeprecated.
-
Constructor Summary
Constructors Constructor Description XMLToolboxManager()Deprecated.Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddData(ToolInfo info)Deprecated.Adds a data object for the context.voidaddTool(ToolInfo info)Deprecated.Adds a tool to be managedprotected org.apache.commons.digester.RuleSetgetRuleSet()Deprecated.Retrieves the rule set Digester should use to parse and load the toolbox for this manager.MapgetToolbox(Object initData)Deprecated.Retrieves a map of the tools and data being managed.voidload(InputStream input)Deprecated.Reads an XML document from anInputStreamand sets up the toolbox from that.voidload(String path)Deprecated.Reads an XML document from the specified file path and sets up the toolbox from that.protected booleanvalidateToolInfo(ToolInfo info)Deprecated.Checks whether an object described by a ToolInfo passes some basic sanity checks.
-
-
-
Method Detail
-
addTool
public void addTool(ToolInfo info)
Deprecated.Description copied from interface:ToolboxManagerAdds a tool to be managed- Specified by:
addToolin interfaceToolboxManager
-
addData
public void addData(ToolInfo info)
Deprecated.Description copied from interface:ToolboxManagerAdds a data object for the context.- Specified by:
addDatain interfaceToolboxManager- Parameters:
info- An object that implements ToolInfo
-
validateToolInfo
protected boolean validateToolInfo(ToolInfo info)
Deprecated.Checks whether an object described by a ToolInfo passes some basic sanity checks.- Parameters:
info- A ToolInfo object- Returns:
- true if the ToolInfo is valid
-
getToolbox
public Map getToolbox(Object initData)
Deprecated.Description copied from interface:ToolboxManagerRetrieves a map of the tools and data being managed. Tools that have an init(Object) method will be (re)initialized using the specified initData.- Specified by:
getToolboxin interfaceToolboxManager- Parameters:
initData- data used to initialize tools- Returns:
- the created ToolboxContext
-
load
public void load(String path) throws Exception
Deprecated.Reads an XML document from the specified file path and sets up the toolbox from that. If the file does not exist, an
IllegalArgumentExceptionwill be thrown.- Parameters:
path- the path to the file to be read from- Throws:
Exception- Since:
- VelocityTools 1.3
-
load
public void load(InputStream input) throws Exception
Deprecated.Reads an XML document from an
InputStreamand sets up the toolbox from that.- Parameters:
input- the InputStream to read from- Throws:
Exception
-
getRuleSet
protected org.apache.commons.digester.RuleSet getRuleSet()
Deprecated.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)>- Since:
- VelocityTools 1.1
-
-