incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r832083 - in /sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters: ParameterMap.java ParameterSupport.java
Date Mon, 02 Nov 2009 20:01:12 GMT
Author: fmeschbe
Date: Mon Nov  2 20:01:12 2009
New Revision: 832083

URL: http://svn.apache.org/viewvc?rev=832083&view=rev
Log:
SLING-1167 move all string related parameter access to the ParameterMap class
and convert the exact parameter request to a String or String[] on demand

Modified:
    sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterMap.java
    sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterSupport.java

Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterMap.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterMap.java?rev=832083&r1=832082&r2=832083&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterMap.java
(original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterMap.java
Mon Nov  2 20:01:12 2009
@@ -68,16 +68,22 @@
         super.put(name, parameters);
     }
 
+    //---------- String parameter support
+
+    String getStringValue(final String name) {
+        final RequestParameter param = getValue(name);
+        return (param != null) ? param.getString() : null;
+    }
+
+    String[] getStringValues(final String name) {
+        return toStringArray(getValues(name));
+    }
+
     Map<String, String[]> getStringParameterMap() {
         if (this.stringParameterMap == null) {
             Map<String, String[]> pm = new HashMap<String, String[]>();
             for (Map.Entry<String, RequestParameter[]> ppmEntry : entrySet()) {
-                RequestParameter[] pps = ppmEntry.getValue();
-                String[] ps = new String[pps.length];
-                for (int i = 0; i < pps.length; i++) {
-                    ps[i] = pps[i].getString();
-                }
-                pm.put(ppmEntry.getKey(), ps);
+                pm.put(ppmEntry.getKey(), toStringArray(ppmEntry.getValue()));
             }
             this.stringParameterMap = Collections.unmodifiableMap(pm);
         }
@@ -125,4 +131,18 @@
     public RequestParameter[] remove(Object key) {
         throw new UnsupportedOperationException("remove");
     }
+
+    //---------- internal
+
+    private static String[] toStringArray(final RequestParameter[] params) {
+        if (params == null) {
+            return null;
+        }
+
+        final String[] ps = new String[params.length];
+        for (int i = 0; i < params.length; i++) {
+            ps[i] = params[i].getString();
+        }
+        return ps;
+    }
 }

Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterSupport.java?rev=832083&r1=832082&r2=832083&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterSupport.java
(original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/ParameterSupport.java
Mon Nov  2 20:01:12 2009
@@ -82,12 +82,11 @@
     }
 
     public String getParameter(String name) {
-        RequestParameter param = this.getRequestParameter(name);
-        return (param != null) ? param.getString() : null;
+        return getRequestParameterMapInternal().getStringValue(name);
     }
 
     public String[] getParameterValues(String name) {
-        return this.getParameterMap().get(name);
+        return getRequestParameterMapInternal().getStringValues(name);
     }
 
     public Map<String, String[]> getParameterMap() {



Mime
View raw message