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.portal.layout;
18:
19: import java.util.Map;
20: import java.util.Iterator;
21: import java.util.HashSet;
22: import java.util.Set;
23:
24: import org.apache.commons.collections.map.LinkedMap;
25: import org.apache.pluto.om.common.Parameter;
26: import org.apache.cocoon.portal.pluto.om.common.ParameterImpl;
27:
28: /**
29: *
30: * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
31: * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
32: *
33: * @version CVS $Id: AbstractParameters.java 603313 2007-12-11 17:30:12Z cziegeler $
34: */
35: public abstract class AbstractParameters implements Parameters,
36: Cloneable {
37:
38: protected Map parameters = new LinkedMap(3);
39:
40: /* (non-Javadoc)
41: * @see org.apache.cocoon.portal.layout.Parameters#getParameters()
42: */
43: public final Map getParameters() {
44: return parameters;
45: }
46:
47: public final Set getCastorParameters() {
48: Set set = new HashSet(this .parameters.size());
49: Iterator iterator = this .parameters.entrySet().iterator();
50: Map.Entry entry;
51: while (iterator.hasNext()) {
52: entry = (Map.Entry) iterator.next();
53: ParameterImpl param = new ParameterImpl();
54: param.setName((String) entry.getKey());
55: param.setValue((String) entry.getValue());
56: set.add(param);
57: }
58: return set;
59: }
60:
61: public void addParameter(Parameter parameter) {
62: parameters.put(parameter.getName(), parameter.getValue());
63: }
64:
65: /* (non-Javadoc)
66: * @see java.lang.Object#clone()
67: */
68: protected Object clone() throws CloneNotSupportedException {
69: AbstractParameters clone = (AbstractParameters) super .clone();
70:
71: clone.parameters = new LinkedMap(this.parameters);
72:
73: return clone;
74: }
75: }
|