public abstract class SystemPropertyUtils
extends java.lang.Object
A text may contain $ ... placeholders, to be resolved as system properties:
e.g. $ user.dir. Default values can be supplied using the ":" separator between
key and value.
Adapted from Spring.
System.getProperty(String)| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PLACEHOLDER_PREFIX
Prefix for system property placeholders: "${".
|
static java.lang.String |
PLACEHOLDER_SUFFIX
Suffix for system property placeholders: "}".
|
static java.lang.String |
VALUE_SEPARATOR
Value separator for system property placeholders: ":".
|
| Constructor and Description |
|---|
SystemPropertyUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getProperty(java.lang.String key) |
static java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue) |
static java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue,
java.lang.String text)
Search the System properties and environment variables for a value with the
provided key.
|
static java.lang.String |
resolvePlaceholders(java.util.Properties properties,
java.lang.String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
system property values.
|
static java.lang.String |
resolvePlaceholders(java.lang.String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
system property values.
|
public static final java.lang.String PLACEHOLDER_PREFIX
public static final java.lang.String PLACEHOLDER_SUFFIX
public static final java.lang.String VALUE_SEPARATOR
public static java.lang.String resolvePlaceholders(java.lang.String text)
text - the String to resolvejava.lang.IllegalArgumentException - if there is an unresolvable placeholderPLACEHOLDER_PREFIX,
PLACEHOLDER_SUFFIXpublic static java.lang.String resolvePlaceholders(java.util.Properties properties,
java.lang.String text)
properties - a properties instance to use in addition to Systemtext - the String to resolvejava.lang.IllegalArgumentException - if there is an unresolvable placeholderPLACEHOLDER_PREFIX,
PLACEHOLDER_SUFFIXpublic static java.lang.String getProperty(java.lang.String key)
public static java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue)
public static java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue,
java.lang.String text)
UPPER_CASE style are allowed where
System properties would normally be lower.case.key - the key to resolvedefaultValue - the default valuetext - optional extra context for an error message if the key resolution fails
(e.g. if System properties are not accessible)