cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/environment/wrapper RequestWrapper.java
Date Thu, 12 Jul 2001 12:39:32 GMT
cziegeler    01/07/12 05:39:29

  Modified:    src/org/apache/cocoon/environment/wrapper Tag:
                        cocoon_20_branch RequestWrapper.java
  Log:
  The cocoon: sources inherit the parameters from the calling source
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +38 -5     xml-cocoon2/src/org/apache/cocoon/environment/wrapper/RequestWrapper.java
  
  Index: RequestWrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/wrapper/RequestWrapper.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- RequestWrapper.java	2001/07/10 10:09:03	1.1.2.1
  +++ RequestWrapper.java	2001/07/12 12:39:00	1.1.2.2
  @@ -23,7 +23,7 @@
    * are different.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version $Id: RequestWrapper.java,v 1.1.2.1 2001/07/10 10:09:03 cziegeler Exp $
  + * @version $Id: RequestWrapper.java,v 1.1.2.2 2001/07/12 12:39:00 cziegeler Exp $
    */
   public final class RequestWrapper implements Request {
   
  @@ -76,15 +76,48 @@
       }
   
       public String getParameter(String name) {
  -        return this.parameters.getParameter(name);
  +        String value = this.parameters.getParameter(name);
  +        if (value == null)
  +            return this.req.getParameter(name);
  +        else
  +            return value;
       }
   
       public Enumeration getParameterNames() {
  -        return this.parameters.getParameterNames();
  +        // put all parameter names into a set
  +        Set parameterNames = new HashSet();
  +        Enumeration names = this.parameters.getParameterNames();
  +        while (names.hasMoreElements() == true) {
  +            parameterNames.add(names.nextElement());
  +    }
  +        names = this.req.getParameterNames();
  +        while (names.hasMoreElements() == true) {
  +            parameterNames.add(names.nextElement());
  +        }
  +        return new EnumerationFromIterator(parameterNames.iterator());
  +    }
  +
  +    final class EnumerationFromIterator implements Enumeration {
  +        private Iterator iter;
  +        EnumerationFromIterator(Iterator iter) {
  +            this.iter = iter;
  +        }
  +
  +        public boolean hasMoreElements() {
  +            return iter.hasNext();
  +        }
  +        public Object nextElement() { return iter.next(); }
       }
   
       public String[] getParameterValues(String name) {
  -        return this.parameters.getParameterValues(name);
  +        String[] values = this.parameters.getParameterValues(name);
  +        String[] inherited = this.req.getParameterValues(name);
  +        if (inherited == null) return values;
  +        if (values == null) return inherited;
  +        String[] allValues = new String[values.length + inherited.length];
  +        System.arraycopy(values, 0, allValues, 0, values.length);
  +        System.arraycopy(inherited, 0, allValues, values.length, inherited.length);
  +        return allValues;
       }
   
       public String getProtocol() {
  @@ -226,4 +259,4 @@
           return this.req.isUserInRole(role);
       }
   
  -}
  \ No newline at end of file
  +}
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message