public ExValue(String val) { int j; if ((j = val.indexOf("${")) >= 0 && val.indexOf('}', j + 2) >= 0) { try { _expr = _expf.parseExpression(_xelc, val, String.class); return; } catch (Throwable ex) { log.error("Illegal expression: "+val, ex); } } _expr = null; _val = val; } public String getValue() {
/** Evaluates an expression. * * @param ctx the context information to evaluate the expression * It can be null, in which case no functions are supported for this * invocation. * @param expression the expression to be evaluated. * Note: the expression is enclosed * with ${ and }, regardless of what implementation is used. * @param expectedType the expected type of the result of the evaluation */ public static final Object evaluate(XelContext ctx, String expression, Class<?> expectedType) throws XelException { return newExpressionFactory().evaluate(ctx, expression, expectedType); }
XelNode(String expr, ParseContext ctx) throws XelException { _expr = ctx.getExpressionFactory().parseExpression(ctx, expr, String.class); }
/** Adds an attribute. */ void addAttribute(String nm, String val, ParseContext ctx) throws NoSuchMethodException, ClassCastException, XelException { if (nm == null || val == null) throw new IllegalArgumentException("null"); if (_attrs == null) _attrs = new LinkedList<Attr>(); final Method mtd = (Method) Classes.getAccessibleObject(_cls, nm, new Class[] { null }, Classes.B_SET | Classes.B_PUBLIC_ONLY | Classes.B_METHOD_ONLY); final Class type = mtd.getParameterTypes()[0]; if (val.indexOf("${") >= 0) { _attrs.add(new Attr(mtd, ctx.getExpressionFactory().parseExpression(ctx, val, type))); } else { _attrs.add(new Attr(mtd, Classes.coerce(type, val))); } }
public Expression parseExpression(String expression, Class expectedType) throws XelException { return getExpressionFactory().parseExpression(newXelContext(null), expression, expectedType); }
public ExpressionX parseExpressionX(BindContext ctx, String expression, Class<?> expectedType) throws XelException { Component comp = null; if (ctx != null) { comp = ctx.getComponent(); if (comp == null) { final Binding binding = ctx.getBinding(); if (binding != null) { comp = binding.getComponent(); } } } try { return (ExpressionX) getExpressionFactory().parseExpression(newXelContext(ctx, comp), "${" + expression + "}", expectedType); } catch (Exception x) { throw MiscUtil.mergeExceptionInfo(x, comp); } }