public class PropertiesValueResolver extends Object
| Constructor and Description |
|---|
PropertiesValueResolver() |
| Modifier and Type | Method and Description |
|---|---|
static String |
replaceProperties(String value)
Replace properties of the form:
${<[env.]name>[,<[env.]name2>[,<[env.]name3>...]][:<default>]}
Method inspects given string and replaces all encountered properties. |
public static String replaceProperties(String value) throws IllegalStateException
${<[env.]name>[,<[env.]name2>[,<[env.]name3>...]][:<default>]}
Method inspects given string and replaces all encountered properties. If method is able to replace all properties, it
returns String with replaced values. If it fails to replace property and ${} does not contain default declaration, method throws IllegalStateException.
String toReplace = "userLang=${user.language};user=${env.USER}";
String result = "userLang=en;user=santa";
String toReplace = "userLang=${IDoneExist,user.language};user=${ImNotThereEither,env.USER}";
String result = "userLang=en;user=santa";
String toReplace = "userLang=${IDoneExist:user.language};user=${ImNotThereEither,env.USER:defaultWontBeUsed}";
String result = "userLang=user.language;user=santa";
NOTE: in Example 3 value of userLang in result String. The default value IS NOT RESOLVED. It is used as fallback value.value - - string containig system or env variable reference(s)IllegalStateException - - thrown when state of properties does not allow to replace all variable references.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.