in src/main/java/org/apache/sling/provisioning/model/ModelResolveUtility.java [50:82]
public static String replace(final Feature feature, final String v, final VariableResolver resolver) {
if ( v == null ) {
return null;
}
String msg = v;
// check for variables
int pos = -1;
int start = 0;
while ( ( pos = msg.indexOf('$', start) ) != -1 ) {
boolean escapedVariable = (pos > 0 && msg.charAt(pos - 1) == '\\');
if ( msg.length() > pos && msg.charAt(pos + 1) == '{' && (pos == 0 || msg.charAt(pos - 1) != '$') ) {
final int endPos = msg.indexOf('}', pos);
if ( endPos != -1 ) {
final String name = msg.substring(pos + 2, endPos);
final String value;
if (escapedVariable) {
value = "\\${" + name + "}";
} else if ( resolver != null ) {
value = resolver.resolve(feature, name);
} else {
value = feature.getVariables().get(name);
}
if ( value == null ) {
throw new IllegalArgumentException("Unknown variable: " + name);
}
int startPos = escapedVariable ? pos - 1 : pos;
msg = msg.substring(0, startPos) + value + msg.substring(endPos + 1);
}
}
start = pos + 1;
}
return msg;
}