org.apache.commons.digester.substitution

Class 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 to {@link 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
VariableExpanderattributesExpander
The expander to be used to expand variables in the attributes.
VariableExpanderbodyTextExpander
The expander to be used to expand variables in the body text.
VariableAttributesvariableAttributes
Attributes implementation that (lazily) performs variable substitution.
Constructor Summary
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
Attributessubstitute(Attributes attributes)
Substitutes the attributes (before they are passed to the Rule implementations's)
Stringsubstitute(String bodyText)
Substitutes for the body text.

Field Detail

attributesExpander

private VariableExpander attributesExpander
The expander to be used to expand variables in the attributes. Null when no expansion should be performed.

bodyTextExpander

private VariableExpander bodyTextExpander
The expander to be used to expand variables in the body text. Null when no expansion should be performed.

variableAttributes

private VariableAttributes variableAttributes
Attributes implementation that (lazily) performs variable substitution. Will be lazily created when needed then reused.

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 performed bodyTextExpander VariableExpander implementation to be used for bodyTextExpander, null if no attribute substitutions are to be performed

Method Detail

substitute

public Attributes substitute(Attributes attributes)
Substitutes the attributes (before they are passed to the Rule implementations's)

substitute

public String substitute(String bodyText)
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 to Digester)

Returns: the body text to be passed to the Rule implementations

Copyright 2001-2005 The Apache Software Foundation.