Class VariableSubstitutor
java.lang.Object
org.apache.commons.digester.Substitutor
org.apache.commons.digester.substitution.VariableSubstitutor
Substitutor implementation that support variable replacement
for both attributes and body text.
The actual expansion of variables into text is delegated to
VariableExpander
implementations.
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate VariableExpander
The expander to be used to expand variables in the attributes.private VariableExpander
The expander to be used to expand variables in the body text.private VariableAttributes
Attributes implementation that (lazily) performs variable substitution. -
Constructor Summary
ConstructorsConstructorDescriptionVariableSubstitutor
(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
Modifier and TypeMethodDescriptionsubstitute
(String bodyText) Substitutes for the body text.substitute
(Attributes attributes) Substitutes the attributes (before they are passed to theRule
implementations's)
-
Field Details
-
attributesExpander
The expander to be used to expand variables in the attributes. Null when no expansion should be performed. -
variableAttributes
Attributes implementation that (lazily) performs variable substitution. Will be lazily created when needed then reused. -
bodyTextExpander
The expander to be used to expand variables in the body text. Null when no expansion should be performed.
-
-
Constructor Details
-
VariableSubstitutor
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
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 Details
-
substitute
Substitutes the attributes (before they are passed to theRule
implementations's)- Specified by:
substitute
in classSubstitutor
- Parameters:
attributes
- theAttributes
passed intoDigester
by the SAX parser, not null (but may be empty)- Returns:
Attributes
to be passed to theRule
implementations. 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.- Specified by:
substitute
in classSubstitutor
- Parameters:
bodyText
- the body text (as passed toDigester
)- Returns:
- the body text to be passed to the
Rule
implementations
-