类 ToolInfo
java.lang.Object
org.apache.velocity.tools.ToolInfo
- 所有已实现的接口:
Serializable
Manages data needed to create instances of a tool. New instances
are returned for every call to create(obj).
- 版本:
- $Id: ToolInfo.java 511959 2007-02-26 19:24:39Z nbubna $
- 作者:
- Nathan Bubna, Henning P. Schmiedehausen
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddProperties(Map<String, Object> parentProps) Adds a map of properties from a parent scope to the properties for this tool.Combine several property mapsprotected voidActually performs configuration of the newly instantiated tool using the combined final set of configuration properties.Returns a new instance of the tool.Get tool class nameprotected MethodTry to find aconfigure()method.Get factory classgetKey()Get tool keyGet tool propertiesgetProps()Get tools property (synchronized version)Get tool classbooleanGet whether this tool has aconfigure()methodbooleanhasPermission(String path) protected voidInvoke a single argument method on a toolbooleanGet whether setters are to be skippedprotected ObjectCreates a new instance for this tool.putProperty(String name, Object value) Puts a new property for this tool.voidrestrictTo(String path) voidSet the tool classvoidsetFactory(Class factory) Set the factory class used to create tool instances.voidSet the tool keyprotected voidsetProperty(Object tool, String name, Object value) Set a property on a tool instancevoidsetSkipSetters(boolean cfgOnly) Set whether or not to skip setters.
-
字段详细资料
-
CONFIGURE_METHOD_NAME
- 另请参阅:
-
-
构造器详细资料
-
ToolInfo
Creates a new instance using the minimum required info necessary for a tool.- 参数:
key- tool keyclazz- tool class
-
ToolInfo
Creates a new instance using the minimum required info necessary for a tool.- 参数:
key- tool keyclazz- tool class
-
-
方法详细资料
-
setKey
Set the tool key- 参数:
key- tool key
-
setClass
Set the tool class- 参数:
clazz- the java.lang.Class of the tool
-
setFactory
Set the factory class used to create tool instances.
The factory is supposed to have one of those three methods:
- createToolClassName()
- newToolClassName()
- getToolClassName()
where ToolClassName is the tool's class name.
If this method takes one
java.util.Mapargument, it will be given the tool's configuration map.- 参数:
factory- factory class
-
restrictTo
- 参数:
path- the full or partial request path restriction of the tool
-
setSkipSetters
public void setSkipSetters(boolean cfgOnly) Set whether or not to skip setters.- 参数:
cfgOnly- flag value
-
addProperties
Adds a map of properties from a parent scope to the properties for this tool. Only new properties will be added; any that are already set for this tool will be ignored.- 参数:
parentProps- parent properties map
-
putProperty
Puts a new property for this tool.- 参数:
name- property namevalue- property value- 返回:
- previous property value
-
getProps
Get tools property (synchronized version)- 返回:
- tools property
-
getKey
Get tool key- 返回:
- tool key
-
getClassname
Get tool class name- 返回:
- tool class name
-
getToolClass
Get tool class- 返回:
- tool class
-
getFactory
Get factory class- 返回:
- factory class or null if not provided
-
getProperties
Get tool properties- 返回:
- tools properties
-
hasConfigure
public boolean hasConfigure()Get whether this tool has aconfigure()method- 返回:
trueif the tool has aconfigure()method,falseotherwise
-
isSkipSetters
public boolean isSkipSetters()Get whether setters are to be skipped- 返回:
- whether to skip setters
-
hasPermission
- 参数:
path- the path of a template requesting this tool- 返回:
trueif the specified request path matches the restrictions of this tool. If there is no request path restriction for this tool, it will always returntrue.
-
create
Returns a new instance of the tool. If the tool has an configure(Map) method, the new instance will be initialized using the given properties combined with whatever "constant" properties have been put into this ToolInfo.- 参数:
dynamicProperties- map of dynamic properties- 返回:
- newly created and configured object
-
configure
Actually performs configuration of the newly instantiated tool using the combined final set of configuration properties. First, if the class lacks theSkipSettersannotation, then any specific setters matching the configuration keys are called, then the general configure(Map) method (if any) is called.- 参数:
tool- newly created tool to be configuredconfiguration- properties
-
getConfigure
Try to find aconfigure()method.- 返回:
configure()method if found,nullotherwise.
-
newInstance
Creates a new instance for this tool.- 返回:
- newly created tool
- 抛出:
IllegalStateException- if creation failed
-
invoke
Invoke a single argument method on a tool- 参数:
method- the method to invoketool- the tool on which to invoke the methodparam- the method argument- 抛出:
IllegalStateException- if invocation failed
-
setProperty
Set a property on a tool instance- 参数:
tool- tool instancename- property namevalue- property value- 抛出:
Exception- if setting the property throwed
-
combine
Combine several property maps- 参数:
maps- maps to combine- 返回:
- combined map
-