01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.treeprocessor.sitemap;
18:
19: import java.util.Collection;
20: import java.util.Map;
21:
22: import org.apache.avalon.framework.configuration.Configuration;
23: import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder;
24: import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
25: import org.apache.cocoon.components.treeprocessor.ProcessingNode;
26: import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
27: import org.apache.cocoon.serialization.Serializer;
28:
29: /**
30: *
31: * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
32: * @version CVS $Id: SerializeNodeBuilder.java 586256 2007-10-19 04:06:50Z joerg $
33: */
34: public class SerializeNodeBuilder extends AbstractProcessingNodeBuilder
35: implements LinkedProcessingNodeBuilder {
36:
37: private SerializeNode node;
38:
39: private Collection views;
40: private Map pipelineHints;
41:
42: /** Serializers can have parameters -- return <code>true</code> */
43: protected boolean hasParameters() {
44: return true;
45: }
46:
47: public ProcessingNode buildNode(Configuration config)
48: throws Exception {
49:
50: String type = this .treeBuilder.getTypeForStatement(config,
51: Serializer.ROLE + "Selector");
52:
53: SitemapLanguage sitemapBuilder = (SitemapLanguage) this .treeBuilder;
54:
55: this .views = sitemapBuilder.getViewsForStatement(
56: Serializer.ROLE, type, config);
57: this .pipelineHints = sitemapBuilder.getHintsForStatement(
58: Serializer.ROLE, type, config);
59:
60: this .node = new SerializeNode(type, VariableResolverFactory
61: .getResolver(config.getAttribute("src", null),
62: this .manager), VariableResolverFactory
63: .getResolver(config.getAttribute("mime-type", null),
64: this .manager), VariableResolverFactory
65: .getResolver(config.getAttribute("status-code", null),
66: this .manager));
67: this .node.setPipelineHints(this .pipelineHints);
68: return this .treeBuilder.setupNode(node, config);
69: }
70:
71: public void linkNode() throws Exception {
72: this .node.setViews(((SitemapLanguage) this.treeBuilder)
73: .getViewNodes(this.views));
74: }
75: }
|