Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 35804 invoked from network); 14 Jan 2010 22:42:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jan 2010 22:42:07 -0000 Received: (qmail 20482 invoked by uid 500); 14 Jan 2010 22:42:06 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 20400 invoked by uid 500); 14 Jan 2010 22:42:06 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 20389 invoked by uid 99); 14 Jan 2010 22:42:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 22:42:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 22:42:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A2AF323888EC; Thu, 14 Jan 2010 22:41:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r899450 - in /tomcat/trunk/java/org/apache/el/parser: AstBracketSuffix.java AstDotSuffix.java AstMethodParameters.java AstValue.java ELParser.jjt Suffix.java Date: Thu, 14 Jan 2010 22:41:41 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100114224141.A2AF323888EC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Thu Jan 14 22:41:41 2010 New Revision: 899450 URL: http://svn.apache.org/viewvc?rev=899450&view=rev Log: Remove the Suffix interface and get the Parser to create a MehtodParameters object which allows a cleaner implementation. Added: tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java (with props) Removed: tomcat/trunk/java/org/apache/el/parser/Suffix.java Modified: tomcat/trunk/java/org/apache/el/parser/AstBracketSuffix.java tomcat/trunk/java/org/apache/el/parser/AstDotSuffix.java tomcat/trunk/java/org/apache/el/parser/AstValue.java tomcat/trunk/java/org/apache/el/parser/ELParser.jjt Modified: tomcat/trunk/java/org/apache/el/parser/AstBracketSuffix.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstBracketSuffix.java?rev=899450&r1=899449&r2=899450&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/el/parser/AstBracketSuffix.java (original) +++ tomcat/trunk/java/org/apache/el/parser/AstBracketSuffix.java Thu Jan 14 22:41:41 2010 @@ -27,7 +27,7 @@ * @author Jacob Hookom [jacob@hookom.net] * @version $Change: 181177 $$Date$$Author$ */ -public final class AstBracketSuffix extends SimpleNode implements Suffix { +public final class AstBracketSuffix extends SimpleNode { public AstBracketSuffix(int id) { super(id); } Modified: tomcat/trunk/java/org/apache/el/parser/AstDotSuffix.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstDotSuffix.java?rev=899450&r1=899449&r2=899450&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/el/parser/AstDotSuffix.java (original) +++ tomcat/trunk/java/org/apache/el/parser/AstDotSuffix.java Thu Jan 14 22:41:41 2010 @@ -27,7 +27,7 @@ * @author Jacob Hookom [jacob@hookom.net] * @version $Change: 181177 $$Date$$Author$ */ -public final class AstDotSuffix extends SimpleNode implements Suffix { +public final class AstDotSuffix extends SimpleNode { public AstDotSuffix(int id) { super(id); } Added: tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java?rev=899450&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java (added) +++ tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java Thu Jan 14 22:41:41 2010 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* Generated By:JJTree: Do not edit this line. AstDotSuffix.java */ + +package org.apache.el.parser; + +import java.util.ArrayList; + +import org.apache.el.lang.EvaluationContext; + +/** + * $Id$ + */ +public final class AstMethodParameters extends SimpleNode { + public AstMethodParameters(int id) { + super(id); + } + + public Object[] getParameters(EvaluationContext ctx) { + ArrayList params = new ArrayList(); + for (int i = 0; i < this.jjtGetNumChildren(); i++) { + params.add(this.jjtGetChild(i).getValue(ctx)); + } + return params.toArray(new Object[params.size()]); + } + + public Class[] getParameterTypes(EvaluationContext ctx) { + ArrayList> paramTypes = new ArrayList>(); + for (int i = 0; i < this.jjtGetNumChildren(); i++) { + paramTypes.add(this.jjtGetChild(i).getType(ctx)); + } + return paramTypes.toArray(new Class[paramTypes.size()]); + } +} Propchange: tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision Modified: tomcat/trunk/java/org/apache/el/parser/AstValue.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstValue.java?rev=899450&r1=899449&r2=899450&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/el/parser/AstValue.java (original) +++ tomcat/trunk/java/org/apache/el/parser/AstValue.java Thu Jan 14 22:41:41 2010 @@ -20,7 +20,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; import javax.el.ELException; import javax.el.ELResolver; @@ -73,7 +72,15 @@ // set up our start/end Object property = null; - int propCount = this.jjtGetNumChildren() - 1; + int propCount = this.jjtGetNumChildren(); + + if (propCount > 2 && + this.jjtGetChild(propCount - 1) instanceof AstMethodParameters) { + // Method call with paramaters. + propCount-=2; + } else { + propCount--; + } int i = 1; // evaluate any properties before our target @@ -115,22 +122,16 @@ ELResolver resolver = ctx.getELResolver(); while (base != null && i < propCount) { suffix = this.children[i].getValue(ctx); - if (i + 1 < propCount && !(this.children[i+1] instanceof Suffix)) { - // Looking for a method - ArrayList params = new ArrayList(); - ArrayList> paramTypes = new ArrayList>(); - while (i + 1 < propCount && - !(this.children[i+1] instanceof Suffix)) { - params.add(this.children[i+1].getValue(ctx)); - paramTypes.add(this.children[i+1].getType(ctx)); - i++; - } + if (i + 1 < propCount && + (this.children[i+1] instanceof AstMethodParameters)) { + AstMethodParameters mps = + (AstMethodParameters) this.children[i+1]; + // This is a method base = resolver.invoke(ctx, base, suffix, - paramTypes.toArray(new Class[paramTypes.size()]), - params.toArray(new Object[params.size()])); - i++; + mps.getParameterTypes(ctx), mps.getParameters(ctx)); + i+=2; } else { - // Looking for a property + // This is a property if (suffix == null) { return null; } else { @@ -215,13 +216,25 @@ @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 Suffix) { + 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, this.jjtGetChild(1).getValue(ctx)); } + - + /** + * @ since EL 2.2 + */ + @Override + public boolean isParametersProvided() { + if (this.children.length > 2 + && this.jjtGetChild(2) instanceof AstMethodParameters) { + return true; + } + return false; + } } Modified: tomcat/trunk/java/org/apache/el/parser/ELParser.jjt URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/ELParser.jjt?rev=899450&r1=899449&r2=899450&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/el/parser/ELParser.jjt (original) +++ tomcat/trunk/java/org/apache/el/parser/ELParser.jjt Thu Jan 14 22:41:41 2010 @@ -251,7 +251,7 @@ /* * MethodParameters */ -void MethodParameters() : {} +void MethodParameters() #MethodParameters : {} { ( Expression() ( Expression())* )? } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org