Replace properties of the form:
${<[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.
Example1:
String toReplace = "userLang=${user.language};user=${env.USER}";
String result = "userLang=en;user=santa";
Example2:
String toReplace = "userLang=${IDoneExist,user.language};user=${ImNotThereEither,env.USER}";
String result = "userLang=en;user=santa";
Example3:
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.
- Parameters:
value - - string containig system or env variable reference(s)
- Returns:
- the value of the system property or environment variable referenced if it exists
- Throws:
IllegalStateException - - thrown when state of properties does not allow to replace all variable references.