org.apache.commons.lang.text.StrLookup Java Examples

The following examples show how to use org.apache.commons.lang.text.StrLookup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BDDDefinitionHelper.java    From qaf with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: Resources.java    From es6draft with MIT License 4 votes vote down vote up
@Override
protected StrLookup fetchLookupForPrefix(String prefix) {
    return errorLookup;
}
 
Example #3
Source File: Resources.java    From es6draft with MIT License 4 votes vote down vote up
@Override
protected StrLookup fetchNoPrefixLookup() {
    return errorLookup;
}