Hello all-

My Turbine 2.2 application relied on the fact that ParameterParser.keys() (now .keySet()) would hand back all of the keys in the parameter parser, not just the simple ones added in the BaseValueParser. Now that the parameters field is private in the base class and fileParameters is private in the DefaultParameterParser extension, the child class needs to wrap the keySet(), getObject(), and getObjects() functionality so that calling classes don't need to make the distinction between whether we are retrieving a FileItem or not.

The following patch implements this behavior.


Index: src/java/org/apache/turbine/util/parser/DefaultParameterParser.java
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/util/ parser/DefaultParameterParser.java,v
retrieving revision 1.20.2.1
diff -u -r1.20.2.1 DefaultParameterParser.java
--- src/java/org/apache/turbine/util/parser/DefaultParameterParser.java 27 Feb 2004 10:34:24 -0000 1.20.2.1
+++ src/java/org/apache/turbine/util/parser/DefaultParameterParser.java 1 Apr 2004 07:11:13 -0000
@@ -20,8 +20,10 @@


 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;
@@ -337,5 +339,63 @@
+ name + ") is not an instance of FileItem[]", e);
return null;
}
+ }
+
+ /**
+ * Return the set of keys contained within this parameter parser, both from
+ * the Map of simple parameters and from the Map of FileItems built during
+ * the initial parse of the inbound request.
+ *
+ * @return Set containing all of the keys.
+ */
+ public Set keySet()
+ {
+ Set result = new HashSet(super.keySet());
+ Set fileKeys = fileParameters.keySet();
+ if(result == null)
+ {
+ result = fileKeys;
+ }
+ else if(fileKeys != null)
+ {
+ result.addAll(fileKeys);
+ }
+ return result;
+ }
+
+ /**
+ * Wrapper for the super class getObject() method that will try to obtain
+ * the result from the superclass, and finding none will try to obtain a
+ * parameter value from the parameter map contained in this object.
+ *
+ * @param name The name of the input parameter to retrieve.
+ * @return The Object corresponding to that value, or null if there is none.
+ */
+ public Object getObject(String name)
+ {
+ Object result = super.getObject(name);
+ if(result == null)
+ {
+ result = getFileItem(name);
+ }
+ return result;
+ }
+
+ /**
+ * Wrapper for the super class getObjects() method that will try to obtain
+ * the result from the superclass, and finding none will try to obtain a
+ * parameter value from the parameter map contained in this object.
+ *
+ * @param name The name of the input parameter to retrieve.
+ * @return The Object corresponding to that value, or null if there is none.
+ */
+ public Object[] getObjects(String name)
+ {
+ Object[] result = super.getObjects(name);
+ if(result == null)
+ {
+ result = getFileItems(name);
+ }
+ return result;
}
}



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to