下面列出了怎么用org.apache.commons.lang.text.StrLookup的API类实例代码及写法,或者点击链接到github查看源代码。
public static String replaceParams(String stepCall, Map<String, Object> context) {
stepCall = convertPrameter(stepCall);
//don't resolve quoted parameters.
stepCall = stepCall.replace("\"${", "\"<%{").replace("'${", "'<%{");
//qaf#321
StrLookup lookup = new StrLookup() {
public String lookup(String var) {
Object prop = context.get(var);
if(prop==null) {
prop = getBundle().getSubstitutor().getVariableResolver().lookup(var);
}
return (prop != null) ? JSONUtil.toString(prop) : null;
}
};
StrSubstitutor interpol = new StrSubstitutor(lookup);
stepCall = interpol.replace(stepCall);
stepCall = stepCall.replace( "\"<%{","\"${").replace( "'<%{","'${");
return stepCall;
}
@Override
protected StrLookup fetchLookupForPrefix(String prefix) {
return errorLookup;
}
@Override
protected StrLookup fetchNoPrefixLookup() {
return errorLookup;
}