use of org.apache.commons.jxpath.FunctionLibrary in project collect by openforis.
the class ExpressionFactory method registerFunctions.
private void registerFunctions(CustomFunctions... functionsLibrary) {
jxPathContext = (ModelJXPathContext) JXPathContext.newContext(null);
FunctionLibrary library = new FunctionLibrary();
for (CustomFunctions functions : functionsLibrary) {
library.addFunctions(functions);
String namespace = functions.getNamespace();
if (customFunctionsByNamespace.containsKey(namespace)) {
throw new IllegalStateException(String.format("Functions for namespace %s already registered", namespace));
}
customFunctionsByNamespace.put(namespace, functions);
}
jxPathContext.setFunctions(library);
}
use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.
the class SpecWithArrayType method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
FunctionLibrary library = new FunctionLibrary();
IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
evaluator.addScriptFunction(new ScriptClassFunction("convertArray", "function convertArray(arrayValue) { return String.fromCharCode(arrayValue[0])}"));
library.addFunctions(evaluator.getFunctions());
return library;
}
use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.
the class SpecBinaryConverter method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
FunctionLibrary library = new FunctionLibrary();
IScriptEvaluator evaluator = evalProvider.createEvaluator("custom");
evaluator.addScriptFunction(new ScriptClassFunction("convert", "function convert(value) { return value*0.01; }"));
library.addFunctions(evaluator.getFunctions());
return library;
}
use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.
the class SpecWithConfigMapping method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
FunctionLibrary library = new FunctionLibrary();
IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
evaluator.addScriptFunction(new ScriptClassFunction("convertClickType", "function convertClickType(clickType) {if (clickType === 'SINGLE') return 1; else if (clickType === 'DOUBLE') return 2; else return 99;}"));
library.addFunctions(evaluator.getFunctions());
return library;
}
use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.
the class SpecWithCustomFunction method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
FunctionLibrary library = new FunctionLibrary();
IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
evaluator.addScriptFunction(new ScriptClassFunction("convertClickType", "function convertClickType(clickType) {if (clickType === 'SINGLE') return 1; else if (clickType === 'DOUBLE') return 2; else return 99;}"));
library.addFunctions(evaluator.getFunctions());
return library;
}
Aggregations