Package org.wildfly.security.jose.util
Class StringPropertyReplacer
- java.lang.Object
-
- org.wildfly.security.jose.util.StringPropertyReplacer
-
final class StringPropertyReplacer extends Object
A utility class for replacing properties in strings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StringPropertyReplacer.PropertyResolver
-
Field Summary
Fields Modifier and Type Field Description private static String
FILE_SEPARATOR
File separator valueprivate static String
FILE_SEPARATOR_ALIAS
File separator aliasprivate static int
IN_BRACKET
static String
NEWLINE
New line string constantprivate static int
NORMAL
private static String
PATH_SEPARATOR
Path separator valueprivate static String
PATH_SEPARATOR_ALIAS
Path separator aliasprivate static int
SEEN_DOLLAR
-
Constructor Summary
Constructors Constructor Description StringPropertyReplacer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
replaceProperties(String string)
Go through the input string and replace any occurance of ${p} with the System.getProperty(p) value.static String
replaceProperties(String string, Properties props)
Go through the input string and replace any occurance of ${p} with the props.getProperty(p) value.static String
replaceProperties(String string, StringPropertyReplacer.PropertyResolver resolver)
private static String
resolveCompositeKey(String key, 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".private static String
resolveCompositeKey(String key, StringPropertyReplacer.PropertyResolver resolver)
-
-
-
Field Detail
-
NEWLINE
public static final String NEWLINE
New line string constant
-
FILE_SEPARATOR
private static final String FILE_SEPARATOR
File separator value
-
PATH_SEPARATOR
private static final String PATH_SEPARATOR
Path separator value
-
FILE_SEPARATOR_ALIAS
private static final String FILE_SEPARATOR_ALIAS
File separator alias- See Also:
- Constant Field Values
-
PATH_SEPARATOR_ALIAS
private static final String PATH_SEPARATOR_ALIAS
Path separator alias- See Also:
- Constant Field Values
-
NORMAL
private static final int NORMAL
- See Also:
- Constant Field Values
-
SEEN_DOLLAR
private static final int SEEN_DOLLAR
- See Also:
- Constant Field Values
-
IN_BRACKET
private static final int IN_BRACKET
- See Also:
- Constant Field Values
-
-
Method Detail
-
replaceProperties
public static String replaceProperties(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
- - the string with possible ${} references- Returns:
- the input string with all property references replaced if any. If there are no valid references the input string will be returned.
-
replaceProperties
public static String replaceProperties(String string, 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
- - the string with possible ${} referencesprops
- - the source for ${x} property ref values, null means use System.getProperty()- Returns:
- the input string with all property references replaced if any. If there are no valid references the input string will be returned.
-
replaceProperties
public static String replaceProperties(String string, StringPropertyReplacer.PropertyResolver resolver)
-
resolveCompositeKey
private static String resolveCompositeKey(String key, 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
- the key to resolveprops
- the properties to use- Returns:
- the resolved key or null
-
resolveCompositeKey
private static String resolveCompositeKey(String key, StringPropertyReplacer.PropertyResolver resolver)
-
-