You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2002/07/11 20:21:03 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/util ParameterParser.java

mpoeschl    2002/07/11 11:21:03

  Modified:    src/java/org/apache/turbine/util/parser
                        DefaultParameterParser.java
               src/java/org/apache/turbine/util ParameterParser.java
  Log:
  patch by Agy Mooy <am...@home.nl>
  I found the following two methods in the org.apache.turbine.util.ParameterParser interface
  - public void setUploadData ( byte[] uploadData );
  - public byte[] setUploadData ();
  Either the second method has a very non-standard name for a getter or someone made a typo. I found the same
  setUploadData() method in org.apache.turbine.util.parser.DefaultParameterParser.
  I couldn't find any references to these methods in the rest of the turbine-2 src so that might be why this was
  never noticed.
  + some code cleanup
  
  Revision  Changes    Path
  1.4       +24 -24    jakarta-turbine-2/src/java/org/apache/turbine/util/parser/DefaultParameterParser.java
  
  Index: DefaultParameterParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/parser/DefaultParameterParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultParameterParser.java	15 Mar 2002 12:50:17 -0000	1.3
  +++ DefaultParameterParser.java	11 Jul 2002 18:21:03 -0000	1.4
  @@ -131,7 +131,7 @@
        */
       public DefaultParameterParser(String characterEncoding)
       {
  -        super (characterEncoding);
  +        super(characterEncoding);
       }
   
       /**
  @@ -187,20 +187,20 @@
               {
                   TurbineUpload.parseRequest(req, this);
               }
  -            catch(TurbineException e)
  +            catch (TurbineException e)
               {
                   Log.error(new TurbineException("File upload failed", e));
               }
           }
   
           Enumeration names = req.getParameterNames();
  -        if ( names != null )
  +        if (names != null)
           {
               while(names.hasMoreElements())
               {
                   tmp = (String) names.nextElement();
  -                parameters.put( convert(tmp),
  -                                (Object) req.getParameterValues(tmp) );
  +                parameters.put(convert(tmp),
  +                        (Object) req.getParameterValues(tmp));
               }
           }
   
  @@ -211,9 +211,9 @@
               StringTokenizer st = new StringTokenizer(req.getPathInfo(), "/");
               boolean name = true;
               String pathPart = null;
  -            while(st.hasMoreTokens())
  +            while (st.hasMoreTokens())
               {
  -                if ( name == true )
  +                if (name == true)
                   {
                       tmp = URLDecoder.decode(st.nextToken());
                       name = false;
  @@ -221,15 +221,15 @@
                   else
                   {
                       pathPart = URLDecoder.decode(st.nextToken());
  -                    if ( tmp.length() != 0 )
  +                    if (tmp.length() != 0)
                       {
  -                        add (convert(tmp), pathPart);
  +                        add(convert(tmp), pathPart);
                       }
                       name = true;
                   }
               }
           }
  -        catch ( Exception e )
  +        catch (Exception e)
           {
               // If anything goes wrong above, don't worry about it.
               // Chances are that the path info was wrong anyways and
  @@ -245,7 +245,7 @@
        *
        * @param uploadData A byte[] with data.
        */
  -    public void setUploadData ( byte[] uploadData )
  +    public void setUploadData(byte[] uploadData)
       {
           this.uploadData = uploadData;
       }
  @@ -255,7 +255,7 @@
        *
        * @return uploadData A byte[] with data.
        */
  -    public byte[] setUploadData ()
  +    public byte[] getUploadData()
       {
           return this.uploadData;
       }
  @@ -270,26 +270,24 @@
        * @param name A String with the name.
        * @param value A FileItem with the value.
        */
  -    public void append( String name,
  -                        FileItem value )
  +    public void append(String name, FileItem value)
       {
           FileItem[] items = this.getFileItems(name);
  -        if(items == null)
  +        if (items == null)
           {
               items = new FileItem[1];
               items[0] = value;
  -            parameters.put( convert(name), items );
  +            parameters.put(convert(name), items);
           }
           else
           {
  -            FileItem[] newItems = new FileItem[items.length+1];
  +            FileItem[] newItems = new FileItem[items.length + 1];
               System.arraycopy(items, 0, newItems, 0, items.length);
               newItems[items.length] = value;
  -            parameters.put( convert(name), newItems );
  +            parameters.put(convert(name), newItems);
           }
       }
   
  -
       /**
        * Return a FileItem object for the given name.  If the name does
        * not exist or the object stored is not a FileItem, return null.
  @@ -304,10 +302,12 @@
               FileItem value = null;
               Object object = parameters.get(convert(name));
               if (object != null)
  -                value = ((FileItem[])object)[0];
  +            {
  +                value = ((FileItem[]) object)[0];
  +            }
               return value;
           }
  -        catch ( ClassCastException e )
  +        catch (ClassCastException e)
           {
               return null;
           }
  @@ -325,9 +325,9 @@
       {
           try
           {
  -            return (FileItem[])parameters.get(convert(name));
  +            return (FileItem[]) parameters.get(convert(name));
           }
  -        catch ( ClassCastException e )
  +        catch (ClassCastException e)
           {
               return null;
           }
  
  
  
  1.3       +9 -10     jakarta-turbine-2/src/java/org/apache/turbine/util/ParameterParser.java
  
  Index: ParameterParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/ParameterParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParameterParser.java	9 Sep 2001 01:31:29 -0000	1.2
  +++ ParameterParser.java	11 Jul 2002 18:21:03 -0000	1.3
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -55,8 +55,8 @@
    */
   
   import javax.servlet.http.HttpServletRequest;
  -
   import org.apache.turbine.util.upload.FileItem;
  +
   /**
    * ParameterParser is an interface to a utility to handle parsing and
    * retrieving the data passed via the GET/POST/PATH_INFO arguments.
  @@ -111,14 +111,14 @@
        *
        * @param uploadData A byte[] with data.
        */
  -    public void setUploadData ( byte[] uploadData );
  +    public void setUploadData(byte[] uploadData);
   
       /**
        * Gets the uploadData byte[]
        *
        * @return uploadData A byte[] with data.
        */
  -    public byte[] setUploadData ();
  +    public byte[] getUploadData();
   
   
       /**
  @@ -130,8 +130,7 @@
        * @param name A String with the name.
        * @param value A FileItem with the value.
        */
  -    public void append( String name,
  -                        FileItem value );
  +    public void append(String name, FileItem value);
   
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>