velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r749733 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ParameterTool.java
Date Tue, 03 Mar 2009 20:24:17 GMT
Author: nbubna
Date: Tue Mar  3 20:24:17 2009
New Revision: 749733

URL: http://svn.apache.org/viewvc?rev=749733&view=rev
Log:
simplify implementation

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

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ParameterTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ParameterTool.java?rev=749733&r1=749732&r2=749733&view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ParameterTool.java (original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ParameterTool.java Tue
Mar  3 20:24:17 2009
@@ -83,7 +83,7 @@
     {
         super.configure(values);
 
-        ServletRequest req = (ServletRequest)values.get(ViewContext.REQUEST);
+        ServletRequest req = (ServletRequest)values.getValue(ViewContext.REQUEST);
         setRequest(req);
     }
 
@@ -124,12 +124,7 @@
     @Override
     public Object getValue(String key)
     {
-        Object value = getRequest().getParameter(key);
-        if(value == null && getAllowSubkeys())
-        {
-            value = getSubkey(key);
-        }
-        return value;
+        return getRequest().getParameter(key);
     }
 
 
@@ -170,12 +165,19 @@
 
     /**
      * Overrides ValueParser.getSource() to return the result
-     * of getRequest().getParameterMap().
+     * of getRequest().getParameterMap() and expand singleton
+     * arrays within it first.
      */
     @Override
     protected Map getSource()
     {
-        return getRequest().getParameterMap();
+        Map source = super.getSource();
+        if (source == null)
+        {
+            source = expandSingletonArrays(getRequest().getParameterMap());
+            super.setSource(source);
+        }
+        return source;
     }
 
     /**
@@ -183,56 +185,7 @@
      */
     public Map getAll()
     {
-        return expandSingletonArrays(getSource());
-    }
-
-    /**
-     * subkey getter that returns a map <subkey#2> -> value
-     * for every "subkey.subkey2" found entry
-     *
-     * @param subkey subkey to search for
-     * @return the map of found values
-     */
-    @Override
-    protected ValueParser getSubkey(String subkey) {
-        ValueParser submap = super.getSubkey(subkey);
-        if (submap != null)
-        {
-            /* expand singleton arrays to reflect request.getParameter behaviour */
-            submap = new ValueParser(expandSingletonArrays(submap));
-        }
-        return submap;
-    }
-
-    /* some methods of java.util.Map need to be subclassed here
-       to expand singleton array values
-     */
-
-    @Override
-    public boolean containsValue(Object value) {
-        return values().contains(value);
-    }
-
-    @Override
-    public Collection values() {
-        Set result = new HashSet();
-        for (Object value : super.values())
-        {
-            if (isSingletonArray(value))
-            {
-                result.add(Array.get(value, 0));
-            }
-            else
-            {
-                result.add(value);
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public Set<Entry<String,Object>> entrySet() {
-        return expandSingletonArrays(getSource()).entrySet();
+        return getSource();
     }
 
     private boolean isSingletonArray(Object value)



Mime
View raw message