From: markt Date: Wed, 13 Jan 2010 22:10:49 +0000 (+0000) Subject: Implement the new ValueExpression.getValueReference() method. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e44ac9333f3b50f4c8f8320bc926a639a602805f;p=tomcat7.0 Implement the new ValueExpression.getValueReference() method. Add some plumbing for MethodExpression.isParametersProvided() Add some more generics where we can without breaking the code generation git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@898969 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/el/MethodExpressionImpl.java b/java/org/apache/el/MethodExpressionImpl.java index f0819af9a..ed55c835e 100644 --- a/java/org/apache/el/MethodExpressionImpl.java +++ b/java/org/apache/el/MethodExpressionImpl.java @@ -317,4 +317,13 @@ public final class MethodExpressionImpl extends MethodExpression implements public boolean isLiteralText() { return false; } + + /** + * @since EL 2.2 + */ + @Override + public boolean isParametersProvided() { + return this.getNode().isParametersProvided(); + } + } diff --git a/java/org/apache/el/ValueExpressionImpl.java b/java/org/apache/el/ValueExpressionImpl.java index 74d84a878..0fd2a7791 100644 --- a/java/org/apache/el/ValueExpressionImpl.java +++ b/java/org/apache/el/ValueExpressionImpl.java @@ -31,6 +31,7 @@ import javax.el.FunctionMapper; import javax.el.PropertyNotFoundException; import javax.el.PropertyNotWritableException; import javax.el.ValueExpression; +import javax.el.ValueReference; import javax.el.VariableMapper; import org.apache.el.lang.ELSupport; @@ -103,7 +104,7 @@ public final class ValueExpressionImpl extends ValueExpression implements private transient Node node; public ValueExpressionImpl() { - + super(); } /** @@ -270,4 +271,15 @@ public final class ValueExpressionImpl extends ValueExpression implements public String toString() { return "ValueExpression["+this.expr+"]"; } + + /** + * @since EL 2.2 + */ + @Override + public ValueReference getValueReference(ELContext context) { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, + this.varMapper); + return this.getNode().getValueReference(ctx); + } + } diff --git a/java/org/apache/el/parser/AstValue.java b/java/org/apache/el/parser/AstValue.java index ef63eacdc..5f5b25cf3 100644 --- a/java/org/apache/el/parser/AstValue.java +++ b/java/org/apache/el/parser/AstValue.java @@ -26,6 +26,7 @@ import javax.el.ELException; import javax.el.ELResolver; import javax.el.MethodInfo; import javax.el.PropertyNotFoundException; +import javax.el.ValueReference; import org.apache.el.lang.ELSupport; import org.apache.el.lang.EvaluationContext; @@ -207,4 +208,20 @@ public final class AstValue extends SimpleNode { } return result; } + + /** + * @since EL 2.2 + */ + @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) { + // This is a method call + return null; + } + Target t = getTarget(ctx); + return new ValueReference(t.base, this.jjtGetChild(1).getValue(ctx)); + } + + } diff --git a/java/org/apache/el/parser/Node.java b/java/org/apache/el/parser/Node.java index e872babe8..f495fc87b 100644 --- a/java/org/apache/el/parser/Node.java +++ b/java/org/apache/el/parser/Node.java @@ -21,6 +21,7 @@ package org.apache.el.parser; import javax.el.ELException; import javax.el.MethodInfo; +import javax.el.ValueReference; import org.apache.el.lang.EvaluationContext; @@ -31,7 +32,7 @@ import org.apache.el.lang.EvaluationContext; /** * @author Jacob Hookom [jacob@hookom.net] - * @version $Change: 181177 $$Date$$Author$ + * $Id$ */ public interface Node { @@ -63,9 +64,21 @@ public interface Node { public Object getValue(EvaluationContext ctx) throws ELException; public void setValue(EvaluationContext ctx, Object value) throws ELException; - public Class getType(EvaluationContext ctx) throws ELException; + public Class getType(EvaluationContext ctx) throws ELException; public boolean isReadOnly(EvaluationContext ctx) throws ELException; public void accept(NodeVisitor visitor) throws Exception; - public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) throws ELException; - public Object invoke(EvaluationContext ctx, Class[] paramTypes, Object[] paramValues) throws ELException; + public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) + throws ELException; + public Object invoke(EvaluationContext ctx, Class[] paramTypes, + Object[] paramValues) throws ELException; + + /** + * @since EL 2.2 + */ + public ValueReference getValueReference(EvaluationContext ctx); + + /** + * @since EL 2.2 + */ + public boolean isParametersProvided(); } diff --git a/java/org/apache/el/parser/SimpleNode.java b/java/org/apache/el/parser/SimpleNode.java index 5250ffdde..747fcc358 100644 --- a/java/org/apache/el/parser/SimpleNode.java +++ b/java/org/apache/el/parser/SimpleNode.java @@ -21,6 +21,7 @@ package org.apache.el.parser; import javax.el.ELException; import javax.el.MethodInfo; import javax.el.PropertyNotWritableException; +import javax.el.ValueReference; import org.apache.el.lang.ELSupport; import org.apache.el.lang.EvaluationContext; @@ -153,17 +154,27 @@ public abstract class SimpleNode extends ELSupport implements Node { } } - // Interface el.parser.Node uses raw types (and is auto-generated) - public Object invoke(EvaluationContext ctx, - @SuppressWarnings("unchecked") Class[] paramTypes, + public Object invoke(EvaluationContext ctx, Class[] paramTypes, Object[] paramValues) throws ELException { throw new UnsupportedOperationException(); } - // Interface el.parser.Node uses a raw type (and is auto-generated) public MethodInfo getMethodInfo(EvaluationContext ctx, - @SuppressWarnings("unchecked") Class[] paramTypes) - throws ELException { + Class[] paramTypes) throws ELException { throw new UnsupportedOperationException(); } + + /** + * @since EL 2.2 + */ + public ValueReference getValueReference(EvaluationContext ctx) { + return null; + } + + /** + * @since EL 2.2 + */ + public boolean isParametersProvided() { + return false; + } }