Author: nbubna
Date: Fri Apr 27 20:42:25 2007
New Revision: 533288

URL: http://svn.apache.org/viewvc?view=rev&rev=533288
Log:
update tools to work with new tool property/initialization in 2.x

Modified:
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ImportSupport.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java
    
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
 Fri Apr 27 20:42:25 2007
@@ -70,7 +70,7 @@
      * if not, set the default to true.
      * @since VelocityTools 1.3
      */
-    public void configure(Map params)
+    public void setup(Map params)
     {
         ValueParser parser = new ValueParser(params);
         // it's true by default in Alternator

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
 Fri Apr 27 20:42:25 2007
@@ -103,7 +103,7 @@
      * Looks for configuration values in the given params.
      * @since VelocityTools 1.3
      */
-    public void configure(Map params)
+    public void setup(Map params)
     {
         if (!configLocked)
         {

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
 Fri Apr 27 20:42:25 2007
@@ -100,7 +100,7 @@
      * Looks for configuration values in the given params.
      * @since VelocityTools 1.4
      */
-    public void configure(Map params)
+    public void setup(Map params)
     {
         if (!configLocked)
         {

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
 Fri Apr 27 20:42:25 2007
@@ -101,7 +101,7 @@
      * Looks for parse depth and catch.exceptions parameters.
      * @since VelocityTools 1.3
      */
-    public void configure(Map params)
+    public void setup(Map params)
     {
         ValueParser parser = new ValueParser(params);
         int depth = parser.getInt(KEY_PARSE_DEPTH, DEFAULT_PARSE_DEPTH);

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
 Fri Apr 27 20:42:25 2007
@@ -101,7 +101,7 @@
     }
 
 
-    public void configure(Map params)
+    public void setup(Map params)
     {
         ValueParser parser = new ValueParser(params);
         String[] bundles = parser.getStrings(BUNDLES_KEY);

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ImportSupport.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ImportSupport.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ImportSupport.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ImportSupport.java
 Fri Apr 27 20:42:25 2007
@@ -56,15 +56,60 @@
 
     protected static final Log LOG = LogFactory.getLog(ImportSupport.class);
 
-    protected ServletContext application;
-    protected HttpServletRequest request;
-    protected HttpServletResponse response;
-
     protected static final String VALID_SCHEME_CHARS =
         "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-";
 
     /** Default character encoding for response. */
     protected static final String DEFAULT_ENCODING = "ISO-8859-1";
+
+    protected ServletContext application;
+    protected HttpServletRequest request;
+    protected HttpServletResponse response;
+
+
+    // --------------------------------------- Setup Methods -------------
+
+    /**
+     * Sets the current [EMAIL PROTECTED] HttpServletRequest}. This is required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
+     */
+    public void setRequest(HttpServletRequest request)
+    {
+        if (request == null)
+        {
+            throw new NullPointerException("request should not be null");
+        }
+        this.request = request;
+    }
+
+    /**
+     * Sets the current [EMAIL PROTECTED] HttpServletResponse}. This is 
required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
+     */
+    public void setResponse(HttpServletResponse response)
+    {
+        if (response == null)
+        {
+            throw new NullPointerException("response should not be null");
+        }
+        this.response = response;
+    }
+
+    /**
+     * Sets the [EMAIL PROTECTED] ServletContext}. This is required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
+     */
+    public void setServletContext(ServletContext application)
+    {
+        if (application == null)
+        {
+            throw new NullPointerException("servlet context should not be 
null");
+        }
+        this.application = application;
+    }
 
     //*********************************************************************
     // URL importation logic

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
 Fri Apr 27 20:42:25 2007
@@ -20,12 +20,13 @@
  */
 
 import java.util.Locale;
+import java.util.Map;
 import javax.servlet.ServletContext;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.context.Context;
 import org.apache.velocity.tools.config.DefaultKey;
 import org.apache.velocity.tools.config.InvalidScope;
-import org.apache.velocity.tools.view.ViewContext;
+import org.apache.velocity.tools.view.ViewToolContext;
 
 /**
  * Allows for transparent content negotiation in a manner mimicking
@@ -78,21 +79,15 @@
      * @param obj the current ViewContext
      * @throws IllegalArgumentException if the param is not a ViewContext
      */
-    public void init(Object obj)
+    public void setup(Map params)
     {
-        if (!(obj instanceof ViewContext))
-        {
-            throw new IllegalArgumentException("Tool can only be initialized 
with a ViewContext");
-        }
-
-        ViewContext context = (ViewContext)obj;
-        Context vc = context.getVelocityContext();
-        this.engine = context.getVelocityEngine();
+        Context vc = (Context)params.get(ViewToolContext.CONTEXT_KEY);
+        this.engine = (VelocityEngine)params.get(ViewToolContext.ENGINE_KEY);
 
         defaultLanguage = (String) vc.get(DEFAULT_LANGUAGE_KEY);
         if (defaultLanguage == null || defaultLanguage.trim().equals(""))
         {
-            ServletContext sc = context.getServletContext();
+            ServletContext sc = 
(ServletContext)params.get(ViewToolContext.SERVLET_CONTEXT_KEY);
             defaultLanguage = (String) sc.getAttribute(DEFAULT_LANGUAGE_KEY);
             if (defaultLanguage == null || defaultLanguage.trim().equals(""))
             {

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
 Fri Apr 27 20:42:25 2007
@@ -131,17 +131,17 @@
     protected HttpSession session;
 
     /**
-     * Initializes this instance by grabbing the request
-     * and session objects from the current ViewContext.
-     *
-     * @param obj the current ViewContext
-     * @throws ClassCastException if the param is not a ViewContext
+     * Initializes this tool with the specified [EMAIL PROTECTED] 
HttpServletRequest}.
+     * This is required for this tool to operate and will throw a
+     * NullPointerException if this is not set or is set to [EMAIL PROTECTED] 
null}.
      */
-    public void init(Object obj)
+    public void setRequest(HttpServletRequest request)
     {
-        ViewContext context = (ViewContext)obj;
-        HttpServletRequest request = context.getRequest();
-        session = request.getSession(false);
+        if (request == null)
+        {
+            throw new NullPointerException("request should not be null");
+        }
+        this.session = request.getSession(false);
         setup(request);
     }
 

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java
 Fri Apr 27 20:42:25 2007
@@ -71,27 +71,18 @@
     private int geckoMajorVersion = -1;
     private int geckoMinorVersion = -1;
 
-    public BrowserSnifferTool()
+    /**
+     * Initializes this tool by setting the current [EMAIL PROTECTED] 
HttpServletRequest}.
+     * This is required for this tool to operate and will throw a
+     * NullPointerException if this is not set or is set to [EMAIL PROTECTED] 
null}.
+     */
+    public void setRequest(HttpServletRequest request)
     {
-    }
-
-    public void init(Object initData)
-    {
-        HttpServletRequest req;
-        if(initData instanceof ViewContext)
-        {
-            req = ((ViewContext)initData).getRequest();
-        }
-        else if(initData instanceof HttpServletRequest)
-        {
-            req = (HttpServletRequest)initData;
-        }
-        else
+        if (request == null)
         {
-            throw new IllegalArgumentException("Was expecting " + 
ViewContext.class +
-                                               " or " + 
HttpServletRequest.class);
+            throw new NullPointerException("request should not be null");
         }
-        userAgent = req.getHeader("User-Agent").toLowerCase();
+        userAgent = request.getHeader("User-Agent").toLowerCase();
     }
 
     /* Generic getter for unknown tests

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
 Fri Apr 27 20:42:25 2007
@@ -33,8 +33,8 @@
 import org.apache.velocity.tools.config.DefaultKey;
 import org.apache.velocity.tools.config.InvalidScope;
 import org.apache.velocity.tools.generic.ValueParser;
-import org.apache.velocity.tools.view.context.ChainedContext;
 import org.apache.velocity.tools.view.ViewContext;
+import org.apache.velocity.tools.view.ViewToolContext;
 
 /**
  * <p>View tool for convenient access to [EMAIL PROTECTED] ViewContext} data 
and
@@ -78,29 +78,22 @@
 
 
     /**
-     * Looks for a safe-mode configuration setting. By default,
+     * Initializes this instance for the current request.
+     * Also looks for a safe-mode configuration setting. By default,
      * safe-mode is true and thus keys with '.' in them are hidden.
      */
-    public void configure(Map params)
+    public void setup(Map params)
     {
         if (params != null)
         {
             ValueParser parser = new ValueParser(params);
             safeMode = parser.getBoolean(SAFE_MODE_KEY, true);
         }
-    }
 
-    /**
-     * Initializes this instance for the current request.
-     *
-     * @param obj the ViewContext of the current request
-     */
-    public void init(Object obj)
-    {
-        this.context = (ViewContext)obj;
-        this.request = context.getRequest();
+        this.context = (ViewContext)params.get(ViewToolContext.CONTEXT_KEY);
+        this.request = (HttpServletRequest)params.get(ViewContext.REQUEST);
         this.session = request.getSession(false);
-        this.application = context.getServletContext();
+        this.application = 
(ServletContext)params.get(ViewContext.SERVLET_CONTEXT_KEY);
     }
 
 
@@ -115,14 +108,14 @@
     /**
      * <p>Returns a read-only view of the toolbox [EMAIL PROTECTED] Map}
      * for this context.</p>
-     * @return an unmodifiable version of the toolbox for this request
-     *         or [EMAIL PROTECTED] null} if there is none
+     * @return a map of all available tools for this request
+     *         or [EMAIL PROTECTED] null} if such a map is not available
      */
     public Map getToolbox()
     {
-        if (this.toolbox == null && this.context instanceof ChainedContext)
+        if (this.toolbox == null && this.context instanceof ViewToolContext)
         {
-            this.toolbox = ((ChainedContext)context).getToolbox();
+            this.toolbox = ((ViewToolContext)context).getToolbox();
         }
         return this.toolbox;
     }

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java
 Fri Apr 27 20:42:25 2007
@@ -48,7 +48,7 @@
  * @since VelocityTools 1.1
  * @version $Id$
  */
[EMAIL PROTECTED]("cookie")
[EMAIL PROTECTED]("cookies")
 @ValidScope("request")
 public class CookieTool
 {
@@ -56,17 +56,34 @@
     protected HttpServletRequest request;
     protected HttpServletResponse response;
 
+    // --------------------------------------- Setup Methods -------------
 
     /**
-     * Initializes this instance for the current request.
-     *
-     * @param obj the ViewContext of the current request
+     * Sets the current [EMAIL PROTECTED] HttpServletRequest}. This is required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
      */
-    public void init(Object obj)
+    public void setRequest(HttpServletRequest request)
     {
-        ViewContext context = (ViewContext)obj;
-        this.request = context.getRequest();
-        this.response = context.getResponse();
+        if (request == null)
+        {
+            throw new NullPointerException("request should not be null");
+        }
+        this.request = request;
+    }
+
+    /**
+     * Sets the current [EMAIL PROTECTED] HttpServletResponse}. This is 
required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
+     */
+    public void setResponse(HttpServletResponse response)
+    {
+        if (response == null)
+        {
+            throw new NullPointerException("response should not be null");
+        }
+        this.response = response;
     }
 
 

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java
 Fri Apr 27 20:42:25 2007
@@ -58,23 +58,6 @@
     public ImportTool() {}
 
     /**
-     * Initializes this tool.
-     *
-     * @param obj the current ViewContext
-     * @throws IllegalArgumentException if the param is not a ViewContext
-     */
-    public void init(Object obj) {
-        if (! (obj instanceof ViewContext)) {
-            throw new IllegalArgumentException("Tool can only be initialized 
with a ViewContext");
-        }
-
-        ViewContext context = (ViewContext) obj;
-        this.request = context.getRequest();
-        this.response = context.getResponse();
-        this.application = context.getServletContext();
-    }
-
-    /**
      * Returns the supplied URL rendered as a String.
      *
      * @param url the URL to import

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
 Fri Apr 27 20:42:25 2007
@@ -148,7 +148,44 @@
     }
 
 
-    // --------------------------------------- Protected Methods -------------
+    // --------------------------------------- Setup Methods -------------
+
+    /**
+     * Sets the current [EMAIL PROTECTED] HttpServletRequest}. This is required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
+     */
+    public void setServletRequest(HttpServletRequest request)
+    {
+        if (request == null)
+        {
+            throw new NullPointerException("request should not be null");
+        }
+        this.request = request;
+    }
+
+    /**
+     * Sets the current [EMAIL PROTECTED] HttpServletResponse}. This is 
required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
+     */
+    public void setServletResponse(HttpServletResponse response)
+    {
+        if (response == null)
+        {
+            throw new NullPointerException("response should not be null");
+        }
+        this.response = response;
+    }
+
+    public void setServletContext(ServletContext application)
+    {
+        if (application == null)
+        {
+            throw new NullPointerException("servletContext should not be 
null");
+        }
+        this.application = application;
+    }
 
     /**
      * <p>Controls the delimiter used for separating query data pairs.
@@ -162,12 +199,19 @@
      *        will be used.  if false, then '&' will be used.
      * @see <a href="http://www.w3.org/TR/xhtml1/#C_12";>Using Ampersands in 
Attribute Values (and Elsewhere)</a>
      */
-    protected void setXhtml(boolean useXhtml)
+    public void setXhtml(boolean useXhtml)
     {
+System.out.println("fired setXhtml: "+useXhtml);
         queryDataDelim =
             (useXhtml) ? XHTML_QUERY_DELIMITER : HTML_QUERY_DELIMITER;
     }
 
+    public void setXHTML(boolean useXhtml)
+    {
+System.out.println("fired primitive setXHTML");
+        setXhtml(useXhtml);
+    }
+    
     /**
      * <p>Controls whether or not the [EMAIL PROTECTED] #getSelf()} method 
will return
      *    a duplicate with a URI in absolute or relative form.</p>
@@ -179,8 +223,9 @@
      * @see #getSelf()
      * @since VelocityTools 1.3
      */
-    protected void setSelfAbsolute(boolean selfAbsolute)
+    public void setSelfAbsolute(boolean selfAbsolute)
     {
+System.out.println("fired setSelfAbsolute: "+selfAbsolute);
         this.selfAbsolute = selfAbsolute;
     }
 
@@ -193,7 +238,7 @@
      * @see #getSelf()
      * @since VelocityTools 1.3
      */
-    protected void setSelfIncludeParameters(boolean selfParams)
+    public void setSelfIncludeParameters(boolean selfParams)
     {
         this.selfParams = selfParams;
     }
@@ -324,56 +369,6 @@
             return copy;
         }
     }
-
-
-    // --------------------------------------- Toolbox Methods -------------
-
-    /**
-     * Configures this tool
-     *
-     * @param params Map of configuration parameters
-     * @since VelocityTools 1.3
-     */
-    public void configure(Map params)
-    {
-        ValueParser parser = new ValueParser(params);
-        Boolean selfAbsolute = parser.getBoolean(SELF_ABSOLUTE_KEY);
-        if (selfAbsolute != null)
-        {
-            setSelfAbsolute(selfAbsolute.booleanValue());
-        }
-        Boolean selfParams = parser.getBoolean(SELF_INCLUDE_PARAMETERS_KEY);
-        if (selfParams != null)
-        {
-            setSelfIncludeParameters(selfParams.booleanValue());
-        }
-    }
-
-    /**
-     * Initializes this tool.
-     *
-     * @param obj the current ViewContext
-     * @throws IllegalArgumentException if the param is not a ViewContext
-     */
-    public void init(Object obj)
-    {
-        if (!(obj instanceof ViewContext))
-        {
-            throw new IllegalArgumentException("Tool can only be initialized 
with a ViewContext");
-        }
-
-        ViewContext context = (ViewContext)obj;
-        this.request = context.getRequest();
-        this.response = context.getResponse();
-        this.application = context.getServletContext();
-        // for backwards compatibility, honor the old key...
-        Boolean b = (Boolean)context.getAttribute("XHTML");
-        if (b != null)
-        {
-            setXhtml(b.booleanValue());
-        }
-    }
-
 
     // --------------------------------------------- Template Methods 
-----------
 

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java
 Fri Apr 27 20:42:25 2007
@@ -73,35 +73,11 @@
     }
 
     /**
-     * Initializes this instance.
-     *
-     * @param obj the current ViewContext or ServletRequest
-     * @throws IllegalArgumentException if the param is not a
-     *         ViewContext or ServletRequest
-     */
-    public void init(Object obj)
-    {
-        if (obj instanceof ViewContext)
-        {
-            setRequest(((ViewContext)obj).getRequest());
-        }
-        else if (obj instanceof ServletRequest)
-        {
-            setRequest((ServletRequest)obj);
-        }
-        else
-        {
-            throw new IllegalArgumentException("Was expecting " + 
ViewContext.class +
-                                               " or " + ServletRequest.class);
-        }
-    }
-
-    /**
      * Sets the current [EMAIL PROTECTED] ServletRequest}
      *
      * @param request the [EMAIL PROTECTED] ServletRequest} to be parsed
      */
-    protected void setRequest(ServletRequest request)
+    public void setRequest(ServletRequest request)
     {
         this.request = request;
     }

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java
 Fri Apr 27 20:42:25 2007
@@ -86,21 +86,18 @@
     public ViewRenderTool()
     {}
 
-
     /**
-     * Initializes this instance.
-     *
-     * @param obj the current Context
+     * Sets the current [EMAIL PROTECTED] Context}. This is required
+     * for this tool to operate and will throw a NullPointerException
+     * if this is not set or is set to [EMAIL PROTECTED] null}.
      */
-    public void init(Object obj)
+    public void setVelocityContext(Context context)
     {
-        context = (Context)obj;
-
-        // if ViewContext, try to retrieve a VelocityEngine for use
-        if (obj instanceof ViewContext)
+        if (context == null)
         {
-            setVelocityEngine(((ViewContext)obj).getVelocityEngine());
+            throw new NullPointerException("context must not be null");
         }
+        this.context = context;
     }
 
     /**

Modified: 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java?view=diff&rev=533288&r1=533287&r2=533288
==============================================================================
--- 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java
 (original)
+++ 
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java
 Fri Apr 27 20:42:25 2007
@@ -67,14 +67,16 @@
 {
 
     /**
-     * Initializes this instance.
+     * Sets the current [EMAIL PROTECTED] ServletRequest}
      *
-     * @param obj the current ViewContext
+     * @param request the [EMAIL PROTECTED] ServletRequest} to retrieve the 
default Locale from
      */
-    public void init(Object obj)
+    public void setRequest(HttpServletRequest request)
     {
-        HttpServletRequest request = ((ViewContext)obj).getRequest();
-        setDefaultLocale(request.getLocale());
+        if (request != null)
+        {
+            setDefaultLocale(request.getLocale());
+        }
     }
 
 }


Reply via email to