use of io.atlasmap.expression.parser.Parser in project atlasmap by atlasmap.
the class Expression method parse.
/**
* Parses the expression text.
* @param expessionText expression text
* @param functionResolver function resolver
* @return result
* @throws ExpressionException unexpected error
*/
static Expression parse(String expessionText, FunctionResolver functionResolver) throws ExpressionException {
if (functionResolver == null) {
functionResolver = (name, args) -> {
throw new ParseException("Function not found: " + name);
};
}
Object result = CACHE.get(expessionText);
if (result instanceof ExpressionException) {
throw (ExpressionException) result;
} else if (result instanceof Expression) {
return (Expression) result;
} else {
String actual = expessionText;
try {
Parser parser = new Parser(new StringReader(actual));
parser.functionResolver = functionResolver;
Expression e = parser.parse();
CACHE.put(expessionText, e);
return e;
} catch (Throwable e) {
ExpressionException fe = new ExpressionException(actual, e);
CACHE.put(expessionText, fe);
throw fe;
}
}
}
Aggregations