org.codehaus.spice.configkit
Class PropertyExpander

java.lang.Object
  |
  +--org.codehaus.spice.configkit.PropertyExpander

public final class PropertyExpander
extends Object

This is a utility class designed for expanding propertys in configuration files. Propertys are stored in Map objects and any section that begins with "${" and ends with "}" will have inner name replaced with property value from map.

Version:
$Revision: 1.1 $ $Date: 2003/12/03 03:19:28 $
Author:
Peter Donald

Field Summary
static int EMPTY_ON_UNDEFINED
          Flag indicating that undefined propertys should be replaced with a empty string "".
static int EXCEPT_ON_UNDEFINED
          Flag indicating that undefined propertys should cause an exception to be thrown.
static int LEAVE_UNDEFINED
          Flag indicating that undefined propertys should be not be replaced.
 
Constructor Summary
PropertyExpander()
          Create property expander with EXCEPT_ON_UNDEFINED policy for undefined propertys.
PropertyExpander(int onUndefined)
          Create property expander with specified policy for undefined propertys.
 
Method Summary
 void expandValues(org.w3c.dom.Element input, Map data)
          Expand all propertys in the input XML attributes and text contents.
 Properties expandValues(Properties input, Map data)
          Expand all propertys in the input Properties object.
 String expandValues(String input, Map data)
          Expand all propertys in input string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEAVE_UNDEFINED

public static final int LEAVE_UNDEFINED
Flag indicating that undefined propertys should be not be replaced. ie "${myUnresolvedProperty}"

See Also:
Constant Field Values

EXCEPT_ON_UNDEFINED

public static final int EXCEPT_ON_UNDEFINED
Flag indicating that undefined propertys should cause an exception to be thrown.

See Also:
Constant Field Values

EMPTY_ON_UNDEFINED

public static final int EMPTY_ON_UNDEFINED
Flag indicating that undefined propertys should be replaced with a empty string "".

See Also:
Constant Field Values
Constructor Detail

PropertyExpander

public PropertyExpander()
Create property expander with EXCEPT_ON_UNDEFINED policy for undefined propertys.


PropertyExpander

public PropertyExpander(int onUndefined)
Create property expander with specified policy for undefined propertys.

Parameters:
onUndefined - the flag indicating behaviour when undefined property is encountered. Must be one of the *_UNDEFINED constants.
Method Detail

expandValues

public Properties expandValues(Properties input,
                               Map data)
                        throws Exception
Expand all propertys in the input Properties object.

Parameters:
input - the Properties object to resolve
data - the data that holds property values
Throws:
Exception - if an error occurs

expandValues

public void expandValues(org.w3c.dom.Element input,
                         Map data)
                  throws Exception
Expand all propertys in the input XML attributes and text contents.

Parameters:
input - the DOM element to resolve
data - the data that holds property values
Throws:
Exception - if an error occurs

expandValues

public String expandValues(String input,
                           Map data)
                    throws Exception
Expand all propertys in input string.

Parameters:
input - the string to resolve
data - the data that holds property values
Returns:
the resolved string
Throws:
Exception - if an error occurs


Copyright © 2003 Codehaus. All Rights Reserved.