KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 1999-2005 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.avalon.framework.component.Component;
19 import org.apache.avalon.framework.component.ComponentManager;
20 import org.apache.avalon.framework.configuration.Configuration;
21 import org.apache.avalon.framework.configuration.ConfigurationException;
22 import org.apache.excalibur.source.Source;
23
24 import java.util.List JavaDoc;
25
26 /**
27  *
28  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
29  * @version CVS $Id: TreeBuilder.java 190154 2005-06-11 17:15:03Z cziegeler $
30  */

31
32 public interface TreeBuilder extends Component {
33
34     void setProcessor(ConcreteTreeProcessor processor);
35
36     ConcreteTreeProcessor getProcessor();
37
38     /**
39      * Returns the language that is being built (e.g. "sitemap").
40      */

41     String JavaDoc getLanguage();
42
43     /**
44      * Returns the name of the parameter element.
45      */

46     String JavaDoc getParameterName();
47
48     /**
49      * Register a <code>ProcessingNode</code> under a given name.
50      * For example, <code>ResourceNodeBuilder</code> stores here the <code>ProcessingNode</code>s
51      * it produces for use by sitemap pipelines. This allows to turn the tree into a graph.
52      * If a node with the name is already registed, the process fails!
53      * @return If the node could be registered, <code>true</code> is returned; otherwise false.
54      */

55     boolean registerNode(String JavaDoc name, ProcessingNode node);
56
57     /**
58      * @throws IllegalStateException
59      */

60     ProcessingNode getRegisteredNode(String JavaDoc name);
61
62     ProcessingNodeBuilder createNodeBuilder(Configuration config) throws Exception JavaDoc;
63
64     /**
65      * Get the namespace URI that builders should use to find their nodes.
66      */

67     String JavaDoc getNamespace();
68
69     /**
70      * Build a processing tree from a <code>Configuration</code>.
71      */

72     ProcessingNode build(Configuration tree) throws Exception JavaDoc;
73
74     ProcessingNode build(Source source) throws Exception JavaDoc;
75
76     String JavaDoc getFileName();
77
78     /**
79      * Return the list of <code>ProcessingNodes</code> part of this tree that are
80      * <code>Disposable</code>. Care should be taken to properly dispose them before
81      * trashing the processing tree.
82      */

83     List JavaDoc getDisposableNodes();
84
85     /**
86      * Setup a <code>ProcessingNode</code> by setting its location, calling all
87      * the lifecycle interfaces it implements and giving it the parameter map if
88      * it's a <code>ParameterizableNode</code>.
89      * <p>
90      * As a convenience, the node is returned by this method to allow constructs
91      * like <code>return treeBuilder.setupNode(new MyNode(), config)</code>.
92      */

93     ProcessingNode setupNode(ProcessingNode node, Configuration config) throws Exception JavaDoc;
94
95
96     /**
97      * Get the type for a statement : it returns the 'type' attribute if present,
98      * and otherwhise the default hint for the <code>ComponentSelector</code> identified by
99      * the role <code>role</code>.
100      *
101      * @throws ConfigurationException if the default type could not be found.
102      */

103     String JavaDoc getTypeForStatement(Configuration statement, String JavaDoc role) throws ConfigurationException;
104
105     /**
106      * Return the sitemap component manager
107      */

108     ComponentManager getSitemapComponentManager();
109     
110     /**
111      * Add an attribute. Useful to transmit information between distant (in the tree) node builders
112      */

113     void setAttribute(String JavaDoc name, Object JavaDoc value);
114     
115     /**
116      * Get the value of an attribute.
117      */

118     Object JavaDoc getAttribute(String JavaDoc name);
119 }
120
Popular Tags