01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.flow.apples;
18:
19: import java.util.List;
20: import java.util.Map;
21: import java.util.Set;
22:
23: import org.apache.cocoon.environment.Request;
24:
25: /**
26: * DefaultAppleRequest wraps the nested <map:paramater> 's and the
27: * active Cocoon Environment Request to implement the service of the
28: * {@link AppleRequest} interface.
29: */
30: public class DefaultAppleRequest implements AppleRequest {
31:
32: private final Map params;
33: private final Request cocoonRequest;
34:
35: /**
36: * Constructs DefaultAppleRequest
37: * @param params the nested <code><map:parameter></code>'s from the sitemap
38: * @param request the active cocoon request
39: */
40: public DefaultAppleRequest(List params, Request request) {
41: this .params = AppleHelper.makeMapFromArguments(params);
42: this .cocoonRequest = request;
43: }
44:
45: public Request getCocoonRequest() {
46: return cocoonRequest;
47: }
48:
49: public Set getSitemapParameterNames() {
50: return this .params.keySet();
51: }
52:
53: public String getSitemapParameter(String key, String defaultValue) {
54: String value = getSitemapParameter(key);
55: if (value == null) {
56: value = defaultValue;
57: }
58: return value;
59: }
60:
61: public String getSitemapParameter(String key) {
62: return (String) this.params.get(key);
63: }
64:
65: }
|