Top Description Inners Fields Constructors Methods
org.springframework.util

public abstract Class SystemPropertyUtils

extends Object
Class Inheritance
Imports
org.springframework.lang.Nullable

Helper class for resolving placeholders in texts. Usually applied to file paths.

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.

Authors
Juergen Hoeller, Rob Harrop, Dave Syer
Since
1.2.5
See Also
PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, System#getProperty(String)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SystemPropertyUtils.SystemPropertyPlaceholderResolver

PlaceholderResolver implementation that resolves against system properties and system environment variables.

Field Summary

Modifier and TypeField and Description
private static final PropertyPlaceholderHelper
public static final String
PLACEHOLDER_PREFIX

Prefix for system property placeholders: ${.

public static final String
PLACEHOLDER_SUFFIX

Suffix for system property placeholders: }.

private static final PropertyPlaceholderHelper
public static final String
VALUE_SEPARATOR

Value separator for system property placeholders: :.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the resolved String
resolvePlaceholders
(String
the String to resolve
text
)

Resolve ${...} placeholders in the given text, replacing them with corresponding system property values.

public static String

Returns:

the resolved String
resolvePlaceholders
(String
the String to resolve
text
,
boolean
whether unresolved placeholders are to be ignored
ignoreUnresolvablePlaceholders
)

Resolve ${...} placeholders in the given text, replacing them with corresponding system property values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nonStrictHelperback to summary
private static final PropertyPlaceholderHelper nonStrictHelper
PLACEHOLDER_PREFIXback to summary
public static final String PLACEHOLDER_PREFIX

Prefix for system property placeholders: ${.

PLACEHOLDER_SUFFIXback to summary
public static final String PLACEHOLDER_SUFFIX

Suffix for system property placeholders: }.

strictHelperback to summary
private static final PropertyPlaceholderHelper strictHelper
VALUE_SEPARATORback to summary
public static final String VALUE_SEPARATOR

Value separator for system property placeholders: :.

Constructor Detail

SystemPropertyUtilsback to summary
public SystemPropertyUtils()

Method Detail

resolvePlaceholdersback to summary
public static String resolvePlaceholders(String text)

Resolve ${...} placeholders in the given text, replacing them with corresponding system property values.

Parameters
text:String

the String to resolve

Returns:String

the resolved String

Exceptions
IllegalArgumentException:
if there is an unresolvable placeholder
See Also
PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX
resolvePlaceholdersback to summary
public static String resolvePlaceholders(String text, boolean ignoreUnresolvablePlaceholders)

Resolve ${...} 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.

Parameters
text:String

the String to resolve

ignoreUnresolvablePlaceholders:boolean

whether unresolved placeholders are to be ignored

Returns:String

the resolved String

Exceptions
IllegalArgumentException:
if there is an unresolvable placeholder
See Also
PLACEHOLDER_PREFIX, and the "ignoreUnresolvablePlaceholders" flag is false
org.springframework.util back to summary

private Class SystemPropertyUtils.SystemPropertyPlaceholderResolver

extends Object
implements PlaceholderResolver
Class Inheritance
  • java.lang.Object
  • org.springframework.util.SystemPropertyUtils.SystemPropertyPlaceholderResolver
All Implemented Interfaces
org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver

PlaceholderResolver implementation that resolves against system properties and system environment variables.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
resolvePlaceholder(String
the name of the placeholder to resolve
placeholderName
)

Implements org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver.resolvePlaceholder.

Resolve the supplied placeholder name to the replacement value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

textback to summary
private final String text

Constructor Detail

SystemPropertyPlaceholderResolverback to summary
public SystemPropertyPlaceholderResolver(String text)

Method Detail

resolvePlaceholderback to summary
public String resolvePlaceholder(String placeholderName)

Implements org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver.resolvePlaceholder.

Doc from org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver.resolvePlaceholder.

Resolve the supplied placeholder name to the replacement value.

Parameters
placeholderName:String

the name of the placeholder to resolve

Returns:String

the replacement value, or null if no replacement is to be made

Annotations
@Override
@Nullable