Java Code Examples for org.apache.el.lang.EvaluationContext#getFunctionMapper()
The following examples show how to use
org.apache.el.lang.EvaluationContext#getFunctionMapper() .
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: 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 2
Source File: AstFunction.java From Tomcat7.0.67 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 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: AstLambdaExpression.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public Object getValue(EvaluationContext ctx) throws ELException { // Correct evaluation requires knowledge of the whole set of nested // expressions, not just the current expression NestedState state = getNestedState(); // Check that there are not more sets of parameters than there are // nested expressions. int methodParameterSetCount = jjtGetNumChildren() - 2; if (methodParameterSetCount > state.getNestingCount()) { throw new ELException(MessageFactory.get( "error.lambda.tooManyMethodParameterSets")); } // First child is always parameters even if there aren't any AstLambdaParameters formalParametersNode = (AstLambdaParameters) children[0]; Node[] formalParamNodes = formalParametersNode.children; // Second child is a value expression ValueExpressionImpl ve = new ValueExpressionImpl("", children[1], ctx.getFunctionMapper(), ctx.getVariableMapper(), null); // Build a LambdaExpression List<String> formalParameters = new ArrayList<>(); if (formalParamNodes != null) { for (Node formalParamNode : formalParamNodes) { formalParameters.add(formalParamNode.getImage()); } } LambdaExpression le = new LambdaExpression(formalParameters, ve); le.setELContext(ctx); if (jjtGetNumChildren() == 2) { // No method parameters // Can only invoke the expression if none of the lambda expressions // in the nesting declare parameters if (state.getHasFormalParameters()) { return le; } else { return le.invoke(ctx, (Object[]) null); } } /* * This is a (possibly nested) lambda expression with one or more sets * of parameters provided. * * If there are more nested expressions than sets of parameters this may * return a LambdaExpression. * * If there are more sets of parameters than nested expressions an * ELException will have been thrown by the check at the start of this * method. */ // Always have to invoke the outer-most expression int methodParameterIndex = 2; Object result = le.invoke(((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); methodParameterIndex++; while (result instanceof LambdaExpression && methodParameterIndex < jjtGetNumChildren()) { result = ((LambdaExpression) result).invoke(((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); methodParameterIndex++; } return result; }
Example 5
Source File: AstFunction.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public Object getValue(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())); } Class<?>[] paramTypes = m.getParameterTypes(); Object[] params = null; Object result = null; int numParams = this.jjtGetNumChildren(); if (numParams > 0) { params = new Object[numParams]; try { for (int i = 0; i < numParams; i++) { params[i] = this.children[i].getValue(ctx); params[i] = coerceToType(params[i], paramTypes[i]); } } catch (ELException ele) { throw new ELException(MessageFactory.get("error.function", this .getOutputName()), ele); } } try { result = m.invoke(null, params); } catch (IllegalAccessException iae) { throw new ELException(MessageFactory.get("error.function", this .getOutputName()), iae); } catch (InvocationTargetException ite) { Throwable cause = ite.getCause(); if (cause instanceof ThreadDeath) { throw (ThreadDeath) cause; } if (cause instanceof VirtualMachineError) { throw (VirtualMachineError) cause; } throw new ELException(MessageFactory.get("error.function", this .getOutputName()), cause); } return result; }
Example 6
Source File: AstFunction.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public Object getValue(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())); } Class<?>[] paramTypes = m.getParameterTypes(); Object[] params = null; Object result = null; int numParams = this.jjtGetNumChildren(); if (numParams > 0) { params = new Object[numParams]; try { for (int i = 0; i < numParams; i++) { params[i] = this.children[i].getValue(ctx); params[i] = coerceToType(params[i], paramTypes[i]); } } catch (ELException ele) { throw new ELException(MessageFactory.get("error.function", this .getOutputName()), ele); } } try { result = m.invoke(null, params); } catch (IllegalAccessException iae) { throw new ELException(MessageFactory.get("error.function", this .getOutputName()), iae); } catch (InvocationTargetException ite) { Throwable cause = ite.getCause(); if (cause instanceof ThreadDeath) { throw (ThreadDeath) cause; } if (cause instanceof VirtualMachineError) { throw (VirtualMachineError) cause; } throw new ELException(MessageFactory.get("error.function", this .getOutputName()), cause); } return result; }