1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import org.apache.avalon.framework.configuration.Configuration; 19 import org.apache.avalon.framework.configuration.ConfigurationException; 20 import org.apache.avalon.framework.thread.ThreadSafe; 21 import org.apache.cocoon.components.treeprocessor.NamedContainerNodeBuilder; 22 import org.apache.cocoon.components.treeprocessor.NamedProcessingNode; 23 import org.apache.cocoon.components.treeprocessor.ProcessingNode; 24 25 31 32 public class ViewNodeBuilder extends NamedContainerNodeBuilder implements ThreadSafe { 33 34 public ProcessingNode buildNode(Configuration config) throws Exception { 35 36 String label = config.getAttribute("from-label", null); 38 39 if (label == null) { 40 String position = config.getAttribute("from-position"); 41 if ("first".equals(position)) { 42 label = SitemapLanguage.FIRST_POS_LABEL; 43 } else if ("last".equals(position)) { 44 label = SitemapLanguage.LAST_POS_LABEL; 45 } else { 46 String msg = "Bad value for 'from-position' at " + config.getLocation(); 47 throw new ConfigurationException(msg); 48 } 49 } 50 51 SitemapLanguage sitemapBuilder = (SitemapLanguage)this.treeBuilder; 52 53 sitemapBuilder.setBuildingView(true); 55 56 NamedProcessingNode result = (NamedProcessingNode)super.buildNode(config); 58 59 sitemapBuilder.addViewForLabel(label, result.getName()); 60 61 sitemapBuilder.setBuildingView(false); 63 64 return result; 65 } 66 } 67 | Popular Tags |