de.lessvoid.xml.tools
Class SpecialValuesReplace

java.lang.Object
  extended by de.lessvoid.xml.tools.SpecialValuesReplace

public class SpecialValuesReplace
extends Object

Author:
Marc Pompl, void (added some additional features)

Constructor Summary
SpecialValuesReplace()
           
 
Method Summary
static String replace(String input, Map<String,ResourceBundle> resourceBundles, Object methodCallTarget, Properties properties)
          Tries to replace values surrounded by "${...}".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpecialValuesReplace

public SpecialValuesReplace()
Method Detail

replace

public static String replace(String input,
                             Map<String,ResourceBundle> resourceBundles,
                             Object methodCallTarget,
                             Properties properties)
Tries to replace values surrounded by "${...}". All pieces of the input that are not part of a "${...}" expression are returned unmodified. Replacement is executed for all "${...}" values contained in the input. Yes, this means there is support for multiple "${...}" expressions in input! :)

Example inputs:
  • ${resourceBundleId.key} tries to find the ResourceBundle with the given id on the given list of ResourceBundles. And then calls resourceBundle.get(key) to translate the value.
  • Parameters:
    input - (may be null)
    resourceBundles - Map of pre loaded ResourceBundles with a String id
    methodCallTarget - if the input contains ${CALL...} the target object to call the method with
    properties - if the input contains ${PROP...} the properties to use (may be null in this case System.getProperties() are used)
    Returns:
    the parsed input


    Copyright © 2012. All Rights Reserved.