KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > wsrp > consumer > RequestImpl


1 /*
2  * Copyright 2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.wsrp.consumer;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import oasis.names.tc.wsrp.v1.types.NamedString;
24
25 /**
26  * This class implements the Request interface and used by
27  * the swing consumer to store request related information.
28  *
29  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
30  * @author <a HREF="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
31  *
32  * @version $Id: RequestImpl.java 264755 2005-08-30 10:29:21Z cziegeler $
33  **/

34 public class RequestImpl implements Request {
35
36     /** Map to store all form params. */
37     protected Map JavaDoc formParameters;
38
39     /** interaction state. */
40     protected String JavaDoc interactionState;
41
42     /**
43      * Default constructor
44      **/

45     public RequestImpl() {
46         this.formParameters = new HashMap JavaDoc();
47     }
48     
49     /**
50     * Add any parameters to the request. These parameters should
51     * be carried in the form parameters field of WSRP.
52     *
53     * @param name The key which identifies the parameter
54     * @param value The value of the parameter
55     **/

56     public void addFormParameter(String JavaDoc name, String JavaDoc value) {
57         this.formParameters.put(name, value);
58     }
59     
60     /**
61      * Get all form parameters from the request. The returned
62      * <code>NamedString</code> array contains all parameter key/value pairs
63      * and can directly be passed to the form parameter field in WSRP.
64      *
65      * @return Array with all set parameters
66      **/

67     public NamedString[] getFormParameters() {
68         ArrayList JavaDoc paramList = new ArrayList JavaDoc();
69         Iterator JavaDoc params = this.formParameters.keySet().iterator();
70         while (params.hasNext()) {
71             String JavaDoc name = (String JavaDoc)params.next();
72
73             NamedString parameter = new NamedString();
74             parameter.setName(name);
75             parameter.setValue((String JavaDoc)this.formParameters.get(name));
76             paramList.add(parameter);
77         }
78         
79         NamedString[] formParams = new NamedString[paramList.size()];
80         paramList.toArray(formParams);
81
82         return formParams;
83     }
84
85     /**
86      * Set the interaction state of a portlet which should be passed
87      * to the producer.
88      *
89      * @param state the interaction state of a portlet
90      **/

91     public void setInteractionState(String JavaDoc state) {
92         this.interactionState = state;
93     }
94     
95     /**
96     * Get the interaction state of the portlet.
97     *
98     * @return interaction state of a portlet carried in a request
99     **/

100     public String JavaDoc getInteractionState() {
101         return this.interactionState;
102     }
103 }
104
Popular Tags