类 ToolInfo

java.lang.Object
org.apache.velocity.tools.ToolInfo
所有已实现的接口:
Serializable

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).
版本:
$Id: ToolInfo.java 511959 2007-02-26 19:24:39Z nbubna $
作者:
Nathan Bubna, Henning P. Schmiedehausen
另请参阅:
  • 字段详细资料

  • 构造器详细资料

    • ToolInfo

      public ToolInfo(String key, Class clazz)
      Creates a new instance using the minimum required info necessary for a tool.
      参数:
      key - tool key
      clazz - tool class
    • ToolInfo

      public ToolInfo(String key, Class clazz, Class factory)
      Creates a new instance using the minimum required info necessary for a tool.
      参数:
      key - tool key
      clazz - tool class
  • 方法详细资料

    • setKey

      public void setKey(String key)
      Set the tool key
      参数:
      key - tool key
    • setClass

      public void setClass(Class clazz)
      Set the tool class
      参数:
      clazz - the java.lang.Class of the tool
    • setFactory

      public void setFactory(Class factory)

      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.Map argument, it will be given the tool's configuration map.

      参数:
      factory - factory class
    • restrictTo

      public void restrictTo(String path)
      参数:
      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

      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.
      参数:
      parentProps - parent properties map
    • putProperty

      public Object putProperty(String name, Object value)
      Puts a new property for this tool.
      参数:
      name - property name
      value - property value
      返回:
      previous property value
    • getProps

      protected Map<String,Object> getProps()
      Get tools property (synchronized version)
      返回:
      tools property
    • getKey

      public String getKey()
      Get tool key
      返回:
      tool key
    • getClassname

      public String getClassname()
      Get tool class name
      返回:
      tool class name
    • getToolClass

      public Class getToolClass()
      Get tool class
      返回:
      tool class
    • getFactory

      public Class getFactory()
      Get factory class
      返回:
      factory class or null if not provided
    • getProperties

      public Map<String,Object> getProperties()
      Get tool properties
      返回:
      tools properties
    • hasConfigure

      public boolean hasConfigure()
      Get whether this tool has a configure() method
      返回:
      true if the tool has a configure() method, false otherwise
    • isSkipSetters

      public boolean isSkipSetters()
      Get whether setters are to be skipped
      返回:
      whether to skip setters
    • hasPermission

      public boolean hasPermission(String path)
      参数:
      path - the path of a template requesting this tool
      返回:
      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.
      参数:
      dynamicProperties - map of dynamic properties
      返回:
      newly created and configured object
    • 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.
      参数:
      tool - newly created tool to be configured
      configuration - properties
    • getConfigure

      protected Method getConfigure()
      Try to find a configure() method.
      返回:
      configure() method if found, nullotherwise.
    • newInstance

      protected Object newInstance()
      Creates a new instance for this tool.
      返回:
      newly created tool
      抛出:
      IllegalStateException - if creation failed
    • invoke

      protected void invoke(Method method, Object tool, Object param)
      Invoke a single argument method on a tool
      参数:
      method - the method to invoke
      tool - the tool on which to invoke the method
      param - the method argument
      抛出:
      IllegalStateException - if invocation failed
    • setProperty

      protected void setProperty(Object tool, String name, Object value) throws Exception
      Set a property on a tool instance
      参数:
      tool - tool instance
      name - property name
      value - property value
      抛出:
      Exception - if setting the property throwed
    • combine

      protected Map<String,Object> combine(Map<String,Object>... maps)
      Combine several property maps
      参数:
      maps - maps to combine
      返回:
      combined map