org.apache.el.lang.EvaluationContext Java Examples
The following examples show how to use
org.apache.el.lang.EvaluationContext.
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: AstIdentifier.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getValue(ctx.getELContext()); } } ctx.setPropertyResolved(false); Object result = ctx.getELResolver().getValue(ctx, null, this.image); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled.null", this.image)); } return result; }
Example #2
Source File: AstValue.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void setValue(EvaluationContext ctx, Object value) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); ELResolver resolver = ctx.getELResolver(); // coerce to the expected type Class<?> targetClass = resolver.getType(ctx, t.base, t.property); if (COERCE_TO_ZERO == true || !isAssignable(value, targetClass)) { resolver.setValue(ctx, t.base, t.property, ELSupport.coerceToType(value, targetClass)); } else { resolver.setValue(ctx, t.base, t.property, value); } if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled", t.base, t.property)); } }
Example #3
Source File: AstFunction.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { FunctionMapper fnMapper = ctx.getFunctionMapper(); // quickly validate again for this request if (fnMapper == null) { throw new ELException(MessageFactory.get("error.fnMapper.null")); } Method m = fnMapper.resolveFunction(this.prefix, this.localName); if (m == null) { throw new ELException(MessageFactory.get("error.fnMapper.method", this.getOutputName())); } return m.getReturnType(); }
Example #4
Source File: AstFunction.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { FunctionMapper fnMapper = ctx.getFunctionMapper(); // quickly validate again for this request if (fnMapper == null) { throw new ELException(MessageFactory.get("error.fnMapper.null")); } Method m = fnMapper.resolveFunction(this.prefix, this.localName); if (m == null) { throw new ELException(MessageFactory.get("error.fnMapper.method", this.getOutputName())); } return m.getReturnType(); }
Example #5
Source File: AstIdentifier.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public void setValue(EvaluationContext ctx, Object value) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { expr.setValue(ctx.getELContext(), value); return; } } ctx.setPropertyResolved(false); ctx.getELResolver().setValue(ctx, null, this.image, value); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled.null", this.image)); } }
Example #6
Source File: AstEmpty.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); if (obj == null) { return Boolean.TRUE; } else if (obj instanceof String) { return Boolean.valueOf(((String) obj).length() == 0); } else if (obj instanceof Object[]) { return Boolean.valueOf(((Object[]) obj).length == 0); } else if (obj instanceof Collection<?>) { return Boolean.valueOf(((Collection<?>) obj).isEmpty()); } else if (obj instanceof Map<?,?>) { return Boolean.valueOf(((Map<?,?>) obj).isEmpty()); } return Boolean.FALSE; }
Example #7
Source File: AstValue.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public boolean isReadOnly(EvaluationContext ctx) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); boolean result = ctx.getELResolver().isReadOnly(ctx, t.base, t.property); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled", t.base, t.property)); } return result; }
Example #8
Source File: AstValue.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * @since EL 2.2 */ @Override public ValueReference getValueReference(EvaluationContext ctx) { // Check this is a reference to a base and a property if (this.children.length > 2 && this.jjtGetChild(2) instanceof AstMethodParameters) { // This is a method call return null; } Target t = getTarget(ctx); return new ValueReference(t.base, t.property); }
Example #9
Source File: ValueExpressionImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * @since EL 2.2 */ @Override public ValueReference getValueReference(ELContext context) { EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); return this.getNode().getValueReference(ctx); }
Example #10
Source File: AstMethodParameters.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public Class<?>[] getParameterTypes(EvaluationContext ctx) { ArrayList<Class<?>> paramTypes = new ArrayList<Class<?>>(); for (int i = 0; i < this.jjtGetNumChildren(); i++) { paramTypes.add(this.jjtGetChild(i).getType(ctx)); } return paramTypes.toArray(new Class<?>[paramTypes.size()]); }
Example #11
Source File: AstValue.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override // Interface el.parser.Node uses raw types (and is auto-generated) public MethodInfo getMethodInfo(EvaluationContext ctx, @SuppressWarnings("rawtypes") Class[] paramTypes) throws ELException { Target t = getTarget(ctx); Method m = ReflectionUtil.getMethod( t.base, t.property, paramTypes, null); return new MethodInfo(m.getName(), m.getReturnType(), m .getParameterTypes()); }
Example #12
Source File: AstValue.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public boolean isReadOnly(EvaluationContext ctx) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); boolean result = ctx.getELResolver().isReadOnly(ctx, t.base, t.property); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled", t.base, t.property)); } return result; }
Example #13
Source File: ReflectionUtil.java From Tomcat8-Source-Read with MIT License | 5 votes |
private static boolean isCoercibleFrom(EvaluationContext ctx, Object src, Class<?> target) { // TODO: This isn't pretty but it works. Significant refactoring would // be required to avoid the exception. try { ELSupport.coerceToType(ctx, src, target); } catch (ELException e) { return false; } return true; }
Example #14
Source File: AstMult.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.multiply(obj0, obj1); }
Example #15
Source File: AstGreaterThan.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); if (obj0 == null) { return Boolean.FALSE; } Object obj1 = this.children[1].getValue(ctx); if (obj1 == null) { return Boolean.FALSE; } return (compare(ctx, obj0, obj1) > 0) ? Boolean.TRUE : Boolean.FALSE; }
Example #16
Source File: ValueExpressionImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public Class<?> getType(ELContext context) throws PropertyNotFoundException, ELException { EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); return this.getNode().getType(ctx); }
Example #17
Source File: AstAssign.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { Object value = children[1].getValue(ctx); children[0].setValue(ctx, value); return children[1].getType(ctx); }
Example #18
Source File: AstSemicolon.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { // Evaluate and throw away children[0].getValue(ctx); return children[1].getValue(ctx); }
Example #19
Source File: AstValue.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); Class<?> result = ctx.getELResolver().getType(ctx, t.base, t.property); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled", t.base, t.property)); } return result; }
Example #20
Source File: AstNot.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); Boolean b = coerceToBoolean(obj); return Boolean.valueOf(!b.booleanValue()); }
Example #21
Source File: AstNotEqual.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return Boolean.valueOf(!equals(obj0, obj1)); }
Example #22
Source File: AstChoice.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Boolean b0 = coerceToBoolean(obj0); return this.children[((b0.booleanValue() ? 1 : 2))].getValue(ctx); }
Example #23
Source File: AstAnd.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj = children[0].getValue(ctx); Boolean b = coerceToBoolean(ctx, obj, true); if (!b.booleanValue()) { return b; } obj = children[1].getValue(ctx); b = coerceToBoolean(ctx, obj, true); return b; }
Example #24
Source File: AstEqual.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return Boolean.valueOf(equals(obj0, obj1)); }
Example #25
Source File: AstMod.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.mod(obj0, obj1); }
Example #26
Source File: AstNotEqual.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return Boolean.valueOf(!equals(obj0, obj1)); }
Example #27
Source File: AstDiv.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.divide(obj0, obj1); }
Example #28
Source File: AstLessThan.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); if (obj0 == null) { return Boolean.FALSE; } Object obj1 = this.children[1].getValue(ctx); if (obj1 == null) { return Boolean.FALSE; } return (compare(obj0, obj1) < 0) ? Boolean.TRUE : Boolean.FALSE; }
Example #29
Source File: AstAnd.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj = children[0].getValue(ctx); Boolean b = coerceToBoolean(obj); if (!b.booleanValue()) { return b; } obj = children[1].getValue(ctx); b = coerceToBoolean(obj); return b; }
Example #30
Source File: AstLessThan.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); if (obj0 == null) { return Boolean.FALSE; } Object obj1 = this.children[1].getValue(ctx); if (obj1 == null) { return Boolean.FALSE; } return (compare(obj0, obj1) < 0) ? Boolean.TRUE : Boolean.FALSE; }