nl.hippo.portal.util
Class PropertiesReplacer

java.lang.Object
  extended by nl.hippo.portal.util.PropertiesReplacer

public class PropertiesReplacer
extends java.lang.Object

Utility class which can replace embedded ${<propertyname>} type properties in files or strings.

Version:
$Id: PropertiesReplacer.java 6122 2007-04-18 14:34:48Z pduin $
Author:
adouma

Constructor Summary
PropertiesReplacer()
           
 
Method Summary
static java.lang.String replaceProperties(java.io.InputStream in, java.util.Map properties)
          Replace embedded ${<propertyname>} type properties with a provided map of propertyname/value objects.
static java.lang.String replaceProperties(java.io.Reader in, java.util.Map properties)
          Replace embedded ${<propertyname>} type properties with a provided map of propertyname/value objects.
static java.lang.String replaceProperties(java.lang.String in, java.util.Map properties)
          Replace embedded ${<propertyname>} type properties with a provided map of propertyname/value objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesReplacer

public PropertiesReplacer()
Method Detail

replaceProperties

public static java.lang.String replaceProperties(java.io.InputStream in,
                                                 java.util.Map properties)
                                          throws java.io.IOException
Replace embedded ${<propertyname>} type properties with a provided map of propertyname/value objects.
Delagates to replaceProperties(Reader, Map) using an InputStreamReader wrapping the InputStream input parameter.

Parameters:
in - the InputStream input
properties - map containing the property/value objects
Returns:
String containing replaced properties.
Throws:
java.io.IOException

replaceProperties

public static java.lang.String replaceProperties(java.lang.String in,
                                                 java.util.Map properties)
                                          throws java.io.IOException
Replace embedded ${<propertyname>} type properties with a provided map of propertyname/value objects.
Delagates to replaceProperties(Reader, Map) using an StringReader wrapping the String input parameter.

Parameters:
in - the String input
properties - map containing the property/value objects
Returns:
String containing replaced properties.
Throws:
java.io.IOException

replaceProperties

public static java.lang.String replaceProperties(java.io.Reader in,
                                                 java.util.Map properties)
                                          throws java.io.IOException
Replace embedded ${<propertyname>} type properties with a provided map of propertyname/value objects.
The property value is written out using the Object.toString() method.

Parameters:
in - the Reader input
properties - map containing the property/value objects
Returns:
String containing replaced properties.
Throws:
java.io.IOException


Copyright © 2007-2008 . All Rights Reserved.