org.apache.commons.digester.substitution
Class MultiVariableExpander

java.lang.Object
  extended by org.apache.commons.digester.substitution.MultiVariableExpander
All Implemented Interfaces:
VariableExpander

public class MultiVariableExpander
extends java.lang.Object
implements VariableExpander

Expands variable references from multiple sources.

Since:
1.6

Constructor Summary
MultiVariableExpander()
           
 
Method Summary
 void addSource(java.lang.String marker, java.util.Map source)
           
 java.lang.String expand(java.lang.String param)
          Return the input string with any variables replaced by their corresponding value.
 java.lang.String expand(java.lang.String str, java.lang.String marker, java.util.Map source)
          Replace any occurrences within the string of the form "marker{key}" with the value from source[key].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiVariableExpander

public MultiVariableExpander()
Method Detail

addSource

public void addSource(java.lang.String marker,
                      java.util.Map source)

expand

public java.lang.String expand(java.lang.String param)
Description copied from interface: VariableExpander
Return the input string with any variables replaced by their corresponding value. If there are no variables in the string, then the input parameter is returned unaltered.

Specified by:
expand in interface VariableExpander

expand

public java.lang.String expand(java.lang.String str,
                               java.lang.String marker,
                               java.util.Map source)
Replace any occurrences within the string of the form "marker{key}" with the value from source[key].

Commonly, the variable marker is "$", in which case variables are indicated by ${key} in the string.

Returns the string after performing all substitutions.

If no substitutions were made, the input string object is returned (not a copy).

Throws:
java.lang.IllegalArgumentException - if the input param references a variable which is not known to the specified source.


Copyright © 2001-2005 The Apache Software Foundation. All Rights Reserved.