1 16 17 package org.apache.velocity.tools.view; 18 19 import org.apache.commons.digester.Digester; 20 import org.apache.commons.digester.RuleSetBase; 21 import org.apache.velocity.tools.view.DataInfo; 22 import org.apache.velocity.tools.view.ViewToolInfo; 23 24 33 public class ToolboxRuleSet extends RuleSetBase 34 { 35 36 47 public void addRuleInstances(Digester digester) 48 { 49 addToolRules(digester); 50 addDataRules(digester); 51 } 52 53 54 57 protected void addToolRules(Digester digester) 58 { 59 digester.addObjectCreate("toolbox/tool", getToolInfoClass()); 60 digester.addBeanPropertySetter("toolbox/tool/key", "key"); 61 digester.addBeanPropertySetter("toolbox/tool/class", "classname"); 62 digester.addSetNext("toolbox/tool", "addTool"); 63 } 64 65 66 69 protected void addDataRules(Digester digester) 70 { 71 digester.addObjectCreate("toolbox/data", getDataInfoClass()); 72 digester.addSetProperties("toolbox/data"); 73 digester.addBeanPropertySetter("toolbox/data/key", "key"); 74 digester.addBeanPropertySetter("toolbox/data/value", "value"); 75 digester.addSetNext("toolbox/data", "addTool"); 76 } 77 78 79 82 protected Class getToolInfoClass() 83 { 84 return ViewToolInfo.class; 85 } 86 87 88 91 protected Class getDataInfoClass() 92 { 93 return DataInfo.class; 94 } 95 96 } 97 | Popular Tags |