Implement the new ValueExpression.getValueReference() method.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 13 Jan 2010 22:10:49 +0000 (22:10 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 13 Jan 2010 22:10:49 +0000 (22:10 +0000)
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

java/org/apache/el/MethodExpressionImpl.java
java/org/apache/el/ValueExpressionImpl.java
java/org/apache/el/parser/AstValue.java
java/org/apache/el/parser/Node.java
java/org/apache/el/parser/SimpleNode.java

index f0819af..ed55c83 100644 (file)
@@ -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();
+    }
+    
 }
index 74d84a8..0fd2a77 100644 (file)
@@ -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);
+    }
+    
 }
index ef63eac..5f5b25c 100644 (file)
@@ -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));
+    }
+    
+    
 }
index e872bab..f495fc8 100644 (file)
@@ -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();
 }
index 5250ffd..747fcc3 100644 (file)
@@ -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;
+    }
 }