org.apache.velocity.tools.view
Class ViewToolInfo

java.lang.Object
  extended by org.apache.velocity.tools.view.ViewToolInfo
All Implemented Interfaces:
ToolInfo
Direct Known Subclasses:
ServletToolInfo

public class ViewToolInfo
extends java.lang.Object
implements ToolInfo

ToolInfo implementation for view tools. New instances are returned for every call to getInstance(obj), and tools that have an init(Object) method are initialized with the given object before being returned. And tools that have a configure(Map) method will be configured before being returned if there are parameters specified for the tool.

Version:
$Id: ViewToolInfo.java 479724 2006-11-27 18:49:37Z nbubna $
Author:
Nathan Bubna, Henning P. Schmiedehausen

Field Summary
private  java.lang.Class clazz
           
private  java.lang.reflect.Method configure
           
private  java.lang.reflect.Method init
           
private  java.lang.String key
           
protected static org.apache.commons.logging.Log LOG
           
private  java.util.Map parameters
           
 
Constructor Summary
ViewToolInfo()
           
 
Method Summary
protected  java.lang.Class getApplicationClass(java.lang.String name)
          Return the Class object for the specified fully qualified class name, from this web application's class loader.
 java.lang.String getClassname()
           
 java.lang.Object getInstance(java.lang.Object initData)
          Returns a new instance of the tool.
 java.lang.String getKey()
          Accessors
 java.util.Map getParameters()
          Get parameters for this tool.
 void setClassname(java.lang.String classname)
          If an instance of the tool cannot be created from the classname passed to this method, it will throw an exception.
 void setKey(java.lang.String key)
          Mutators
 void setParameter(java.lang.String name, java.lang.String value)
          Set/add new parameter for this tool.
 void setParameters(java.util.Map parameters)
          Set parameter map for this tool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG

key

private java.lang.String key

clazz

private java.lang.Class clazz

parameters

private java.util.Map parameters

init

private java.lang.reflect.Method init

configure

private java.lang.reflect.Method configure
Constructor Detail

ViewToolInfo

public ViewToolInfo()
Method Detail

getApplicationClass

protected java.lang.Class getApplicationClass(java.lang.String name)
                                       throws java.lang.ClassNotFoundException
Return the Class object for the specified fully qualified class name, from this web application's class loader. If no class loader is set for the current thread, then the class loader that loaded this class will be used.

Parameters:
name - Fully qualified class name to be loaded
Returns:
Class object
Throws:
java.lang.ClassNotFoundException - if the class cannot be found
Since:
VelocityTools 1.1

setKey

public void setKey(java.lang.String key)
Mutators


setClassname

public void setClassname(java.lang.String classname)
                  throws java.lang.Exception
If an instance of the tool cannot be created from the classname passed to this method, it will throw an exception.

Parameters:
classname - the fully qualified java.lang.Class name of the tool
Throws:
java.lang.Exception

setParameters

public void setParameters(java.util.Map parameters)
Set parameter map for this tool.

Since:
VelocityTools 1.1

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Set/add new parameter for this tool.

Since:
VelocityTools 1.1

getKey

public java.lang.String getKey()
Accessors

Specified by:
getKey in interface ToolInfo
Returns:
the context key for the tool

getClassname

public java.lang.String getClassname()
Specified by:
getClassname in interface ToolInfo
Returns:
the fully qualified classname for the tool

getParameters

public java.util.Map getParameters()
Get parameters for this tool.

Since:
VelocityTools 1.1

getInstance

public java.lang.Object getInstance(java.lang.Object initData)
Returns a new instance of the tool. If the tool has an init(Object) method, the new instance will be initialized using the given data. If parameters have been specified and the tool has a configure(Map) method, the tool will be passed the parameters also.

Specified by:
getInstance in interface ToolInfo
Parameters:
initData - an object that may be used to initialize the instance
Returns:
an instance of the tool


Copyright (c) 2003-2007 Apache Software Foundation