jstrachan 2002/12/16 02:41:59
Modified: jexl/src/java/org/apache/commons/jexl/util/introspection
Uberspect.java Introspector.java MethodMap.java
ClassMap.java
jexl/src/java/org/apache/commons/jexl/util GetExecutor.java
Introspector.java PropertyExecutor.java
BooleanPropertyExecutor.java
jexl/src/java/org/apache/commons/jexl ExpressionFactory.java
ExpressionImpl.java
jexl/src/java/org/apache/commons/jexl/parser
ASTIdentifier.java
Log:
Removed some unused imports
Revision Changes Path
1.2 +1 -2
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/Uberspect.java
Index: Uberspect.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/Uberspect.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Uberspect.java 5 Aug 2002 05:04:53 -0000 1.1
+++ Uberspect.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -56,7 +56,6 @@
import java.util.Iterator;
-import java.lang.reflect.Method;
/**
* 'Federated' introspection/reflection interface to allow the introspection
1.2 +3 -8
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/Introspector.java
Index: Introspector.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/Introspector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Introspector.java 5 Aug 2002 05:04:53 -0000 1.1
+++ Introspector.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -54,14 +54,9 @@
package org.apache.commons.jexl.util.introspection;
-import org.apache.commons.logging.Log;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.HashSet;
-
import java.lang.reflect.Method;
+
+import org.apache.commons.logging.Log;
/**
1.2 +427 -430
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/MethodMap.java
Index: MethodMap.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/MethodMap.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MethodMap.java 5 Aug 2002 05:04:53 -0000 1.1
+++ MethodMap.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -1,167 +1,164 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Velocity", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Velocity", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
*/
-package org.apache.commons.jexl.util.introspection;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Hashtable;
-
-import java.lang.reflect.Method;
-
-/**
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Bob McWhirter</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Christoph Reck</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Attila Szegedi</a>
- * @version $Id$
- */
-public class MethodMap
+package org.apache.commons.jexl.util.introspection;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Bob McWhirter</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christoph Reck</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Attila Szegedi</a>
+ * @version $Id$
+ */
+public class MethodMap
{
private static final int MORE_SPECIFIC = 0;
private static final int LESS_SPECIFIC = 1;
private static final int INCOMPARABLE = 2;
-
- /**
- * Keep track of all methods with the same name.
- */
- Map methodByNameMap = new Hashtable();
-
- /**
- * Add a method to a list of methods by name.
- * For a particular class we are keeping track
- * of all the methods with the same name.
- */
- public void add(Method method)
- {
- String methodName = method.getName();
-
- List l = get( methodName );
-
- if ( l == null)
- {
- l = new ArrayList();
- methodByNameMap.put(methodName, l);
- }
-
- l.add(method);
-
- return;
- }
-
- /**
- * Return a list of methods with the same name.
- *
- * @param String key
- * @return List list of methods
- */
- public List get(String key)
- {
- return (List) methodByNameMap.get(key);
- }
-
- /**
- * <p>
- * Find a method. Attempts to find the
- * most specific applicable method using the
- * algorithm described in the JLS section
- * 15.12.2 (with the exception that it can't
- * distinguish a primitive type argument from
- * an object type argument, since in reflection
- * primitive type arguments are represented by
- * their object counterparts, so for an argument of
- * type (say) java.lang.Integer, it will not be able
- * to decide between a method that takes int and a
- * method that takes java.lang.Integer as a parameter.
- * </p>
- *
- * <p>
- * This turns out to be a relatively rare case
- * where this is needed - however, functionality
- * like this is needed.
- * </p>
- *
- * @param methodName name of method
- * @param args the actual arguments with which the method is called
- * @return the most specific applicable method, or null if no
- * method is applicable.
- * @throws AmbiguousException if there is more than one maximally
- * specific applicable method
- */
- public Method find(String methodName, Object[] args)
- throws AmbiguousException
- {
- List methodList = get(methodName);
-
- if (methodList == null)
- {
- return null;
- }
-
- int l = args.length;
+
+ /**
+ * Keep track of all methods with the same name.
+ */
+ Map methodByNameMap = new Hashtable();
+
+ /**
+ * Add a method to a list of methods by name.
+ * For a particular class we are keeping track
+ * of all the methods with the same name.
+ */
+ public void add(Method method)
+ {
+ String methodName = method.getName();
+
+ List l = get( methodName );
+
+ if ( l == null)
+ {
+ l = new ArrayList();
+ methodByNameMap.put(methodName, l);
+ }
+
+ l.add(method);
+
+ return;
+ }
+
+ /**
+ * Return a list of methods with the same name.
+ *
+ * @param String key
+ * @return List list of methods
+ */
+ public List get(String key)
+ {
+ return (List) methodByNameMap.get(key);
+ }
+
+ /**
+ * <p>
+ * Find a method. Attempts to find the
+ * most specific applicable method using the
+ * algorithm described in the JLS section
+ * 15.12.2 (with the exception that it can't
+ * distinguish a primitive type argument from
+ * an object type argument, since in reflection
+ * primitive type arguments are represented by
+ * their object counterparts, so for an argument of
+ * type (say) java.lang.Integer, it will not be able
+ * to decide between a method that takes int and a
+ * method that takes java.lang.Integer as a parameter.
+ * </p>
+ *
+ * <p>
+ * This turns out to be a relatively rare case
+ * where this is needed - however, functionality
+ * like this is needed.
+ * </p>
+ *
+ * @param methodName name of method
+ * @param args the actual arguments with which the method is called
+ * @return the most specific applicable method, or null if no
+ * method is applicable.
+ * @throws AmbiguousException if there is more than one maximally
+ * specific applicable method
+ */
+ public Method find(String methodName, Object[] args)
+ throws AmbiguousException
+ {
+ List methodList = get(methodName);
+
+ if (methodList == null)
+ {
+ return null;
+ }
+
+ int l = args.length;
Class[] classes = new Class[l];
-
- for(int i = 0; i < l; ++i)
- {
- Object arg = args[i];
+
+ for(int i = 0; i < l; ++i)
+ {
+ Object arg = args[i];
/*
* if we are careful down below, a null argument goes in there
@@ -169,221 +166,221 @@
*/
classes[i] =
arg == null ? null : arg.getClass();
- }
-
- return getMostSpecific(methodList, classes);
- }
-
- /**
- * simple distinguishable exception, used when
- * we run across ambiguous overloading
- */
- public static class AmbiguousException extends Exception
- {
- }
-
-
- private static Method getMostSpecific(List methods, Class[] classes)
- throws AmbiguousException
- {
- LinkedList applicables = getApplicables(methods, classes);
-
- if(applicables.isEmpty())
- {
- return null;
- }
-
- if(applicables.size() == 1)
- {
- return (Method)applicables.getFirst();
- }
+ }
+
+ return getMostSpecific(methodList, classes);
+ }
+
+ /**
+ * simple distinguishable exception, used when
+ * we run across ambiguous overloading
+ */
+ public static class AmbiguousException extends Exception
+ {
+ }
+
+
+ private static Method getMostSpecific(List methods, Class[] classes)
+ throws AmbiguousException
+ {
+ LinkedList applicables = getApplicables(methods, classes);
+
+ if(applicables.isEmpty())
+ {
+ return null;
+ }
+
+ if(applicables.size() == 1)
+ {
+ return (Method)applicables.getFirst();
+ }
/*
- * This list will contain the maximally specific methods. Hopefully at
- * the end of the below loop, the list will contain exactly one method,
+ * This list will contain the maximally specific methods. Hopefully at
+ * the end of the below loop, the list will contain exactly one method,
* (the most specific method) otherwise we have ambiguity.
*/
-
- LinkedList maximals = new LinkedList();
+
+ LinkedList maximals = new LinkedList();
for (Iterator applicable = applicables.iterator();
- applicable.hasNext();)
- {
- Method app = (Method) applicable.next();
- Class[] appArgs = app.getParameterTypes();
- boolean lessSpecific = false;
-
- for (Iterator maximal = maximals.iterator();
- !lessSpecific && maximal.hasNext();)
- {
- Method max = (Method) maximal.next();
+ applicable.hasNext();)
+ {
+ Method app = (Method) applicable.next();
+ Class[] appArgs = app.getParameterTypes();
+ boolean lessSpecific = false;
+
+ for (Iterator maximal = maximals.iterator();
+ !lessSpecific && maximal.hasNext();)
+ {
+ Method max = (Method) maximal.next();
switch(moreSpecific(appArgs, max.getParameterTypes()))
{
- case MORE_SPECIFIC:
- {
+ case MORE_SPECIFIC:
+ {
/*
- * This method is more specific than the previously
+ * This method is more specific than the previously
* known maximally specific, so remove the old maximum.
*/
-
- maximal.remove();
- break;
- }
- case LESS_SPECIFIC:
- {
+ maximal.remove();
+ break;
+ }
+
+ case LESS_SPECIFIC:
+ {
/*
- * This method is less specific than some of the
- * currently known maximally specific methods, so we
- * won't add it into the set of maximally specific
+ * This method is less specific than some of the
+ * currently known maximally specific methods, so we
+ * won't add it into the set of maximally specific
* methods
*/
-
- lessSpecific = true;
- break;
- }
- }
+
+ lessSpecific = true;
+ break;
+ }
+ }
+ }
+
+ if(!lessSpecific)
+ {
+ maximals.addLast(app);
}
-
- if(!lessSpecific)
- {
- maximals.addLast(app);
- }
- }
-
- if(maximals.size() > 1)
- {
- // We have more than one maximally specific method
- throw new AmbiguousException();
- }
-
- return (Method)maximals.getFirst();
- }
-
- /**
- * Determines which method signature (represented by a class array) is more
- * specific. This defines a partial ordering on the method signatures.
- * @param c1 first signature to compare
- * @param c2 second signature to compare
- * @return MORE_SPECIFIC if c1 is more specific than c2, LESS_SPECIFIC if
- * c1 is less specific than c2, INCOMPARABLE if they are incomparable.
- */
- private static int moreSpecific(Class[] c1, Class[] c2)
- {
- boolean c1MoreSpecific = false;
+ }
+
+ if(maximals.size() > 1)
+ {
+ // We have more than one maximally specific method
+ throw new AmbiguousException();
+ }
+
+ return (Method)maximals.getFirst();
+ }
+
+ /**
+ * Determines which method signature (represented by a class array) is more
+ * specific. This defines a partial ordering on the method signatures.
+ * @param c1 first signature to compare
+ * @param c2 second signature to compare
+ * @return MORE_SPECIFIC if c1 is more specific than c2, LESS_SPECIFIC if
+ * c1 is less specific than c2, INCOMPARABLE if they are incomparable.
+ */
+ private static int moreSpecific(Class[] c1, Class[] c2)
+ {
+ boolean c1MoreSpecific = false;
boolean c2MoreSpecific = false;
-
- for(int i = 0; i < c1.length; ++i)
- {
- if(c1[i] != c2[i])
- {
- c1MoreSpecific =
- c1MoreSpecific ||
- isStrictMethodInvocationConvertible(c2[i], c1[i]);
- c2MoreSpecific =
- c2MoreSpecific ||
- isStrictMethodInvocationConvertible(c1[i], c2[i]);
- }
- }
-
- if(c1MoreSpecific)
- {
- if(c2MoreSpecific)
- {
+
+ for(int i = 0; i < c1.length; ++i)
+ {
+ if(c1[i] != c2[i])
+ {
+ c1MoreSpecific =
+ c1MoreSpecific ||
+ isStrictMethodInvocationConvertible(c2[i], c1[i]);
+ c2MoreSpecific =
+ c2MoreSpecific ||
+ isStrictMethodInvocationConvertible(c1[i], c2[i]);
+ }
+ }
+
+ if(c1MoreSpecific)
+ {
+ if(c2MoreSpecific)
+ {
/*
- * Incomparable due to cross-assignable arguments (i.e.
+ * Incomparable due to cross-assignable arguments (i.e.
* foo(String, Object) vs. foo(Object, String))
*/
-
- return INCOMPARABLE;
+
+ return INCOMPARABLE;
}
-
- return MORE_SPECIFIC;
+
+ return MORE_SPECIFIC;
+ }
+
+ if(c2MoreSpecific)
+ {
+ return LESS_SPECIFIC;
}
-
- if(c2MoreSpecific)
- {
- return LESS_SPECIFIC;
- }
/*
- * Incomparable due to non-related arguments (i.e.
+ * Incomparable due to non-related arguments (i.e.
* foo(Runnable) vs. foo(Serializable))
*/
-
- return INCOMPARABLE;
- }
-
- /**
- * Returns all methods that are applicable to actual argument types.
- * @param methods list of all candidate methods
- * @param classes the actual types of the arguments
- * @return a list that contains only applicable methods (number of
- * formal and actual arguments matches, and argument types are assignable
- * to formal types through a method invocation conversion).
- */
- private static LinkedList getApplicables(List methods, Class[] classes)
- {
+
+ return INCOMPARABLE;
+ }
+
+ /**
+ * Returns all methods that are applicable to actual argument types.
+ * @param methods list of all candidate methods
+ * @param classes the actual types of the arguments
+ * @return a list that contains only applicable methods (number of
+ * formal and actual arguments matches, and argument types are assignable
+ * to formal types through a method invocation conversion).
+ */
+ private static LinkedList getApplicables(List methods, Class[] classes)
+ {
LinkedList list = new LinkedList();
-
- for (Iterator imethod = methods.iterator(); imethod.hasNext();)
- {
- Method method = (Method) imethod.next();
-
- if(isApplicable(method, classes))
- {
- list.add(method);
- }
-
- }
- return list;
- }
-
- /**
- * Returns true if the supplied method is applicable to actual
- * argument types.
- */
- private static boolean isApplicable(Method method, Class[] classes)
- {
- Class[] methodArgs = method.getParameterTypes();
-
- if(methodArgs.length != classes.length)
- {
- return false;
- }
-
- for(int i = 0; i < classes.length; ++i)
- {
- if(!isMethodInvocationConvertible(methodArgs[i], classes[i]))
- {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Determines whether a type represented by a class object is
- * convertible to another type represented by a class object using a
- * method invocation conversion, treating object types of primitive
- * types as if they were primitive types (that is, a Boolean actual
- * parameter type matches boolean primitive formal type). This behavior
- * is because this method is used to determine applicable methods for
- * an actual parameter list, and primitive types are represented by
+
+ for (Iterator imethod = methods.iterator(); imethod.hasNext();)
+ {
+ Method method = (Method) imethod.next();
+
+ if(isApplicable(method, classes))
+ {
+ list.add(method);
+ }
+
+ }
+ return list;
+ }
+
+ /**
+ * Returns true if the supplied method is applicable to actual
+ * argument types.
+ */
+ private static boolean isApplicable(Method method, Class[] classes)
+ {
+ Class[] methodArgs = method.getParameterTypes();
+
+ if(methodArgs.length != classes.length)
+ {
+ return false;
+ }
+
+ for(int i = 0; i < classes.length; ++i)
+ {
+ if(!isMethodInvocationConvertible(methodArgs[i], classes[i]))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Determines whether a type represented by a class object is
+ * convertible to another type represented by a class object using a
+ * method invocation conversion, treating object types of primitive
+ * types as if they were primitive types (that is, a Boolean actual
+ * parameter type matches boolean primitive formal type). This behavior
+ * is because this method is used to determine applicable methods for
+ * an actual parameter list, and primitive types are represented by
* their object duals in reflective method calls.
- *
- * @param formal the formal parameter type to which the actual
- * parameter type should be convertible
- * @param actual the actual parameter type.
- * @return true if either formal type is assignable from actual type,
- * or formal is a primitive type and actual is its corresponding object
- * type or an object type of a primitive type that can be converted to
- * the formal type.
- */
- private static boolean isMethodInvocationConvertible(Class formal,
- Class actual)
+ *
+ * @param formal the formal parameter type to which the actual
+ * parameter type should be convertible
+ * @param actual the actual parameter type.
+ * @return true if either formal type is assignable from actual type,
+ * or formal is a primitive type and actual is its corresponding object
+ * type or an object type of a primitive type that can be converted to
+ * the formal type.
+ */
+ private static boolean isMethodInvocationConvertible(Class formal,
+ Class actual)
{
/*
* if it's a null, it means the arg was null
@@ -392,71 +389,71 @@
{
return true;
}
-
+
/*
* Check for identity or widening reference conversion
*/
-
- if (actual != null && formal.isAssignableFrom(actual))
- {
- return true;
- }
+
+ if (actual != null && formal.isAssignableFrom(actual))
+ {
+ return true;
+ }
/*
- * Check for boxing with widening primitive conversion. Note that
+ * Check for boxing with widening primitive conversion. Note that
* actual parameters are never primitives.
*/
-
- if (formal.isPrimitive())
- {
- if(formal == Boolean.TYPE && actual == Boolean.class)
- return true;
- if(formal == Character.TYPE && actual == Character.class)
- return true;
- if(formal == Byte.TYPE && actual == Byte.class)
- return true;
- if(formal == Short.TYPE &&
- (actual == Short.class || actual == Byte.class))
- return true;
- if(formal == Integer.TYPE &&
- (actual == Integer.class || actual == Short.class ||
- actual == Byte.class))
- return true;
- if(formal == Long.TYPE &&
- (actual == Long.class || actual == Integer.class ||
- actual == Short.class || actual == Byte.class))
- return true;
- if(formal == Float.TYPE &&
- (actual == Float.class || actual == Long.class ||
- actual == Integer.class || actual == Short.class ||
- actual == Byte.class))
- return true;
- if(formal == Double.TYPE &&
- (actual == Double.class || actual == Float.class ||
- actual == Long.class || actual == Integer.class ||
- actual == Short.class || actual == Byte.class))
- return true;
- }
-
- return false;
- }
-
- /**
- * Determines whether a type represented by a class object is
- * convertible to another type represented by a class object using a
- * method invocation conversion, without matching object and primitive
- * types. This method is used to determine the more specific type when
+
+ if (formal.isPrimitive())
+ {
+ if(formal == Boolean.TYPE && actual == Boolean.class)
+ return true;
+ if(formal == Character.TYPE && actual == Character.class)
+ return true;
+ if(formal == Byte.TYPE && actual == Byte.class)
+ return true;
+ if(formal == Short.TYPE &&
+ (actual == Short.class || actual == Byte.class))
+ return true;
+ if(formal == Integer.TYPE &&
+ (actual == Integer.class || actual == Short.class ||
+ actual == Byte.class))
+ return true;
+ if(formal == Long.TYPE &&
+ (actual == Long.class || actual == Integer.class ||
+ actual == Short.class || actual == Byte.class))
+ return true;
+ if(formal == Float.TYPE &&
+ (actual == Float.class || actual == Long.class ||
+ actual == Integer.class || actual == Short.class ||
+ actual == Byte.class))
+ return true;
+ if(formal == Double.TYPE &&
+ (actual == Double.class || actual == Float.class ||
+ actual == Long.class || actual == Integer.class ||
+ actual == Short.class || actual == Byte.class))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Determines whether a type represented by a class object is
+ * convertible to another type represented by a class object using a
+ * method invocation conversion, without matching object and primitive
+ * types. This method is used to determine the more specific type when
* comparing signatures of methods.
- *
- * @param formal the formal parameter type to which the actual
- * parameter type should be convertible
- * @param actual the actual parameter type.
- * @return true if either formal type is assignable from actual type,
- * or formal and actual are both primitive types and actual can be
- * subject to widening conversion to formal.
- */
- private static boolean isStrictMethodInvocationConvertible(Class formal,
- Class actual)
+ *
+ * @param formal the formal parameter type to which the actual
+ * parameter type should be convertible
+ * @param actual the actual parameter type.
+ * @return true if either formal type is assignable from actual type,
+ * or formal and actual are both primitive types and actual can be
+ * subject to widening conversion to formal.
+ */
+ private static boolean isStrictMethodInvocationConvertible(Class formal,
+ Class actual)
{
/*
* we shouldn't get a null into, but if so
@@ -465,41 +462,41 @@
{
return true;
}
-
+
/*
* Check for identity or widening reference conversion
*/
- if(formal.isAssignableFrom(actual))
- {
- return true;
+ if(formal.isAssignableFrom(actual))
+ {
+ return true;
}
-
+
/*
* Check for widening primitive conversion.
*/
-
- if(formal.isPrimitive())
- {
- if(formal == Short.TYPE && (actual == Byte.TYPE))
- return true;
- if(formal == Integer.TYPE &&
- (actual == Short.TYPE || actual == Byte.TYPE))
- return true;
- if(formal == Long.TYPE &&
- (actual == Integer.TYPE || actual == Short.TYPE ||
- actual == Byte.TYPE))
- return true;
- if(formal == Float.TYPE &&
- (actual == Long.TYPE || actual == Integer.TYPE ||
- actual == Short.TYPE || actual == Byte.TYPE))
- return true;
- if(formal == Double.TYPE &&
- (actual == Float.TYPE || actual == Long.TYPE ||
- actual == Integer.TYPE || actual == Short.TYPE ||
- actual == Byte.TYPE))
- return true;
- }
- return false;
- }
-}
+
+ if(formal.isPrimitive())
+ {
+ if(formal == Short.TYPE && (actual == Byte.TYPE))
+ return true;
+ if(formal == Integer.TYPE &&
+ (actual == Short.TYPE || actual == Byte.TYPE))
+ return true;
+ if(formal == Long.TYPE &&
+ (actual == Integer.TYPE || actual == Short.TYPE ||
+ actual == Byte.TYPE))
+ return true;
+ if(formal == Float.TYPE &&
+ (actual == Long.TYPE || actual == Integer.TYPE ||
+ actual == Short.TYPE || actual == Byte.TYPE))
+ return true;
+ if(formal == Double.TYPE &&
+ (actual == Float.TYPE || actual == Long.TYPE ||
+ actual == Integer.TYPE || actual == Short.TYPE ||
+ actual == Byte.TYPE))
+ return true;
+ }
+ return false;
+ }
+}
1.2 +3 -5
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java
Index: ClassMap.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassMap.java 5 Aug 2002 05:04:53 -0000 1.1
+++ ClassMap.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -54,12 +54,10 @@
package org.apache.commons.jexl.util.introspection;
-import java.util.Map;
-import java.util.List;
-import java.util.Hashtable;
-
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.Hashtable;
+import java.util.Map;
/**
* Taken from the Velocity tree so we can be self-sufficient
1.2 +3 -5
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/GetExecutor.java
Index: GetExecutor.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/GetExecutor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GetExecutor.java 5 Aug 2002 05:06:21 -0000 1.1
+++ GetExecutor.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -54,11 +54,9 @@
package org.apache.commons.jexl.util;
-import org.apache.commons.logging.Log;
-
-import java.lang.reflect.Method;
-
import java.lang.reflect.InvocationTargetException;
+
+import org.apache.commons.logging.Log;
/**
1.4 +3 -5
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/Introspector.java
Index: Introspector.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/Introspector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Introspector.java 5 Aug 2002 05:06:21 -0000 1.3
+++ Introspector.java 16 Dec 2002 10:41:59 -0000 1.4
@@ -53,13 +53,11 @@
*/
package org.apache.commons.jexl.util;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
import org.apache.commons.jexl.util.introspection.Uberspect;
import org.apache.commons.jexl.util.introspection.UberspectImpl;
import org.apache.commons.jexl.util.introspection.UberspectLoggable;
-
-import java.lang.reflect.Method;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Little class to manage a Velocity uberspector (Vel 1.4+) for instrospective
1.2 +0 -1
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/PropertyExecutor.java
Index: PropertyExecutor.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/PropertyExecutor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PropertyExecutor.java 5 Aug 2002 05:06:21 -0000 1.1
+++ PropertyExecutor.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -53,7 +53,6 @@
*/
package org.apache.commons.jexl.util;
-import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.jexl.util.introspection.Introspector;
1.2 +1 -4
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/BooleanPropertyExecutor.java
Index: BooleanPropertyExecutor.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/util/BooleanPropertyExecutor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BooleanPropertyExecutor.java 5 Aug 2002 05:06:21 -0000 1.1
+++ BooleanPropertyExecutor.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -54,9 +54,6 @@
package org.apache.commons.jexl.util;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-
import org.apache.commons.logging.Log;
/**
* Handles discovery and valuation of a
1.2 +5 -6
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/ExpressionFactory.java
Index: ExpressionFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/ExpressionFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExpressionFactory.java 26 Apr 2002 04:23:14 -0000 1.1
+++ ExpressionFactory.java 16 Dec 2002 10:41:59 -0000 1.2
@@ -53,13 +53,12 @@
*/
package org.apache.commons.jexl;
+import java.io.StringReader;
+
+import org.apache.commons.jexl.parser.ASTExpressionExpression;
+import org.apache.commons.jexl.parser.ASTReferenceExpression;
import org.apache.commons.jexl.parser.Parser;
import org.apache.commons.jexl.parser.SimpleNode;
-import org.apache.commons.jexl.parser.ASTReference;
-import org.apache.commons.jexl.parser.ASTReferenceExpression;
-import org.apache.commons.jexl.parser.ASTExpressionExpression;
-
-import java.io.StringReader;
/**
* Used to create Expression objects
1.4 +4 -7
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/ExpressionImpl.java
Index: ExpressionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/ExpressionImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExpressionImpl.java 9 Aug 2002 13:36:10 -0000 1.3
+++ ExpressionImpl.java 16 Dec 2002 10:41:59 -0000 1.4
@@ -54,17 +54,14 @@
package org.apache.commons.jexl;
-import org.apache.commons.jexl.parser.SimpleNode;
-import org.apache.commons.jexl.parser.Parser;
-import org.apache.commons.jexl.parser.ASTReference;
-
-import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.jexl.parser.SimpleNode;
+
/**
* Implelmentation of an Expression. Created by the ExpressionFactory.
- *
+ *
* The expression is different than a script - it's really just either
* a reference or expression that we can get the value of.
*
1.4 +1 -4
jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/parser/ASTIdentifier.java
Index: ASTIdentifier.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jexl/src/java/org/apache/commons/jexl/parser/ASTIdentifier.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ASTIdentifier.java 5 Aug 2002 12:41:08 -0000 1.3
+++ ASTIdentifier.java 16 Dec 2002 10:41:59 -0000 1.4
@@ -56,9 +56,6 @@
package org.apache.commons.jexl.parser;
import org.apache.commons.jexl.JexlContext;
-import org.apache.commons.jexl.util.Introspector;
-
-import java.lang.reflect.Method;
/**
* Simple identifier -
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>