Class Substitutor
- Direct Known Subclasses:
VariableSubstitutor
(Logical) Interface for substitution strategies. (It happens to be implemented as a Java abstract class to allow future additions to be made without breaking backwards compatibility.)
Usage: When Digester.setSubstitutor(org.apache.commons.digester.Substitutor) is set, Digester
calls the methods in this interface to create substitute values which will
be passed into the Rule implementations.
Of course, it is perfectly acceptable for implementations not to make
substitutions and simply return the inputs.
Different strategies are supported for attributes and body text.
- Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Stringsubstitute(String bodyText) Substitutes for the body text.abstract Attributessubstitute(Attributes attributes) Substitutes the attributes (before they are passed to theRuleimplementations's).
-
Constructor Details
-
Substitutor
public Substitutor()
-
-
Method Details
-
substitute
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.- 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
Substitutes for the body text. This method may substitute values into the body text of the elements that Digester parses.- Parameters:
bodyText- the body text (as passed toDigester)- Returns:
- the body text to be passed to the
Ruleimplementations
-