Generics changes for o.a.el
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 30 Nov 2008 22:32:18 +0000 (22:32 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 30 Nov 2008 22:32:18 +0000 (22:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@721914 13f79535-47bb-0310-9956-ffa450edef68

27 files changed:
java/org/apache/el/ExpressionFactoryImpl.java
java/org/apache/el/MethodExpressionImpl.java
java/org/apache/el/MethodExpressionLiteral.java
java/org/apache/el/ValueExpressionImpl.java
java/org/apache/el/ValueExpressionLiteral.java
java/org/apache/el/lang/ELSupport.java
java/org/apache/el/lang/ExpressionBuilder.java
java/org/apache/el/lang/FunctionMapperImpl.java
java/org/apache/el/parser/ArithmeticNode.java
java/org/apache/el/parser/AstChoice.java
java/org/apache/el/parser/AstCompositeExpression.java
java/org/apache/el/parser/AstDeferredExpression.java
java/org/apache/el/parser/AstDynamicExpression.java
java/org/apache/el/parser/AstEmpty.java
java/org/apache/el/parser/AstFloatingPoint.java
java/org/apache/el/parser/AstFunction.java
java/org/apache/el/parser/AstIdentifier.java
java/org/apache/el/parser/AstInteger.java
java/org/apache/el/parser/AstLiteralExpression.java
java/org/apache/el/parser/AstNegative.java
java/org/apache/el/parser/AstNot.java
java/org/apache/el/parser/AstNull.java
java/org/apache/el/parser/AstString.java
java/org/apache/el/parser/AstValue.java
java/org/apache/el/parser/BooleanNode.java
java/org/apache/el/parser/SimpleNode.java
java/org/apache/el/util/ReflectionUtil.java

index 79718bd..5372aaa 100644 (file)
@@ -42,7 +42,7 @@ public class ExpressionFactoryImpl extends ExpressionFactory {
         super();
     }
 
-    public Object coerceToType(Object obj, Class type) {
+    public Object coerceToType(Object obj, Class<?> type) {
         return ELSupport.coerceToType(obj, type);
     }
 
@@ -59,7 +59,7 @@ public class ExpressionFactoryImpl extends ExpressionFactory {
     }
 
     public ValueExpression createValueExpression(ELContext context,
-            String expression, Class expectedType) {
+            String expression, Class<?> expectedType) {
         if (expectedType == null) {
             throw new NullPointerException(MessageFactory
                     .get("error.value.expectedType"));
@@ -69,7 +69,7 @@ public class ExpressionFactoryImpl extends ExpressionFactory {
     }
 
     public ValueExpression createValueExpression(Object instance,
-            Class expectedType) {
+            Class<?> expectedType) {
         if (expectedType == null) {
             throw new NullPointerException(MessageFactory
                     .get("error.value.expectedType"));
index 88bae6a..7799f21 100644 (file)
@@ -80,7 +80,7 @@ import org.apache.el.util.ReflectionUtil;
 public final class MethodExpressionImpl extends MethodExpression implements
         Externalizable {
 
-    private Class expectedType;
+    private Class<?> expectedType;
 
     private String expr;
 
@@ -90,7 +90,7 @@ public final class MethodExpressionImpl extends MethodExpression implements
 
     private transient Node node;
 
-    private Class[] paramTypes;
+    private Class<?>[] paramTypes;
 
     /**
      * 
@@ -108,7 +108,7 @@ public final class MethodExpressionImpl extends MethodExpression implements
      */
     public MethodExpressionImpl(String expr, Node node,
             FunctionMapper fnMapper, VariableMapper varMapper,
-            Class expectedType, Class[] paramTypes) {
+            Class<?> expectedType, Class<?>[] paramTypes) {
         super();
         this.expr = expr;
         this.node = node;
index b0de8cb..5e3ed0f 100644 (file)
@@ -33,17 +33,18 @@ import org.apache.el.util.ReflectionUtil;
 
 public class MethodExpressionLiteral extends MethodExpression implements Externalizable {
 
-    private Class expectedType;
+    private Class<?> expectedType;
 
     private String expr;
 
-    private Class[] paramTypes;
+    private Class<?>[] paramTypes;
 
     public MethodExpressionLiteral() {
         // do nothing
     }
 
-    public MethodExpressionLiteral(String expr, Class expectedType, Class[] paramTypes) {
+    public MethodExpressionLiteral(String expr, Class<?> expectedType,
+            Class<?>[] paramTypes) {
         this.expr = expr;
         this.expectedType = expectedType;
         this.paramTypes = paramTypes;
index 759a0fd..29e8700 100644 (file)
@@ -92,7 +92,7 @@ import org.apache.el.util.ReflectionUtil;
 public final class ValueExpressionImpl extends ValueExpression implements
         Externalizable {
 
-    private Class expectedType;
+    private Class<?> expectedType;
 
     private String expr;
 
@@ -110,7 +110,7 @@ public final class ValueExpressionImpl extends ValueExpression implements
      * 
      */
     public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper,
-            VariableMapper varMapper, Class expectedType) {
+            VariableMapper varMapper, Class<?> expectedType) {
         this.expr = expr;
         this.node = node;
         this.fnMapper = fnMapper;
@@ -133,7 +133,7 @@ public final class ValueExpressionImpl extends ValueExpression implements
      * 
      * @see javax.el.ValueExpression#getExpectedType()
      */
-    public Class getExpectedType() {
+    public Class<?> getExpectedType() {
         return this.expectedType;
     }
 
@@ -167,7 +167,7 @@ public final class ValueExpressionImpl extends ValueExpression implements
      * 
      * @see javax.el.ValueExpression#getType(javax.el.ELContext)
      */
-    public Class getType(ELContext context) throws PropertyNotFoundException,
+    public Class<?> getType(ELContext context) throws PropertyNotFoundException,
             ELException {
         EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
                 this.varMapper);
index 1477b4c..0dd6158 100644 (file)
@@ -39,13 +39,13 @@ public final class ValueExpressionLiteral extends ValueExpression implements
 
     private Object value;
 
-    private Class expectedType;
+    private Class<?> expectedType;
 
     public ValueExpressionLiteral() {
         super();
     }
 
-    public ValueExpressionLiteral(Object value, Class expectedType) {
+    public ValueExpressionLiteral(Object value, Class<?> expectedType) {
         this.value = value;
         this.expectedType = expectedType;
     }
@@ -66,11 +66,11 @@ public final class ValueExpressionLiteral extends ValueExpression implements
         return true;
     }
 
-    public Class getType(ELContext context) {
+    public Class<?> getType(ELContext context) {
         return (this.value != null) ? this.value.getClass() : null;
     }
 
-    public Class getExpectedType() {
+    public Class<?> getExpectedType() {
         return this.expectedType;
     }
 
index 7c028ab..a425740 100644 (file)
@@ -184,7 +184,7 @@ public class ELSupport {
         if (ELArithmetic.isNumber(obj)) {
             return new Character((char) ((Number) obj).shortValue());
         }
-        Class objType = obj.getClass();
+        Class<?> objType = obj.getClass();
         if (obj instanceof Character) {
             return (Character) obj;
         }
@@ -209,7 +209,7 @@ public class ELSupport {
     }
 
     protected final static Number coerceToNumber(final Number number,
-            final Class type) throws IllegalArgumentException {
+            final Class<?> type) throws IllegalArgumentException {
         if (Long.TYPE == type || Long.class.equals(type)) {
             return new Long(number.longValue());
         }
@@ -251,8 +251,8 @@ public class ELSupport {
                 number, number.getClass(), type));
     }
 
-    public final static Number coerceToNumber(final Object obj, final Class type)
-            throws IllegalArgumentException {
+    public final static Number coerceToNumber(final Object obj,
+            final Class<?> type) throws IllegalArgumentException {
         if (obj == null || "".equals(obj)) {
             return coerceToNumber(ZERO, type);
         }
@@ -273,7 +273,7 @@ public class ELSupport {
     }
 
     protected final static Number coerceToNumber(final String val,
-            final Class type) throws IllegalArgumentException {
+            final Class<?> type) throws IllegalArgumentException {
         if (Long.TYPE == type || Long.class.equals(type)) {
             return Long.valueOf(val);
         }
@@ -319,7 +319,7 @@ public class ELSupport {
         }
     }
 
-    public final static void checkType(final Object obj, final Class type)
+    public final static void checkType(final Object obj, final Class<?> type)
         throws IllegalArgumentException {
         if (String.class.equals(type)) {
             coerceToString(obj);
@@ -338,8 +338,8 @@ public class ELSupport {
         }
     }
 
-    public final static Object coerceToType(final Object obj, final Class type)
-            throws IllegalArgumentException {
+    public final static Object coerceToType(final Object obj,
+            final Class<?> type) throws IllegalArgumentException {
         if (type == null || Object.class.equals(type) ||
                 (obj != null && type.isAssignableFrom(obj.getClass()))) {
             return obj;
index 006dca9..feafba9 100644 (file)
@@ -99,7 +99,7 @@ public final class ExpressionBuilder implements NodeVisitor {
                     if (numChildren == 1) {
                         n = n.jjtGetChild(0);
                     } else {
-                        Class type = null;
+                        Class<?> type = null;
                         Node child = null;
                         for (int i = 0; i < numChildren; i++) {
                             child = n.jjtGetChild(i);
@@ -189,15 +189,15 @@ public final class ExpressionBuilder implements NodeVisitor {
         }
     }
 
-    public ValueExpression createValueExpression(Class expectedType)
+    public ValueExpression createValueExpression(Class<?> expectedType)
             throws ELException {
         Node n = this.build();
         return new ValueExpressionImpl(this.expression, n, this.fnMapper,
                 this.varMapper, expectedType);
     }
 
-    public MethodExpression createMethodExpression(Class expectedReturnType,
-            Class[] expectedParamTypes) throws ELException {
+    public MethodExpression createMethodExpression(Class<?> expectedReturnType,
+            Class<?>[] expectedParamTypes) throws ELException {
         Node n = this.build();
         if (n instanceof AstValue || n instanceof AstIdentifier) {
             return new MethodExpressionImpl(expression, n, this.fnMapper,
index 2c41820..86a8adc 100644 (file)
@@ -153,8 +153,8 @@ public class FunctionMapperImpl extends FunctionMapper implements
         public Method getMethod() {
             if (this.m == null) {
                 try {
-                    Class t = ReflectionUtil.forName(this.owner);
-                    Class[] p = ReflectionUtil.toTypeArray(this.types);
+                    Class<?> t = ReflectionUtil.forName(this.owner);
+                    Class<?>[] p = ReflectionUtil.toTypeArray(this.types);
                     this.m = t.getMethod(this.name, p);
                 } catch (Exception e) {
                     e.printStackTrace();
index 74b9bd4..85627ee 100644 (file)
@@ -35,7 +35,7 @@ public class ArithmeticNode extends SimpleNode {
         super(i);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return Number.class;
     }
index 3a3cf3a..6600b24 100644 (file)
@@ -32,7 +32,7 @@ public final class AstChoice extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         Object val = this.getValue(ctx);
         return (val != null) ? val.getClass() : null;
index 035c2d0..c7946b1 100644 (file)
@@ -33,7 +33,7 @@ public final class AstCompositeExpression extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return String.class;
     }
index 7d442a3..f64c49d 100644 (file)
@@ -32,7 +32,7 @@ public final class AstDeferredExpression extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return this.children[0].getType(ctx);
     }
index 8765b28..1b54cec 100644 (file)
@@ -32,7 +32,7 @@ public final class AstDynamicExpression extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return this.children[0].getType(ctx);
     }
index 55eee93..0a3a8ce 100644 (file)
@@ -35,7 +35,7 @@ public final class AstEmpty extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return Boolean.class;
     }
index 1413570..ed5056a 100644 (file)
@@ -52,7 +52,7 @@ public final class AstFloatingPoint extends SimpleNode {
         return this.getFloatingPoint();
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return this.getFloatingPoint().getClass();
     }
index 05e3a71..1f0e666 100644 (file)
@@ -58,7 +58,7 @@ public final class AstFunction extends SimpleNode {
         return prefix;
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         
         FunctionMapper fnMapper = ctx.getFunctionMapper();
@@ -90,7 +90,7 @@ public final class AstFunction extends SimpleNode {
                     this.getOutputName()));
         }
 
-        Class[] paramTypes = m.getParameterTypes();
+        Class<?>[] paramTypes = m.getParameterTypes();
         Object[] params = null;
         Object result = null;
         int numParams = this.jjtGetNumChildren();
index b53a76f..4e9a1fc 100644 (file)
@@ -37,7 +37,7 @@ public final class AstIdentifier extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx) throws ELException {
+    public Class<?> getType(EvaluationContext ctx) throws ELException {
         VariableMapper varMapper = ctx.getVariableMapper();
         if (varMapper != null) {
             ValueExpression expr = varMapper.resolveVariable(this.image);
@@ -87,23 +87,6 @@ public final class AstIdentifier extends SimpleNode {
         ctx.getELResolver().setValue(ctx, null, this.image, value);
     }
 
-    private final Object invokeTarget(EvaluationContext ctx, Object target,
-            Object[] paramValues) throws ELException {
-        if (target instanceof MethodExpression) {
-            MethodExpression me = (MethodExpression) target;
-            return me.invoke(ctx.getELContext(), paramValues);
-        } else if (target == null) {
-            throw new MethodNotFoundException("Identity '" + this.image
-                    + "' was null and was unable to invoke");
-        } else {
-            throw new ELException(
-                    "Identity '"
-                            + this.image
-                            + "' does not reference a MethodExpression instance, returned type: "
-                            + target.getClass().getName());
-        }
-    }
-
     public Object invoke(EvaluationContext ctx, Class[] paramTypes,
             Object[] paramValues) throws ELException {
         return this.getMethodExpression(ctx).invoke(ctx.getELContext(), paramValues);
index ef5b8c1..677fb86 100644 (file)
@@ -47,7 +47,7 @@ public final class AstInteger extends SimpleNode {
         return number;
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return this.getInteger().getClass();
     }
index 5287f04..ad686e5 100644 (file)
@@ -32,7 +32,7 @@ public final class AstLiteralExpression extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx) throws ELException {
+    public Class<?> getType(EvaluationContext ctx) throws ELException {
         return String.class;
     }
 
index f58bd9b..c974158 100644 (file)
@@ -35,7 +35,7 @@ public final class AstNegative extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return Number.class;
     }
index fea9961..0201cda 100644 (file)
@@ -32,7 +32,7 @@ public final class AstNot extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return Boolean.class;
     }
index 3085ee5..c0f066e 100644 (file)
@@ -32,7 +32,7 @@ public final class AstNull extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return null;
     }
index 449916a..15c3836 100644 (file)
@@ -41,7 +41,7 @@ public final class AstString extends SimpleNode {
         return this.string;
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return String.class;
     }
index 0a53675..06262da 100644 (file)
@@ -52,7 +52,7 @@ public final class AstValue extends SimpleNode {
         super(id);
     }
 
-    public Class getType(EvaluationContext ctx) throws ELException {
+    public Class<?> getType(EvaluationContext ctx) throws ELException {
         Target t = getTarget(ctx);
         ctx.setPropertyResolved(false);
         return ctx.getELResolver().getType(ctx, t.base, t.property);
@@ -169,7 +169,7 @@ public final class AstValue extends SimpleNode {
         Method m = ReflectionUtil.getMethod(t.base, t.property, paramTypes);
         Object result = null;
         try {
-            result = m.invoke(t.base, (Object[]) paramValues);
+            result = m.invoke(t.base, paramValues);
         } catch (IllegalAccessException iae) {
             throw new ELException(iae);
         } catch (InvocationTargetException ite) {
index 1d4cc78..c769ec9 100644 (file)
@@ -32,7 +32,7 @@ public class BooleanNode extends SimpleNode {
     public BooleanNode(int i) {
         super(i);
     }
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         return Boolean.class;
     }
index 94721bb..7d68445 100644 (file)
@@ -121,7 +121,7 @@ public abstract class SimpleNode extends ELSupport implements Node {
         this.image = image;
     }
 
-    public Class getType(EvaluationContext ctx)
+    public Class<?> getType(EvaluationContext ctx)
             throws ELException {
         throw new UnsupportedOperationException();
     }
@@ -150,11 +150,13 @@ public abstract class SimpleNode extends ELSupport implements Node {
         }
     }
 
-    public Object invoke(EvaluationContext ctx, Class[] paramTypes, Object[] paramValues) throws ELException {
+    public Object invoke(EvaluationContext ctx, Class[] paramTypes,
+            Object[] paramValues) throws ELException {
         throw new UnsupportedOperationException();
     }
 
-    public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) throws ELException {
+    public MethodInfo getMethodInfo(EvaluationContext ctx,
+            Class[] paramTypes) throws ELException {
         throw new UnsupportedOperationException();
     }
 }
index 42f162a..8d42ca9 100644 (file)
@@ -43,7 +43,7 @@ public class ReflectionUtil {
     protected static final String[] PRIMITIVE_NAMES = new String[] { "boolean",
             "byte", "char", "double", "float", "int", "long", "short", "void" };
 
-    protected static final Class[] PRIMITIVES = new Class[] { boolean.class,
+    protected static final Class<?>[] PRIMITIVES = new Class[] { boolean.class,
             byte.class, char.class, double.class, float.class, int.class,
             long.class, short.class, Void.TYPE };
 
@@ -54,11 +54,11 @@ public class ReflectionUtil {
         super();
     }
 
-    public static Class forName(String name) throws ClassNotFoundException {
+    public static Class<?> forName(String name) throws ClassNotFoundException {
         if (null == name || "".equals(name)) {
             return null;
         }
-        Class c = forNamePrimitive(name);
+        Class<?> c = forNamePrimitive(name);
         if (c == null) {
             if (name.endsWith("[]")) {
                 String nc = name.substring(0, name.length() - 2);
@@ -71,7 +71,7 @@ public class ReflectionUtil {
         return c;
     }
 
-    protected static Class forNamePrimitive(String name) {
+    protected static Class<?> forNamePrimitive(String name) {
         if (name.length() <= 8) {
             int p = Arrays.binarySearch(PRIMITIVE_NAMES, name);
             if (p >= 0) {
@@ -87,10 +87,10 @@ public class ReflectionUtil {
      * @return
      * @throws ClassNotFoundException
      */
-    public static Class[] toTypeArray(String[] s) throws ClassNotFoundException {
+    public static Class<?>[] toTypeArray(String[] s) throws ClassNotFoundException {
         if (s == null)
             return null;
-        Class[] c = new Class[s.length];
+        Class<?>[] c = new Class[s.length];
         for (int i = 0; i < s.length; i++) {
             c[i] = forName(s[i]);
         }
@@ -102,7 +102,7 @@ public class ReflectionUtil {
      * @param c
      * @return
      */
-    public static String[] toTypeNameArray(Class[] c) {
+    public static String[] toTypeNameArray(Class<?>[] c) {
         if (c == null)
             return null;
         String[] s = new String[c.length];
@@ -121,7 +121,7 @@ public class ReflectionUtil {
      * @throws MethodNotFoundException
      */
     public static Method getMethod(Object base, Object property,
-            Class[] paramTypes) throws MethodNotFoundException {
+            Class<?>[] paramTypes) throws MethodNotFoundException {
         if (base == null || property == null) {
             throw new MethodNotFoundException(MessageFactory.get(
                     "error.method.notfound", base, property,
@@ -142,7 +142,7 @@ public class ReflectionUtil {
         return method;
     }
 
-    protected static final String paramString(Class[] types) {
+    protected static final String paramString(Class<?>[] types) {
         if (types != null) {
             StringBuffer sb = new StringBuffer();
             for (int i = 0; i < types.length; i++) {
@@ -166,7 +166,6 @@ public class ReflectionUtil {
     public static PropertyDescriptor getPropertyDescriptor(Object base,
             Object property) throws ELException, PropertyNotFoundException {
         String name = ELSupport.coerceToString(property);
-        PropertyDescriptor p = null;
         try {
             PropertyDescriptor[] desc = Introspector.getBeanInfo(
                     base.getClass()).getPropertyDescriptors();