velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r584488 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java
Date Sun, 14 Oct 2007 06:10:57 GMT
Author: nbubna
Date: Sat Oct 13 23:10:52 2007
New Revision: 584488

URL: http://svn.apache.org/viewvc?rev=584488&view=rev
Log:
avoid NPEs and just return null when there's no source map

Modified:
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java?rev=584488&r1=584487&r2=584488&view=diff
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java
Sat Oct 13 23:10:52 2007
@@ -54,10 +54,6 @@
 
     protected Map getSource()
     {
-        if (source == null)
-        {
-            throw new NullPointerException("You must set a Map source for values to be parsed.");
-        }
         return this.source;
     }
 
@@ -91,8 +87,17 @@
         return getValue(key);
     }
 
+    /**
+     * Returns the value mapped to the specified key
+     * in the {@link Map} returned by {@link #getSource()}. If there is
+     * no source, then this will always return {@code null}.
+     */
     public Object getValue(String key)
     {
+        if (getSource() == null)
+        {
+            return null;
+        }
         return getSource().get(key);
     }
 



Mime
View raw message