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").
100 final char[] chars =
string.toCharArray();
101 StringBuilder buffer =
new StringBuilder();
102 boolean properties =
false;
105 for (
int i = 0; i < chars.length; ++i)
116 buffer.append(
string.substring(start, i - 1));
131 buffer.append(
"${}");
137 String key =
string.substring(start + 2, i);
152 value = props.getProperty(key);
154 value = System.getProperty(key);
159 int colon = key.indexOf(
':');
162 String realKey = key.substring(0, colon);
164 value = props.getProperty(realKey);
166 value = System.getProperty(realKey);
175 value = key.substring(colon+1);
189 buffer.append(value);
209 if (start != chars.length)
210 buffer.append(
string.substring(start, chars.length));
213 return buffer.toString();
static final String FILE_SEPARATOR
Definition: StringPropertyReplacer.java:38
static final String PATH_SEPARATOR
Definition: StringPropertyReplacer.java:41
static final String PATH_SEPARATOR_ALIAS
Definition: StringPropertyReplacer.java:47
static String resolveCompositeKey(String key, Properties props)
Definition: StringPropertyReplacer.java:227
static final int IN_BRACKET
Definition: StringPropertyReplacer.java:52
static final int NORMAL
Definition: StringPropertyReplacer.java:50
static final String FILE_SEPARATOR_ALIAS
Definition: StringPropertyReplacer.java:44
static final int SEEN_DOLLAR
Definition: StringPropertyReplacer.java:51