I'd like to use EL in my application. But I can't find any howto. I usually end up needing some interface for which I don't have an implementation.
I have a map of objects, and I want a string expression like Hello, ${person.name}
to be evaluated to a string.
How can I achieve that, using any of Commons EL, javax.el, OGNL, or such? Must be a standalone library.
And I know Java: using EL outside J2EE, and have seen JSTL/JSP EL (Expression Language) in a non JSP (standalone) context. That is not what I'm looking for.
What I am looking for is an example of what dependency to add, and then how to initialize a parser which will have:
private static String evaluateEL( String expr, Map<String, String> properties );
and allow me to do:
String greet = evaluateEL("Hello ${person.name}",
new HashMap(){{
put("person", new Person("Ondra"));
}}
);
And I need it to use some rational value, e.g. ""
on null
instead of throwing NPE or so.