1 17 18 package org.apache.commons.digester.substitution; 19 20 import org.apache.commons.digester.Substitutor; 21 22 import org.xml.sax.Attributes ; 23 24 34 public class VariableSubstitutor extends Substitutor { 35 36 40 private VariableExpander attributesExpander; 41 42 46 private VariableAttributes variableAttributes; 47 48 52 private VariableExpander bodyTextExpander; 53 54 60 public VariableSubstitutor(VariableExpander expander) { 61 this(expander, expander); 62 } 63 64 71 public VariableSubstitutor(VariableExpander attributesExpander, VariableExpander bodyTextExpander) { 72 this.attributesExpander = attributesExpander; 73 this.bodyTextExpander = bodyTextExpander; 74 variableAttributes = new VariableAttributes(); 75 } 76 77 81 public Attributes substitute(Attributes attributes) { 82 Attributes results = attributes; 83 if (attributesExpander != null) { 84 variableAttributes.init(attributes, attributesExpander); 85 results = variableAttributes; 86 } 87 return results; 88 } 89 90 98 public String substitute(String bodyText) { 99 String result = bodyText; 100 if (bodyTextExpander != null) { 101 result = bodyTextExpander.expand(bodyText); 102 } 103 return result; 104 } 105 } 106 | Popular Tags |