velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r564045 - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools: generic/MathTool.java generic/RenderTool.java generic/SortTool.java view/ViewToolInfo.java view/jsp/VelocityViewTag.java
Date Wed, 08 Aug 2007 23:25:21 GMT
Author: nbubna
Date: Wed Aug  8 16:25:20 2007
New Revision: 564045

URL: http://svn.apache.org/viewvc?view=rev&rev=564045
Log:
fix misc findbugs complaints

Modified:
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/MathTool.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/SortTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolInfo.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/MathTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/MathTool.java?view=diff&rev=564045&r1=564044&r2=564045
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/MathTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/MathTool.java
Wed Aug  8 16:25:20 2007
@@ -563,26 +563,29 @@
         {
             return null;
         }
+        double result = 0;
+        // hold the first number and use it to match return type
+        Number first = null;
         try
         {
-            double result = 0;
-            // hold the first number and use it to match return type
-            Number first = null;
             for (Iterator i = collection.iterator(); i.hasNext();)
             {
                 Object property = PropertyUtils.getProperty(i.next(), field);
                 Number value = toNumber(property);
-                if (first == null)
+                // skip over nulls (i.e. treat them as 0)
+                if (value != null)
                 {
-                    first = value;
+                    if (first == null)
+                    {
+                        first = value;
+                    }
+                    result += value.doubleValue();
                 }
-                result += value.doubleValue();
             }
             return matchType(first, result);
         }
         catch (Exception e)
         {
-            //FIXME? Log this?
             return null;
         }
     }

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=564045&r1=564044&r2=564045
==============================================================================
--- 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
Wed Aug  8 16:25:20 2007
@@ -269,7 +269,7 @@
             if (count < parseDepth)
             {
                 // continue recursing
-                return internalRecurse(ctx, result, count++);
+                return internalRecurse(ctx, result, count + 1);
             }
             else
             {

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/SortTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/SortTool.java?view=diff&rev=564045&r1=564044&r2=564045
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/SortTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/SortTool.java
Wed Aug  8 16:25:20 2007
@@ -270,7 +270,7 @@
                 if (left == null && right != null)
                 {
                     // find out how right feels about left being null
-                    comparison = right.compareTo(left);
+                    comparison = right.compareTo(null);
                     // and reverse that (if it works)
                     comparison *= -1;
                 }

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolInfo.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolInfo.java?view=diff&rev=564045&r1=564044&r2=564045
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolInfo.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolInfo.java
Wed Aug  8 16:25:20 2007
@@ -95,7 +95,7 @@
         {
             this.clazz = getApplicationClass(classname);
             // create an instance to make sure we can
-            Object instance = clazz.newInstance();
+            clazz.newInstance();
             try
             {
                 // try to get an init(Object) method

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java?view=diff&rev=564045&r1=564044&r2=564045
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
Wed Aug  8 16:25:20 2007
@@ -200,11 +200,9 @@
 
     protected void renderContent(Writer out) throws Exception
     {
-        VelocityView view = getVelocityView();
-        VelocityEngine engine = view.getVelocityEngine();
-
         if (getTemplate() != null)
         {
+            VelocityView view = getVelocityView();
             ViewToolContext context = getViewToolContext();
 
             // get the actual Template



Mime
View raw message