Java Code Examples for org.apache.el.lang.EvaluationContext#setPropertyResolved()
The following examples show how to use
org.apache.el.lang.EvaluationContext#setPropertyResolved() .
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 Tomcat7.0.67 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 2
Source File: AstIdentifier.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public boolean isReadOnly(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.isReadOnly(ctx.getELContext()); } } ctx.setPropertyResolved(false); boolean result = ctx.getELResolver().isReadOnly(ctx, null, this.image); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled.null", this.image)); } return result; }
Example 3
Source File: AstIdentifier.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getType(ctx.getELContext()); } } ctx.setPropertyResolved(false); Class<?> result = ctx.getELResolver().getType(ctx, null, this.image); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled.null", this.image)); } return result; }
Example 4
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 5
Source File: AstIdentifier.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public boolean isReadOnly(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.isReadOnly(ctx.getELContext()); } } ctx.setPropertyResolved(false); boolean result = ctx.getELResolver().isReadOnly(ctx, null, this.image); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled.null", this.image)); } return result; }
Example 6
Source File: AstIdentifier.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getType(ctx.getELContext()); } } ctx.setPropertyResolved(false); Class<?> result = ctx.getELResolver().getType(ctx, null, this.image); if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled.null", this.image)); } return result; }
Example 7
Source File: AstValue.java From tomcatsrc 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 8
Source File: AstValue.java From Tomcat7.0.67 with Apache License 2.0 | 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 9
Source File: AstIdentifier.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private final MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException { Object obj = null; // case A: ValueExpression exists, getValue which must // be a MethodExpression VariableMapper varMapper = ctx.getVariableMapper(); ValueExpression ve = null; if (varMapper != null) { ve = varMapper.resolveVariable(this.image); if (ve != null) { obj = ve.getValue(ctx); } } // case B: evaluate the identity against the ELResolver, again, must be // a MethodExpression to be able to invoke if (ve == null) { ctx.setPropertyResolved(false); obj = ctx.getELResolver().getValue(ctx, null, this.image); } // finally provide helpful hints if (obj instanceof MethodExpression) { return (MethodExpression) obj; } else if (obj == null) { throw new MethodNotFoundException("Identity '" + this.image + "' was null and was unable to invoke"); } else { throw new ELException( "Identity '" + this.image + "' does not reference a MethodExpression instance, returned type: " + obj.getClass().getName()); } }
Example 10
Source File: AstIdentifier.java From tomcatsrc with Apache License 2.0 | 5 votes |
private final MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException { Object obj = null; // case A: ValueExpression exists, getValue which must // be a MethodExpression VariableMapper varMapper = ctx.getVariableMapper(); ValueExpression ve = null; if (varMapper != null) { ve = varMapper.resolveVariable(this.image); if (ve != null) { obj = ve.getValue(ctx); } } // case B: evaluate the identity against the ELResolver, again, must be // a MethodExpression to be able to invoke if (ve == null) { ctx.setPropertyResolved(false); obj = ctx.getELResolver().getValue(ctx, null, this.image); } // finally provide helpful hints if (obj instanceof MethodExpression) { return (MethodExpression) obj; } else if (obj == null) { throw new MethodNotFoundException("Identity '" + this.image + "' was null and was unable to invoke"); } else { throw new ELException( "Identity '" + this.image + "' does not reference a MethodExpression instance, returned type: " + obj.getClass().getName()); } }
Example 11
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 12
Source File: AstValue.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object base = this.children[0].getValue(ctx); int propCount = this.jjtGetNumChildren(); int i = 1; Object suffix = null; ELResolver resolver = ctx.getELResolver(); while (base != null && i < propCount) { suffix = this.children[i].getValue(ctx); if (i + 1 < propCount && (this.children[i+1] instanceof AstMethodParameters)) { AstMethodParameters mps = (AstMethodParameters) this.children[i+1]; // This is a method Object[] paramValues = mps.getParameters(ctx); base = resolver.invoke(ctx, base, suffix, getTypesFromValues(paramValues), paramValues); i+=2; } else { // This is a property if (suffix == null) { return null; } ctx.setPropertyResolved(false); base = resolver.getValue(ctx, base, suffix); i++; } } if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled", base, suffix)); } return base; }
Example 13
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 14
Source File: AstValue.java From tomcatsrc with Apache License 2.0 | 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 15
Source File: AstValue.java From Tomcat8-Source-Read with MIT License | 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 16
Source File: AstValue.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
private final Target getTarget(EvaluationContext ctx) throws ELException { // evaluate expr-a to value-a Object base = this.children[0].getValue(ctx); // if our base is null (we know there are more properties to evaluate) if (base == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.base", this.children[0].getImage())); } // set up our start/end Object property = null; int propCount = this.jjtGetNumChildren(); int i = 1; // Evaluate any properties or methods before our target ELResolver resolver = ctx.getELResolver(); while (i < propCount) { if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call not at end of expression base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null, ((AstMethodParameters) this.children[i + 1]).getParameters(ctx)); i += 2; } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i += 2; if (property == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } else if (i + 1 < propCount) { // Object with property not at end of expression property = this.children[i].getValue(ctx); ctx.setPropertyResolved(false); base = resolver.getValue(ctx, base, property); i++; } else { // Object with property at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i++; if (property == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } if (base == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } Target t = new Target(); t.base = base; t.property = property; return t; }
Example 17
Source File: AstValue.java From tomcatsrc with Apache License 2.0 | 4 votes |
private final Target getTarget(EvaluationContext ctx) throws ELException { // evaluate expr-a to value-a Object base = this.children[0].getValue(ctx); // if our base is null (we know there are more properties to evaluate) if (base == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.base", this.children[0].getImage())); } // set up our start/end Object property = null; int propCount = this.jjtGetNumChildren(); int i = 1; // Evaluate any properties or methods before our target ELResolver resolver = ctx.getELResolver(); while (i < propCount) { if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call not at end of expression base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null, ((AstMethodParameters) this.children[i + 1]).getParameters(ctx)); i += 2; } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i += 2; if (property == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } else if (i + 1 < propCount) { // Object with property not at end of expression property = this.children[i].getValue(ctx); ctx.setPropertyResolved(false); base = resolver.getValue(ctx, base, property); i++; } else { // Object with property at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i++; if (property == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } if (base == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } Target t = new Target(); t.base = base; t.property = property; return t; }
Example 18
Source File: AstIdentifier.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { // Lambda parameters if (ctx.isLambdaArgument(this.image)) { return ctx.getLambdaArgument(this.image); } // Variable mapper VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getValue(ctx.getELContext()); } } // EL Resolvers ctx.setPropertyResolved(false); Object result; /* Putting the Boolean into the ELContext is part of a performance * optimisation for ScopedAttributeELResolver. When looking up "foo", * the resolver can't differentiate between ${ foo } and ${ foo.bar }. * This is important because the expensive class lookup only needs to * be performed in the later case. This flag tells the resolver if the * lookup can be skipped. */ if (parent instanceof AstValue) { ctx.putContext(this.getClass(), Boolean.FALSE); } else { ctx.putContext(this.getClass(), Boolean.TRUE); } try { result = ctx.getELResolver().getValue(ctx, null, this.image); } finally { // Always reset the flag to false so the optimisation is not applied // inappropriately ctx.putContext(this.getClass(), Boolean.FALSE); } if (ctx.isPropertyResolved()) { return result; } // Import result = ctx.getImportHandler().resolveClass(this.image); if (result != null) { return new ELClass((Class<?>) result); } result = ctx.getImportHandler().resolveStatic(this.image); if (result != null) { try { return ((Class<?>) result).getField(this.image).get(null); } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { throw new ELException(e); } } throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled.null", this.image)); }
Example 19
Source File: AstValue.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { Object base = this.children[0].getValue(ctx); int propCount = this.jjtGetNumChildren(); int i = 1; Object suffix = null; ELResolver resolver = ctx.getELResolver(); while (base != null && i < propCount) { suffix = this.children[i].getValue(ctx); if (i + 1 < propCount && (this.children[i+1] instanceof AstMethodParameters)) { AstMethodParameters mps = (AstMethodParameters) this.children[i+1]; if (base instanceof Optional && "orElseGet".equals(suffix) && mps.jjtGetNumChildren() == 1) { Node paramFoOptional = mps.jjtGetChild(0); if (!(paramFoOptional instanceof AstLambdaExpression || paramFoOptional instanceof LambdaExpression)) { throw new ELException(MessageFactory.get( "stream.optional.paramNotLambda", suffix)); } } // This is a method Object[] paramValues = mps.getParameters(ctx); base = resolver.invoke(ctx, base, suffix, getTypesFromValues(paramValues), paramValues); i+=2; } else { // This is a property if (suffix == null) { return null; } ctx.setPropertyResolved(false); base = resolver.getValue(ctx, base, suffix); i++; } } if (!ctx.isPropertyResolved()) { throw new PropertyNotFoundException(MessageFactory.get( "error.resolver.unhandled", base, suffix)); } return base; }
Example 20
Source File: AstValue.java From Tomcat8-Source-Read with MIT License | 4 votes |
private final Target getTarget(EvaluationContext ctx) throws ELException { // evaluate expr-a to value-a Object base = this.children[0].getValue(ctx); // if our base is null (we know there are more properties to evaluate) if (base == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.base", this.children[0].getImage())); } // set up our start/end Object property = null; int propCount = this.jjtGetNumChildren(); int i = 1; // Evaluate any properties or methods before our target ELResolver resolver = ctx.getELResolver(); while (i < propCount) { if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call not at end of expression base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null, ((AstMethodParameters) this.children[i + 1]).getParameters(ctx)); i += 2; } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i += 2; if (property == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } else if (i + 1 < propCount) { // Object with property not at end of expression property = this.children[i].getValue(ctx); ctx.setPropertyResolved(false); base = resolver.getValue(ctx, base, property); i++; } else { // Object with property at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i++; if (property == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } if (base == null) { throw new PropertyNotFoundException(MessageFactory.get( "error.unreachable.property", property)); } } Target t = new Target(); t.base = base; t.property = property; return t; }