velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r599282 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java
Date Thu, 29 Nov 2007 05:48:04 GMT
Author: nbubna
Date: Wed Nov 28 21:47:58 2007
New Revision: 599282

URL: http://svn.apache.org/viewvc?rev=599282&view=rev
Log:
add getValue(key,alternate)

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=599282&r1=599281&r2=599282&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
Wed Nov 28 21:47:58 2007
@@ -170,6 +170,23 @@
         return value;
     }
 
+    /**
+     * @param key the desired parameter's key
+     * @param alternate The alternate value
+     * @return parameter matching the specified key or the
+     *         specified alternate Object if there is no matching
+     *         parameter
+     */
+    public Object getValue(String key, Object alternate)
+    {
+        Object value = getValue(key);
+        if (value == null)
+        {
+            return alternate;
+        }
+        return value;
+    }
+
     public Object[] getValues(String key)
     {
         Object value = getValue(key);



Mime
View raw message