Class VariableSubstitutor
- java.lang.Object
-
- org.apache.commons.digester3.Substitutor
-
- org.apache.commons.digester3.substitution.VariableSubstitutor
-
public class VariableSubstitutor extends Substitutor
Substitutor implementation that support variable replacement for both attributes and body text. The actual expansion of variables into text is delegated toVariableExpanderimplementations. Supports setting an expander just for body text or just for attributes. Also supported is setting no expanders for body text and for attributes.- Since:
- 1.6
-
-
Constructor Summary
Constructors Constructor Description VariableSubstitutor(VariableExpander expander)Constructs a Substitutor which uses the same VariableExpander for both body text and attibutes.VariableSubstitutor(VariableExpander attributesExpander, VariableExpander bodyTextExpander)Constructs a Substitutor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringsubstitute(java.lang.String bodyText)Substitutes for the body text.org.xml.sax.Attributessubstitute(org.xml.sax.Attributes attributes)Substitutes the attributes (before they are passed to theRuleimplementations's).
-
-
-
Constructor Detail
-
VariableSubstitutor
public VariableSubstitutor(VariableExpander expander)
Constructs a Substitutor which uses the same VariableExpander for both body text and attibutes.- Parameters:
expander- VariableExpander implementation, null if no substitutions are to be performed
-
VariableSubstitutor
public VariableSubstitutor(VariableExpander attributesExpander, VariableExpander bodyTextExpander)
Constructs a Substitutor.- Parameters:
attributesExpander- VariableExpander implementation to be used for attributes, null if no attribute substitutions are to be performedbodyTextExpander- VariableExpander implementation to be used for bodyTextExpander, null if no attribute substitutions are to be performed
-
-
Method Detail
-
substitute
public org.xml.sax.Attributes substitute(org.xml.sax.Attributes attributes)
Substitutes the attributes (before they are passed to the
Ruleimplementations's).Digesterwill only call this method a second time once the originalAttributesinstance can be safely reused. The implementation is therefore free to reuse the sameAttributesinstance for all calls.- Specified by:
substitutein classSubstitutor- Parameters:
attributes- theAttributespassed intoDigesterby the SAX parser, not null (but may be empty)- Returns:
Attributesto be passed to theRuleimplementations. This method may pass back the Attributes passed in. Not null but possibly empty.
-
substitute
public java.lang.String substitute(java.lang.String bodyText)
Substitutes for the body text. This method may substitute values into the body text of the elements that Digester parses.- Specified by:
substitutein classSubstitutor- Parameters:
bodyText- the body text (as passed toDigester)- Returns:
- the body text to be passed to the
Ruleimplementations
-
-