KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > treeprocessor > sitemap > ActSetNode


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.treeprocessor.sitemap;
17
18 import org.apache.avalon.framework.parameters.Parameters;
19 import org.apache.cocoon.components.treeprocessor.InvokeContext;
20 import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
21 import org.apache.cocoon.components.treeprocessor.SimpleParentProcessingNode;
22 import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
23 import org.apache.cocoon.environment.Environment;
24
25 import java.util.Map JavaDoc;
26
27 /**
28  * Handles <map:act type="..."> (action-sets calls are handled by {@link ActSetNode}).
29  *
30  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
31  * @version CVS $Id: ActSetNode.java 37174 2004-08-29 16:29:31Z cziegeler $
32  */

33
34 public class ActSetNode extends SimpleParentProcessingNode
35   implements ParameterizableProcessingNode {
36
37     /** The parameters of this node */
38     private Map JavaDoc parameters;
39
40     /** The action set to call */
41     private ActionSetNode actionSet;
42
43     public void setParameters(Map JavaDoc parameterMap) {
44         this.parameters = parameterMap;
45     }
46
47     public void setActionSet(ActionSetNode actionSet) {
48         this.actionSet = actionSet;
49     }
50
51     public final boolean invoke(Environment env, InvokeContext context)
52       throws Exception JavaDoc {
53
54         // Perform any common invoke functionality
55
super.invoke(env, context);
56
57         Parameters resolvedParams = VariableResolver.buildParameters(
58             this.parameters,
59             context,
60             env.getObjectModel()
61         );
62
63         Map JavaDoc result = this.actionSet.call(env, context, resolvedParams);
64
65         if (context.getRedirector().hasRedirected()) {
66             return true;
67
68         } else if (result == null) {
69             return false;
70
71         } else if (this.children == null) {
72             return true;
73
74         } else {
75             return this.invokeNodes(this.children, env, context, null, result);
76         }
77     }
78 }
79
Popular Tags