1 16 package org.apache.cocoon.components.treeprocessor; 17 18 import java.util.HashMap ; 19 import java.util.Map ; 20 21 import org.apache.cocoon.ProcessingException; 22 import org.apache.cocoon.environment.Environment; 23 24 30 31 public final class CategoryNode extends AbstractParentProcessingNode { 32 33 34 private String categoryName; 35 36 37 private Map nodes; 38 39 public void setCategory(String categoryName, Map nodes) { 40 this.categoryName = categoryName; 41 this.nodes = (nodes != null) ? nodes : new HashMap (0); 42 } 43 44 public final boolean invoke(Environment env, InvokeContext context) throws Exception { 45 String msg = "Cannot invoke " + this.categoryName + " at " + getLocation(); 46 throw new ProcessingException(msg); 47 } 48 49 public final ProcessingNode getNodeByName(String name) throws Exception { 50 ProcessingNode node = (ProcessingNode)nodes.get(name); 51 if (node == null) { 52 String msg = "Unknown " + this.categoryName + " named '" + name + "' at " + getLocation(); 53 throw new ProcessingException(msg); 54 } 55 56 return node; 57 } 58 59 public final boolean invokeByName(String name, Environment env, InvokeContext context) 60 throws Exception { 61 62 return getNodeByName(name).invoke(env, context); 63 } 64 } 65 | Popular Tags |