KickJava   Java API By Example, From Geeks To Geeks.

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


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.configuration.Configuration;
19 import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder;
20 import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
21 import org.apache.cocoon.components.treeprocessor.ProcessingNode;
22 import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
23
24 import org.apache.cocoon.serialization.Serializer;
25
26 import java.util.Collection JavaDoc;
27 import java.util.Map JavaDoc;
28
29 /**
30  *
31  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
32  * @version CVS $Id: SerializeNodeBuilder.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  */

34
35 public class SerializeNodeBuilder extends AbstractProcessingNodeBuilder
36   implements LinkedProcessingNodeBuilder {
37
38     private SerializeNode node;
39
40     private Collection JavaDoc views;
41     private Map JavaDoc pipelineHints;
42
43     /** Serializers can have parameters -- return <code>true</code> */
44     protected boolean hasParameters() {
45         return true;
46     }
47
48     public ProcessingNode buildNode(Configuration config) throws Exception JavaDoc {
49
50         String JavaDoc type = this.treeBuilder.getTypeForStatement(config, Serializer.ROLE + "Selector");
51
52         this.views = ((SitemapLanguage)this.treeBuilder).getViewsForStatement(Serializer.ROLE, type, config);
53         this.pipelineHints = ((SitemapLanguage)this.treeBuilder).getHintsForStatement(Serializer.ROLE, type, config);
54
55         this.node = new SerializeNode(
56             type,
57             VariableResolverFactory.getResolver(config.getAttribute("src", null), this.manager),
58             VariableResolverFactory.getResolver(config.getAttribute("mime-type", null), this.manager),
59             config.getAttributeAsInteger("status-code", -1)
60         );
61         this.node.setPipelineHints(this.pipelineHints);
62         return this.treeBuilder.setupNode(node, config);
63     }
64
65     public void linkNode() throws Exception JavaDoc {
66         this.node.setViews(
67             ((SitemapLanguage)this.treeBuilder).getViewNodes(this.views)
68         );
69     }
70 }
71
Popular Tags