org.apache.velocity.tools
Class ToolInfo

java.lang.Object
  extended by org.apache.velocity.tools.ToolInfo
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
OldToolInfo

public class ToolInfo
extends Object
implements Serializable

Manages data needed to create instances of a tool. New instances are returned for every call to create(obj).

Version:
$Id: ToolInfo.java 511959 2007-02-26 19:24:39Z nbubna $
Author:
Nathan Bubna, Henning P. Schmiedehausen
See Also:
Serialized Form

Field Summary
static String CONFIGURE_METHOD_NAME
           
 
Constructor Summary
ToolInfo(String key, Class clazz)
          Creates a new instance using the minimum required info necessary for a tool.
 
Method Summary
 void addProperties(Map<String,Object> parentProps)
          Adds a map of properties from a parent scope to the properties for this tool.
protected  Map<String,Object> combine(Map<String,Object>... maps)
           
protected  void configure(Object tool, Map<String,Object> configuration)
          Actually performs configuration of the newly instantiated tool using the combined final set of configuration properties.
 Object create(Map<String,Object> dynamicProperties)
          Returns a new instance of the tool.
 String getClassname()
           
protected  Method getConfigure()
           
 String getKey()
          Accessors
 Map<String,Object> getProperties()
           
protected  Map<String,Object> getProps()
           
 Class getToolClass()
           
 boolean hasConfigure()
           
 boolean hasPermission(String path)
           
protected  void invoke(Method method, Object tool, Object param)
           
 boolean isSkipSetters()
           
protected  Object newInstance()
           
 Object putProperty(String name, Object value)
          Puts a new property for this tool.
 void restrictTo(String path)
           
 void setClass(Class clazz)
          Tries to create an instance of the specified Class, then looks for a configure(Map) method.
 void setKey(String key)
          Mutators
protected  void setProperty(Object tool, String name, Object value)
           
 void setSkipSetters(boolean cfgOnly)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURE_METHOD_NAME

public static final String CONFIGURE_METHOD_NAME
See Also:
Constant Field Values
Constructor Detail

ToolInfo

public ToolInfo(String key,
                Class clazz)
Creates a new instance using the minimum required info necessary for a tool.

Method Detail

setKey

public void setKey(String key)
Mutators


setClass

public void setClass(Class clazz)
Tries to create an instance of the specified Class, then looks for a configure(Map) method.

Parameters:
clazz - the java.lang.Class of the tool

restrictTo

public void restrictTo(String path)
Parameters:
path - the full or partial request path restriction of the tool

setSkipSetters

public void setSkipSetters(boolean cfgOnly)

addProperties

public void addProperties(Map<String,Object> parentProps)
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.


putProperty

public Object putProperty(String name,
                          Object value)
Puts a new property for this tool.


getProps

protected Map<String,Object> getProps()

getKey

public String getKey()
Accessors


getClassname

public String getClassname()

getToolClass

public Class getToolClass()

getProperties

public Map<String,Object> getProperties()

hasConfigure

public boolean hasConfigure()

isSkipSetters

public boolean isSkipSetters()

hasPermission

public boolean hasPermission(String path)
Parameters:
path - the path of a template requesting this tool
Returns:
true if the specified request path matches the restrictions of this tool. If there is no request path restriction for this tool, it will always return true.

create

public Object create(Map<String,Object> dynamicProperties)
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.


configure

protected void configure(Object tool,
                         Map<String,Object> configuration)
Actually performs configuration of the newly instantiated tool using the combined final set of configuration properties. First, if the class lacks the SkipSetters annotation, then any specific setters matching the configuration keys are called, then the general configure(Map) method (if any) is called.


getConfigure

protected Method getConfigure()

newInstance

protected Object newInstance()

invoke

protected void invoke(Method method,
                      Object tool,
                      Object param)

setProperty

protected void setProperty(Object tool,
                           String name,
                           Object value)
                    throws Exception
Throws:
Exception

combine

protected Map<String,Object> combine(Map<String,Object>... maps)


Copyright © 2002-2011 The Apache Software Foundation. All Rights Reserved.