velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r483664 - /velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java
Date Thu, 07 Dec 2006 21:04:01 GMT
Author: nbubna
Date: Thu Dec  7 13:04:00 2006
New Revision: 483664

URL: http://svn.apache.org/viewvc?view=rev&rev=483664
Log:
handle null and empty parameters maps better

Modified:
    velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java

Modified: velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java?view=diff&rev=483664&r1=483663&r2=483664
==============================================================================
--- velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java (original)
+++ velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java Thu Dec
 7 13:04:00 2006
@@ -231,7 +231,7 @@
      * @param queryData the query parameters to add
      * @since VelocityTools 1.3
      */
-    protected LinkTool copyWith(Map queryData)
+    protected LinkTool copyWith(Map newQueryData)
     {
         LinkTool copy = duplicate();
         if (copy.queryData != null)
@@ -244,10 +244,10 @@
         {
             copy.queryData = new ArrayList();
         }
-        for (Iterator i = queryData.keySet().iterator(); i.hasNext(); )
+        for (Iterator i = newQueryData.keySet().iterator(); i.hasNext(); )
         {
             Object key = i.next();
-            Object value = queryData.get(key);
+            Object value = newQueryData.get(key);
             copy.queryData.add(new QueryPair(String.valueOf(key), value));
         }
         return copy;
@@ -582,6 +582,11 @@
      */
     public LinkTool addQueryData(Map parameters)
     {
+        // don't waste time with null/empty data
+        if (parameters == null || parameters.isEmpty())
+        {
+            return this;
+        }
         return copyWith(parameters);
     }
 
@@ -601,7 +606,7 @@
      */
     public LinkTool params(Map parameters)
     {
-        return copyWith(parameters);
+        return addQueryData(parameters);
     }
 
     /**



Mime
View raw message