You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2007/10/30 20:54:26 UTC

svn commit: r590341 - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view: LinkTool.java tools/LinkTool.java

Author: nbubna
Date: Tue Oct 30 12:54:25 2007
New Revision: 590341

URL: http://svn.apache.org/viewvc?rev=590341&view=rev
Log:
beware of null LOG and support deprecated configure() constants in old LinkTool

Modified:
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java?rev=590341&r1=590340&r2=590341&view=diff
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java Tue Oct 30 12:54:25 2007
@@ -61,18 +61,6 @@
 @ValidScope(Scope.REQUEST)
 public class LinkTool implements Cloneable
 {
-    /**
-     * Parameter key for configuring {@link #setSelfAbsolute} state
-     * @since VelocityTools 1.3
-     */
-    public static final String SELF_ABSOLUTE_KEY = "self-absolute";
-
-    /**
-     * Parameter key for configuring {@link #setSelfIncludeParameters} state
-     * @since VelocityTools 1.3
-     */
-    public static final String SELF_INCLUDE_PARAMETERS_KEY = "self-include-parameters";
-
     /** Standard HTML delimiter for query data ('&') */
     public static final String HTML_QUERY_DELIMITER = "&";
 
@@ -322,7 +310,10 @@
         }
         catch (CloneNotSupportedException e)
         {
-            LOG.warn("LinkTool : Could not properly clone " + getClass(), e);
+            if (LOG != null)
+            {
+                LOG.warn("LinkTool : Could not properly clone " + getClass(), e);
+            }
 
             // "clone" manually
             LinkTool copy;
@@ -797,8 +788,11 @@
         }
         catch(UnsupportedEncodingException uee)
         {
-            LOG.error("LinkTool : Response character encoding '" + 
-                      response.getCharacterEncoding() + "' is unsupported", uee);
+            if (LOG != null)
+            {
+                LOG.error("LinkTool : Response character encoding '" + 
+                          response.getCharacterEncoding() + "' is unsupported", uee);
+            }
             return null;
         }
     }

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?rev=590341&r1=590340&r2=590341&view=diff
==============================================================================
--- 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 Tue Oct 30 12:54:25 2007
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.util.Map;
+import org.apache.velocity.tools.generic.ValueParser;
 import org.apache.velocity.tools.view.ViewContext;
 
 /**
@@ -27,6 +29,28 @@
 @Deprecated
 public class LinkTool extends org.apache.velocity.tools.view.LinkTool
 {
+    @Deprecated
+    public static final String SELF_ABSOLUTE_KEY = "self-absolute";
+
+    @Deprecated
+    public static final String SELF_INCLUDE_PARAMETERS_KEY = "self-include-parameters";
+
+    @Deprecated
+    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());
+        }
+    }
+
     @Deprecated
     public void init(Object obj)
     {