de.lessvoid.xml.tools.SpecialValuesReplace Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nifty Show documentation
Show all versions of nifty Show documentation
Nifty GUI is a Java Library that supports the building of interactive user interfaces for games or similar applications. It utilizes OpenGL for rendering and it can be easily integrated into many rendering systems. The configuration of the GUI is stored in xml files with little supporting Java code. In short Nifty helps you to layout stuff, display it in a cool way and interact with it :)
The newest version!
package de.lessvoid.xml.tools;
import java.text.MessageFormat;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* @author Marc Pompl
* @author void (added some additional features)
* @created 12.06.2010
*/
public class SpecialValuesReplace {
private static final String KEY_PROP = "PROP.";
private static final String KEY_ENV = "ENV.";
private static final String KEY_CALL = "CALL.";
private static final Logger log = Logger.getLogger(SpecialValuesReplace.class.getName());
/**
* 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:
*
* - {@code ${ENV.myEnv}} checks and returns if {@code myEnv} exists in
* {@link System.getEnv()}.
*
* - {@code ${PROP.myProp}} checks and returns if myProp
exists in
* the given properties. If properties is {@code null}, {@link System.getProperties()}
* is checked instead.{@code ${CALL.myMethod()}} calls the method {@code myMethod()} on the
* given {@code object} if it's not {@code null}
*
*
*