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/14 08:10:57 UTC
svn commit: r584488 -
/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java
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);
}