KickJava   Java API By Example, From Geeks To Geeks.

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


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.sitemap;
17
18 import org.apache.avalon.framework.configuration.Configuration;
19 import org.apache.avalon.framework.thread.ThreadSafe;
20
21 import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder;
22 import org.apache.cocoon.components.treeprocessor.ProcessingNode;
23
24 /**
25  * Builds a <map:handle-errors>
26  *
27  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
28  * @version $Id: HandleErrorsNodeBuilder.java 157541 2005-03-15 14:26:31Z vgritsenko $
29  */

30 public class HandleErrorsNodeBuilder extends AbstractParentProcessingNodeBuilder
31                                      implements ThreadSafe {
32
33     /** This builder has no parameters -- return <code>false</code> */
34     protected boolean hasParameters() {
35         return false;
36     }
37
38     public ProcessingNode buildNode(Configuration config) throws Exception JavaDoc {
39
40         HandleErrorsNode node = new HandleErrorsNode(config.getAttributeAsInteger("type", -1),
41                                                      config.getAttribute("when", "external"));
42         this.treeBuilder.setupNode(node, config);
43
44         // Set a flag that will prevent redirects
45
((SitemapLanguage) this.treeBuilder).setBuildingErrorHandler(true);
46         try {
47             // Get all children
48
node.setChildren(buildChildNodes(config));
49         } finally {
50             // And clear the flag
51
((SitemapLanguage) this.treeBuilder).setBuildingErrorHandler(false);
52         }
53
54         return node;
55     }
56 }
57
Popular Tags