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.
PLACEHOLDER_PREFIX
,
PLACEHOLDER_SUFFIX
,
System.getProperty(String)
Modifier and Type | Class and Description |
---|---|
private static class |
SystemPropertyUtils.SystemPropertyPlaceholderResolver
PlaceholderResolver implementation that resolves against system properties
and system environment variables.
|
Modifier and Type | Field and Description |
---|---|
private static PropertyPlaceholderHelper |
nonStrictHelper |
static java.lang.String |
PLACEHOLDER_PREFIX
Prefix for system property placeholders: "${"
|
static java.lang.String |
PLACEHOLDER_SUFFIX
Suffix for system property placeholders: "}"
|
private static PropertyPlaceholderHelper |
strictHelper |
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 |
resolvePlaceholders(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,
boolean ignoreUnresolvablePlaceholders)
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
private static final PropertyPlaceholderHelper strictHelper
private static final PropertyPlaceholderHelper nonStrictHelper
public static java.lang.String resolvePlaceholders(java.lang.String text)
${...}
placeholders in the given text, replacing them with
corresponding system property values.text
- the String to resolvejava.lang.IllegalArgumentException
- if there is an unresolvable placeholderPLACEHOLDER_PREFIX
,
PLACEHOLDER_SUFFIX
public static java.lang.String resolvePlaceholders(java.lang.String text, boolean ignoreUnresolvablePlaceholders)
${...}
placeholders in the given text, replacing them with
corresponding system property values. Unresolvable placeholders with no default
value are ignored and passed through unchanged if the flag is set to true
.text
- the String to resolveignoreUnresolvablePlaceholders
- whether unresolved placeholders are to be ignoredjava.lang.IllegalArgumentException
- if there is an unresolvable placeholder
and the "ignoreUnresolvablePlaceholders" flag is false
PLACEHOLDER_PREFIX
,
PLACEHOLDER_SUFFIX