KickJava   Java API By Example, From Geeks To Geeks.

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


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.avalon.framework.component.ComponentException;
19 import org.apache.avalon.framework.component.ComponentManager;
20 import org.apache.avalon.framework.component.Recomposable;
21 import org.apache.avalon.framework.configuration.Configuration;
22 import org.apache.avalon.framework.configuration.ConfigurationException;
23 import org.apache.avalon.framework.logger.AbstractLogEnabled;
24
25 /**
26  *
27  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
28  * @version CVS $Id: AbstractProcessingNodeBuilder.java 267195 2005-09-02 12:45:49Z pier $
29  */

30 public abstract class AbstractProcessingNodeBuilder extends AbstractLogEnabled
31                                                     implements ProcessingNodeBuilder, Recomposable {
32
33     protected TreeBuilder treeBuilder;
34
35     protected ComponentManager manager;
36
37     public void compose(ComponentManager manager) throws ComponentException {
38         this.manager = manager;
39     }
40
41     public void recompose(ComponentManager manager) throws ComponentException {
42         this.manager = manager;
43     }
44
45     public void setBuilder(TreeBuilder treeBuilder) {
46         this.treeBuilder = treeBuilder;
47     }
48
49     /**
50      * Does this node accept parameters ? Default is true : if a builder that doesn't
51      * have parameters doesn't override this method, erroneous parameters will be silently
52      * ignored.
53      */

54     protected boolean hasParameters() {
55         return true;
56     }
57
58     /**
59      * Check if the namespace URI of the given configuraition is the same as the
60      * one given by the builder.
61      */

62     protected void checkNamespace(Configuration config) throws ConfigurationException {
63         if (!this.treeBuilder.getNamespace().equals(config.getNamespace())) {
64             String JavaDoc msg = "Invalid namespace '" + config.getNamespace() + "' at " + config.getLocation();
65             throw new ConfigurationException(msg);
66         }
67     }
68 }
69
Popular Tags