Java Code Examples for javax.el.ELResolver#getValue()
The following examples show how to use
javax.el.ELResolver#getValue() .
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: 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 2
Source File: AstValue.java From tomcatsrc 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 3
Source File: VariableResolverImpl.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
/** * Resolves the specified variable within the given context. * Returns null if the variable is not found. **/ public Object resolveVariable (String pName) throws javax.servlet.jsp.el.ELException { ELContext elContext = pageContext.getELContext(); ELResolver elResolver = elContext.getELResolver(); try { return elResolver.getValue(elContext, null, pName); } catch (javax.el.ELException ex) { throw new javax.servlet.jsp.el.ELException(); } }
Example 4
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; }
Example 5
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 6
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 7
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 8
Source File: TestScopedAttributeELResolverPerformance.java From Tomcat8-Source-Read with MIT License | 3 votes |
@Test public void testGetValuePerformance() throws Exception { ELContext context = new StandardELContext(ELManager.getExpressionFactory()); context.putContext(JspContext.class, new TesterPageContext()); ELResolver resolver = new ScopedAttributeELResolver(); for (int i = 0; i < 100000; i++) { resolver.getValue(context, null, "unknown"); } }