You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/15 12:10:55 UTC
svn commit: r1503162 - in /tomcat/trunk/java/org/apache/el:
Messages.properties parser/AstLambdaExpression.java
Author: markt
Date: Mon Jul 15 10:10:54 2013
New Revision: 1503162
URL: http://svn.apache.org/r1503162
Log:
Remove duplication
Modified:
tomcat/trunk/java/org/apache/el/Messages.properties
tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
Modified: tomcat/trunk/java/org/apache/el/Messages.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/Messages.properties?rev=1503162&r1=1503161&r2=1503162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/Messages.properties (original)
+++ tomcat/trunk/java/org/apache/el/Messages.properties Mon Jul 15 10:10:54 2013
@@ -52,6 +52,3 @@ error.context.null=ELContext was null
# Parser
error.identifier.notjava=The identifier [{0}] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier). This check can be disabled by setting the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.
-
-# AstLambdaExpression
-error.lambda.args.tooFew=Only [{0}] arguments were provided for a lambda expression that requires at least [{1}]
Modified: tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java?rev=1503162&r1=1503161&r2=1503162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java Mon Jul 15 10:10:54 2013
@@ -18,16 +18,13 @@
package org.apache.el.parser;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.el.ELException;
import javax.el.LambdaExpression;
import org.apache.el.ValueExpressionImpl;
import org.apache.el.lang.EvaluationContext;
-import org.apache.el.util.MessageFactory;
public class AstLambdaExpression extends SimpleNode {
@@ -63,42 +60,17 @@ public class AstLambdaExpression extends
}
}
- @SuppressWarnings("null") // paramValues[i] can't be null due to checks
@Override
public Object invoke(EvaluationContext ctx, Class<?>[] paramTypes,
Object[] paramValues) throws ELException {
- // Two children - the formal parameters and the expression
- AstLambdaParameters formalParameters =
- (AstLambdaParameters) children[0];
-
- int paramCount = 0;
- if (formalParameters.children != null) {
- paramCount = formalParameters.children.length;
- }
- int argCount = 0;
- if (paramValues != null) {
- argCount = paramValues.length;
- }
- if (paramCount > argCount) {
- throw new ELException(MessageFactory.get("error.lambda.args.tooFew",
- Integer.valueOf(argCount), Integer.valueOf(paramCount)));
- }
+ Object result = getValue(ctx);
- // Build the argument map
- Map<String,Object> lambdaArguments = new HashMap<>();
- for (int i = 0; i < paramCount; i++) {
- lambdaArguments.put(formalParameters.children[i].getImage(),
- paramValues[i]);
+ if (result instanceof LambdaExpression) {
+ result = ((LambdaExpression) result).invoke(paramValues);
}
- ctx.enterLambdaScope(lambdaArguments);
-
- try {
- return children[1].getValue(ctx);
- } finally {
- ctx.exitLambdaScope();
- }
+ return result;
}
}
/* JavaCC - OriginalChecksum=071159eff10c8e15ec612c765ae4480a (do not edit this line) */
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org