Question:

We couldn't figure out why when we added an integer to the parameters like:

data.getParameters().add("ERRORLEVEL",1);

We could retrieve it with:

data.getParameters().getInt("ERRORLEVEL");

But if we added a string and used getString("ERRORLEVEL") it would not work. 
ParameterParser was converting the names to lowercase and stripping spaces
when the object was initialized.  But when a value was added via an add()
method, the name was not converted ( via ParameterParser.convert(String) ). 
But some retrieval methods where converting the name before retrieval.  So in
some cases this was working and others it was not.  I've included a patch
where nothing is converted via the convert() method, but am wondering if there
was a reason this was in here.  We don't have to 'not convert' any thing, but
then we'd have to be consistent when adding to the parameters to convert the
name also and document this side-effect.  Anyway here's the patch which
removes the stripping and lower-casing of the names.  I left the
ParameterParser.convert(String) method alone, but it is no longer used
internally by ParameterParser.

---- BEGIN ---

Index: ParameterParser.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/ParameterParser.java,v
retrieving revision 1.10
diff -u -r1.10 ParameterParser.java
--- ParameterParser.java        2000/04/14 07:20:07     1.10
+++ ParameterParser.java        2000/04/19 15:29:02
@@ -105,7 +105,7 @@
             while(names.hasMoreElements())
             {
                 tmp = (String) names.nextElement();
-                this.put( convert(tmp), (Object) req.getParameterValues(tmp)
);
+                this.put( tmp, (Object) req.getParameterValues(tmp) );
             }
         }
         
@@ -128,7 +128,7 @@
                     tmp2 = JServUtils.URLDecode(st.nextToken());
                     if ( tmp.length() != 0 )
                     {
-                        add (convert(tmp), tmp2);
+                        add (tmp, tmp2);
                     }
                     name = true;
                 }
@@ -187,7 +187,7 @@
     */
     public boolean containsKey( Object key )
     {
-        return super.containsKey(convert((String)key));
+        return super.containsKey((String)key);
     }
     /**
         Return a boolean for the given name. If the name does not 
@@ -196,7 +196,7 @@
     public boolean getBoolean(String name)
     {
         boolean value = false;
-        Object object = this.get(convert(name));
+        Object object = this.get(name);
         if (object != null)
         {
             String tmp = getString(name);
@@ -215,7 +215,7 @@
     public boolean getBoolean(String name, boolean defaultValue)
     {
         boolean value = defaultValue;
-        Object object = this.get(convert(name));
+        Object object = this.get(name);
         if (object != null)
         {
             String tmp = getString(name);
@@ -234,7 +234,7 @@
     public Boolean getBool(String name)
     {
         boolean value = false;
-        Object object = this.get(convert(name));
+        Object object = this.get(name);
         if (object != null)
         {
             String tmp = getString(name);
@@ -253,7 +253,7 @@
     public Boolean getBool(String name, boolean defaultValue)
     {
         boolean value = defaultValue;
-        Object object = this.get(convert(name));
+        Object object = this.get(name);
         if (object != null)
         {
             String tmp = getString(name);
@@ -274,7 +274,7 @@
         double value = 0.0;
         try
         {
-            Object object = this.get(convert(name));
+            Object object = this.get(name);
             if (object != null)
                 value = Double.valueOf(((String[])object)[0]).doubleValue();
         }
@@ -292,7 +292,7 @@
         double value = defaultValue;
         try
         {
-          Object object = this.get(convert(name));
+          Object object = this.get(name);
           if (object != null)
             value = Double.valueOf(((String[])object)[0]).doubleValue();
         }
@@ -310,7 +310,7 @@
         int value = 0;
         try
         {
-            Object object = this.get(convert(name));
+            Object object = this.get(name);
             if (object != null)
                 value = Integer.valueOf(((String[])object)[0]).intValue();
         }
@@ -328,7 +328,7 @@
         int value = defaultValue;
         try
         {
-            Object object = this.get(convert(name));
+            Object object = this.get(name);
             if (object != null)
                 value = Integer.valueOf(((String[])object)[0]).intValue();
         }
@@ -370,7 +370,7 @@
     public Integer[] getIntegers(String name)
     {
         Integer[] value = null;
-        Object object = getStrings(convert(name));
+        Object object = getStrings(name);
         if (object != null)
         {
             String[] temp = (String[])object;
@@ -385,7 +385,7 @@
         long value = 0;
         try
         {
-            Object object = this.get(convert(name));
+            Object object = this.get(name);
             if (object != null)
                 value = Long.valueOf(((String[])object)[0]).longValue();
         }
@@ -403,7 +403,7 @@
         long value = defaultValue;
         try
         {
-            Object object = this.get(convert(name));
+            Object object = this.get(name);
             if (object != null)
                 value = Long.valueOf(((String[])object)[0]).longValue();
         }
@@ -421,7 +421,7 @@
         try
         {
             String value = null;
-            Object object = this.get(convert(name));
+            Object object = this.get(name);
             if (object != null)
                 value = ((String[])object)[0];
             return value;
@@ -450,7 +450,7 @@
     public String[] getStrings(String name)
     {
         String[] value = null;
-        Object object = this.get(convert(name));
+        Object object = this.get(name);
         if (object != null)
             value = ((String[])object);
         return value;

----- END ----

Jeffrey D. Brekke
mailto:[EMAIL PROTECTED]
http://sites.netscape.net/ekkerbj/homepage


____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at 
http://webmail.netscape.com.


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to