KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > flow > apples > DefaultAppleRequest


1 /*
2  * Copyright 1999-2004 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.components.flow.apples;
17
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc;
20 import java.util.Set JavaDoc;
21
22 import org.apache.cocoon.environment.Request;
23
24 /**
25  * DefaultAppleRequest wraps the nested <map:paramater> 's and the
26  * active Cocoon Environment Request to implement the service of the
27  * {@link AppleRequest} interface.
28  */

29 public class DefaultAppleRequest implements AppleRequest {
30
31     private final Map JavaDoc params;
32     private final Request cocoonRequest;
33
34     /**
35      * Constructs DefaultAppleRequest
36      * @param params the nested <code>&lt;map:parameter&gt;</code>'s from the sitemap
37      * @param request the active cocoon request
38      */

39     public DefaultAppleRequest(List JavaDoc params, Request request) {
40         this.params = AppleHelper.makeMapFromArguments(params);
41         this.cocoonRequest = request;
42     }
43     
44
45     public Request getCocoonRequest() {
46         return cocoonRequest;
47     }
48     
49
50     public Set JavaDoc getSitemapParameterNames() {
51         return this.params.keySet();
52     }
53
54
55     public String JavaDoc getSitemapParameter(String JavaDoc key, String JavaDoc defaultValue) {
56         String JavaDoc value = getSitemapParameter(key);
57         if (value == null) {
58             value = defaultValue;
59         }
60         return value;
61     }
62
63
64     public String JavaDoc getSitemapParameter(String JavaDoc key) {
65         return (String JavaDoc)this.params.get(key);
66     }
67
68
69 }
70
Popular Tags