KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > treeprocessor > AbstractParentProcessingNode


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;
17
18 import org.apache.cocoon.environment.Environment;
19
20 import java.util.Map JavaDoc;
21
22 /**
23  *
24  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
25  * @version CVS $Id: AbstractParentProcessingNode.java 47299 2004-09-27 16:00:06Z vgritsenko $
26  */

27 public abstract class AbstractParentProcessingNode extends AbstractProcessingNode {
28
29     /**
30      * Invoke all nodes of a node array in order, until one succeeds.
31      *
32      * @param currentMap the <code>Map<code> of parameters produced by this node,
33      * which is added to <code>listOfMap</code>.
34      */

35     protected final boolean invokeNodes(ProcessingNode[] nodes,
36                                         Environment env,
37                                         InvokeContext context,
38                                         String JavaDoc currentName,
39                                         Map JavaDoc currentMap)
40     throws Exception JavaDoc {
41
42         context.pushMap(currentName,currentMap);
43
44         try {
45             for (int i = 0; i < nodes.length; i++) {
46                 if (nodes[i].invoke(env, context)) {
47                     // Success
48
return true;
49                 }
50             }
51         } finally {
52             // No success
53
context.popMap();
54         }
55
56         return false;
57     }
58
59     /**
60      * Invoke all nodes of a node array in order, until one succeeds.
61      */

62     protected final boolean invokeNodes (ProcessingNode[] nodes,
63                                          Environment env,
64                                          InvokeContext context)
65     throws Exception JavaDoc {
66
67         for (int i = 0; i < nodes.length; i++) {
68             if (nodes[i].invoke(env, context)) {
69                 return true;
70             }
71         }
72
73         return false;
74     }
75 }
76
Popular Tags