2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.shale.clay.component.chain;
22
23 import java.util.Map;
24 import java.util.TreeMap;
25 import java.util.TreeSet;
26
27 import javax.faces.component.UIComponent;
28 import javax.faces.context.FacesContext;
29
30 import org.apache.commons.chain.impl.ContextBase;
31 import org.apache.shale.clay.config.beans.AttributeBean;
32 import org.apache.shale.clay.config.beans.ComponentBean;
33
34 /***
35 * <p>This context is passed to all the commands in this package
36 * used to create the sub component tree for the clay component.
37 * The use of the context object promotes a reusable logic
38 * fragments that are loosely coupled and kind of snap togather.
39 * </p>
40 */
41 public class ClayContext extends ContextBase {
42
43 /***
44 * <p>Unique serialization id.</p>
45 */
46 private static final long serialVersionUID = 3618132372818901298L;
47
48 /***
49 * <p>Symbol table that holds literal strings that
50 * will be replaced within the value of an attribute.</p>
51 */
52 private Map symbols = null;
53
54 /***
55 * <p>Returns a Map containing replacement symbols
56 * within meta-component attributes.</p>
57 *
58 * @return map of {@link org.apache.shale.clay.config.beans.SymbolBean}
59 */
60 public Map getSymbols() {
61 if (symbols == null) {
62 symbols = new TreeMap();
63 }
64
65 return symbols;
66 }
67
68 /***
69 * <p>Sets a Map containing replacement symbols
70 * within meta-component attributes.</p>
71 *
72 * @param symbols map of {@link org.apache.shale.clay.config.beans.SymbolBean}
73 */
74 public void setSymbols(Map symbols) {
75 this.symbols = symbols;
76 }
77
78
79 /***
80 * <p>Unique identifier for a component metadata definition.</p>
81 */
82 private String jsfid = null;
83
84 /***
85 * <p>Returns the unique identifier for a component metadata definition.</p>
86 *
87 * @return jsfid
88 */
89 public String getJsfid() {
90 return jsfid;
91 }
92
93 /***
94 * <p>Sets the unique identifier for a component metadata definition.</p>
95 *
96 * @param jsfid unique component identifier
97 */
98 public void setJsfid(String jsfid) {
99 this.jsfid = jsfid;
100 }
101
102 /***
103 * <p>A <strong>child</strong> component is a faces Component, Validator,
104 * Listener or Converter that has a parent. Because a {@link org.apache.shale.clay.component.Clay} component
105 * is nested within a JSF/JSP page, it will should always have a parent.
106 * </p>
107 */
108 private Object child = null;
109
110 /***
111 * <b>Returns a child component that can be a UIComponent, Validator,
112 * Listener or Converter.
113 * </b>
114 *
115 * @return child component
116 */
117 public Object getChild() {
118 return child;
119 }
120
121 /***
122 * <p>Sets a child component that can be a UIComponent, Validator,
123 * Listener or Converter.
124 * </p>
125 *
126 * @param child component
127 */
128 public void setChild(Object child) {
129 this.child = child;
130 }
131
132 /***
133 * <p>The root of a {@link org.apache.shale.clay.component.Clay} component defined by a
134 * {@link org.apache.shale.clay.taglib.ClayTag} has a base metadata object of type
135 * {@link org.apache.shale.clay.config.beans.ComponentBean}. It can be defined in an XML
136 * file or dynamically built from a HTML fragment or defined
137 * at runtime.</p>
138 */
139 private ComponentBean rootElement = null;
140
141 /***
142 * <p>Returns the root config object used to construct the
143 * {@link org.apache.shale.clay.component.Clay} component subtree.
144 * </p>
145 *
146 * @return config bean
147 */
148 public ComponentBean getRootElement() {
149 return rootElement;
150 }
151
152 /***
153 * <p>Sets the root config object used to construct the
154 * {@link org.apache.shale.clay.component.Clay} component subtree.
155 * </p>
156 *
157 * @param rootElement parent config bean
158 */
159 public void setRootElement(ComponentBean rootElement) {
160 this.rootElement = rootElement;
161 }
162
163 /***
164 * <p>An attribute that is the current index in the
165 * <code>attributes</code> collection of the {@link org.apache.shale.clay.config.beans.ComponentBean}
166 * object. There are five <code>Command</code> object that use the
167 * <code>attribute</code> property in the context.
168 * <dl>
169 * <dd>{@link org.apache.shale.clay.component.chain.PropertyActionCommand}
170 * <dd>{@link org.apache.shale.clay.component.chain.PropertyActionListenerCommand}
171 * <dd>{@link org.apache.shale.clay.component.chain.PropertyValidatorCommand}
172 * <dd>{@link org.apache.shale.clay.component.chain.PropertyValueChangeListenerCommand}
173 * <dd>{@link org.apache.shale.clay.component.chain.PropertyValueCommand}
174 * </dl>
175 *
176 */
177 private AttributeBean attribute = null;
178
179 /***
180 * <p>Sets the current attribute for each in
181 * {@link org.apache.shale.clay.component.chain.AssignPropertiesCommand}.
182 * </p>
183 *
184 * @param attribute current attribute bean
185 */
186 public void setAttribute(AttributeBean attribute) {
187 this.attribute = attribute;
188 }
189
190 /***
191 * <p>Gets the current attribute for each in
192 * {@link org.apache.shale.clay.component.chain.AssignPropertiesCommand}.
193 * </p>
194 *
195 * @return current attribute bean
196 */
197 public AttributeBean getAttribute() {
198 return attribute;
199 }
200
201 /***
202 * <p>Represents the current component metadata used to build
203 * an associated JSF resource.</p>
204 */
205 private ComponentBean displayElement = null;
206
207 /***
208 * <p>Returns the current component metadata used to build
209 * a JSF resource.
210 * </p>
211 *
212 * @return current config bean
213 */
214 public ComponentBean getDisplayElement() {
215 return displayElement;
216 }
217
218 /***
219 * <p>Sets the current component metadata used to build
220 * a JSF resource.
221 * </p>
222 *
223 * @param displayElement config bean
224 */
225 public void setDisplayElement(ComponentBean displayElement) {
226 this.displayElement = displayElement;
227 }
228
229 /***
230 * <p>Reference to the current {@link FacesContext}.</p>
231 */
232 private FacesContext facesContext = null;
233
234 /***
235 * <p>Returns the current faces Context.</p>
236 *
237 * @return faces context
238 */
239 public FacesContext getFacesContext() {
240 return facesContext;
241 }
242
243 /***
244 * <p>Sets the current faces Context.</p>
245 *
246 * @param facesContext jsf context
247 */
248 public void setFacesContext(FacesContext facesContext) {
249 this.facesContext = facesContext;
250 }
251
252 /***
253 * <p>The <strong>parent</strong> of the <strong>child</strong>
254 * component. The <strong>parent</strong> can be something other
255 * than a subclass of <code>UIComponent</code>.
256 * </p>
257 */
258 private UIComponent parent = null;
259
260 /***
261 * <p>Returns the <strong>parent</strong> of the <strong>child</strong>.</p>
262 *
263 * @return current parent component
264 */
265 public UIComponent getParent() {
266 return parent;
267 }
268
269 /***
270 * <p>Sets the <strong>parent</strong> of the <strong>child</strong>.</p>
271 *
272 * @param parent current
273 */
274 public void setParent(UIComponent parent) {
275 this.parent = parent;
276 }
277
278 /***
279 * <p>Index at which a new component must be added in the list of childs.</p>
280 */
281 private int childIndex = 0;
282
283 /***
284 * <p>Returns the index at which a new component must be added in the list
285 * of childs.</p>
286 *
287 * @return current child index
288 */
289 public int getChildIndex() {
290 return childIndex;
291 }
292
293 /***
294 * <p>Sets the index at which a new component must be added in the list
295 * of childs.</p>
296 *
297 * @param index current child index
298 */
299 public void setChildIndex(int index) {
300 childIndex = index;
301 }
302
303 /***
304 * <p>Each <code>displayElement</code> is given a unique id. This
305 * set represents each {@link ComponentBean} used in the page
306 * composition.</p>
307 */
308 private TreeSet jspIds = null;
309
310 /***
311 * @return the set that represents each <code>displayElement</code> used
312 * to build the target JSF sub componennt tree
313 */
314 public TreeSet getJspIds() {
315 return jspIds;
316 }
317
318 /***
319 * @param graph the set that represents each <code>displayElement</code> used
320 * to build the target JSF sub componennt tree
321 */
322 public void setJspIds(TreeSet graph) {
323 jspIds = graph;
324 }
325 }