KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > layout > AbstractLayout


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.portal.layout;
17
18 import java.util.Map JavaDoc;
19 import java.util.Set JavaDoc;
20 import java.util.HashSet JavaDoc;
21 import java.util.Iterator JavaDoc;
22
23 import org.apache.cocoon.portal.factory.impl.AbstractProducible;
24 import org.apache.cocoon.portal.pluto.om.common.ParameterImpl;
25 import org.apache.commons.collections.map.LinkedMap;
26 import org.apache.pluto.om.common.Parameter;
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: AbstractLayout.java 125402 2005-01-17 08:32:27Z cziegeler $
34  */

35 public abstract class AbstractLayout
36     extends AbstractProducible
37     implements Layout, Parameters {
38     
39     protected String JavaDoc rendererName;
40     
41     protected Item parent;
42     
43     protected Map JavaDoc parameters = new LinkedMap();
44
45     /* (non-Javadoc)
46      * @see org.apache.cocoon.portal.layout.Parameters#getParameters()
47      */

48     public final Map JavaDoc getParameters() {
49         return parameters;
50     }
51
52     public final Set JavaDoc getCastorParameters()
53     {
54         Set JavaDoc set = new HashSet JavaDoc(this.parameters.size());
55         Iterator JavaDoc iterator = this.parameters.entrySet().iterator();
56         Map.Entry JavaDoc entry;
57         while (iterator.hasNext())
58         {
59             entry = (Map.Entry JavaDoc) iterator.next();
60             ParameterImpl param = new ParameterImpl();
61             param.setName((String JavaDoc) entry.getKey());
62             param.setValue((String JavaDoc) entry.getValue());
63             set.add(param);
64         }
65         return set;
66     }
67
68     public void addParameter(Parameter parameter)
69     {
70         parameters.put(parameter.getName(), parameter.getValue());
71     }
72
73     /**
74      * @see org.apache.cocoon.portal.layout.Layout#getRendererName()
75      */

76     public String JavaDoc getRendererName() {
77         if ( this.rendererName == null ) {
78             return ((LayoutDescription)this.description).getDefaultRendererName();
79         }
80         return this.rendererName;
81     }
82
83     public void setLayoutRendererName(String JavaDoc value) {
84         this.rendererName = value;
85     }
86     
87     public Item getParent() {
88         return this.parent;
89     }
90     
91     public void setParent(Item item) {
92         this.parent = item;
93     }
94
95     /* (non-Javadoc)
96      * @see org.apache.cocoon.portal.layout.Layout#getLayoutRendererName()
97      */

98     public String JavaDoc getLayoutRendererName() {
99         return this.rendererName;
100     }
101
102     
103     /* (non-Javadoc)
104      * @see java.lang.Object#clone()
105      */

106     protected Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
107         AbstractLayout clone = (AbstractLayout)super.clone();
108         
109         // we don't clone the parent; we just set it to null
110
clone.rendererName = this.rendererName;
111         clone.parameters = new LinkedMap(this.parameters);
112         clone.parent = null;
113         
114         return clone;
115     }
116     
117     /* (non-Javadoc)
118      * @see org.apache.cocoon.portal.layout.Layout#copy()
119      */

120     public Layout copy() {
121         try {
122             return (Layout)this.clone();
123         } catch (CloneNotSupportedException JavaDoc cnse) {
124             // ignore
125
}
126         return null;
127     }
128 }
129
Popular Tags