Top Description Inners Fields Constructors Methods
org.keycloak.common.util

public final Class StringPropertyReplacer

extends Object
Class Inheritance
Imports
java.io.File, java.util.Properties

A utility class for replacing properties in strings.
Authors
Jason Dillon, Scott Stark, Claudio Vesco, Adrian Brock, Dimitris Andreadis
Version
$Revision: 2898 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private static final String
FILE_SEPARATOR

File separator value

private static final String
FILE_SEPARATOR_ALIAS

File separator alias

private static final int
public static final String
NEWLINE

New line string constant

private static final int
private static final String
PATH_SEPARATOR

Path separator value

private static final String
PATH_SEPARATOR_ALIAS

Path separator alias

private static final int
private static final Properties

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the input string with all property references replaced if any. If there are no valid references the input string will be returned.
replaceProperties
(final String
- the string with possible ${} references
string
)

Go through the input string and replace any occurance of ${p} with the System.getProperty(p) value.

public static String

Returns:

the input string with all property references replaced if any. If there are no valid references the input string will be returned.
replaceProperties
(final String
- the string with possible ${} references
string
,
final Properties
- the source for ${x} property ref values, null means use System.getProperty()
props
)

Go through the input string and replace any occurance of ${p} with the props.getProperty(p) value.

public static String
private static String

Returns:

the resolved key or null
resolveCompositeKey
(String
the key to resolve
key
,
final Properties
the properties to use
props
)

Try to resolve a "key" from the provided properties by checking if it is actually a "key1,key2", in which case try first "key1", then "key2".

private static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FILE_SEPARATORback to summary
private static final String FILE_SEPARATOR

File separator value

FILE_SEPARATOR_ALIASback to summary
private static final String FILE_SEPARATOR_ALIAS

File separator alias

IN_BRACKETback to summary
private static final int IN_BRACKET
NEWLINEback to summary
public static final String NEWLINE

New line string constant

NORMALback to summary
private static final int NORMAL
PATH_SEPARATORback to summary
private static final String PATH_SEPARATOR

Path separator value

PATH_SEPARATOR_ALIASback to summary
private static final String PATH_SEPARATOR_ALIAS

Path separator alias

SEEN_DOLLARback to summary
private static final int SEEN_DOLLAR
systemEnvPropertiesback to summary
private static final Properties systemEnvProperties

Constructor Detail

StringPropertyReplacerback to summary
public StringPropertyReplacer()

Method Detail

replacePropertiesback to summary
public static String replaceProperties(final String string)

Go through the input string and replace any occurance of ${p} with the System.getProperty(p) value. If there is no such property p defined, then the ${p} reference will remain unchanged. If the property reference is of the form ${p:v} and there is no such property p, then the default value v will be returned. If the property reference is of the form ${p1,p2} or ${p1,p2:v} then the primary and the secondary properties will be tried in turn, before returning either the unchanged input, or the default value. The property ${/} is replaced with System.getProperty("file.separator") value and the property ${:} is replaced with System.getProperty("path.separator").

Parameters
string:String

- the string with possible ${} references

Returns:String

the input string with all property references replaced if any. If there are no valid references the input string will be returned.

replacePropertiesback to summary
public static String replaceProperties(final String string, final Properties props)

Go through the input string and replace any occurance of ${p} with the props.getProperty(p) value. If there is no such property p defined, then the ${p} reference will remain unchanged. If the property reference is of the form ${p:v} and there is no such property p, then the default value v will be returned. If the property reference is of the form ${p1,p2} or ${p1,p2:v} then the primary and the secondary properties will be tried in turn, before returning either the unchanged input, or the default value. The property ${/} is replaced with System.getProperty("file.separator") value and the property ${:} is replaced with System.getProperty("path.separator").

Parameters
string:String

- the string with possible ${} references

props:Properties

- the source for ${x} property ref values, null means use System.getProperty()

Returns:String

the input string with all property references replaced if any. If there are no valid references the input string will be returned.

replacePropertiesback to summary
public static String replaceProperties(final String string, StringPropertyReplacer.PropertyResolver resolver)
resolveCompositeKeyback to summary
private static String resolveCompositeKey(String key, final Properties props)

Try to resolve a "key" from the provided properties by checking if it is actually a "key1,key2", in which case try first "key1", then "key2". If all fails, return null. It also accepts "key1," and ",key2".

Parameters
key:String

the key to resolve

props:Properties

the properties to use

Returns:String

the resolved key or null

resolveCompositeKeyback to summary
private static String resolveCompositeKey(String key, StringPropertyReplacer.PropertyResolver resolver)
org.keycloak.common.util back to summary

public Interface StringPropertyReplacer.PropertyResolver


Method Summary

Modifier and TypeMethod and Description
public String
resolve(String property)

Method Detail

resolveback to summary
public String resolve(String property)