You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by di...@apache.org on 2007/10/28 09:09:38 UTC
svn commit: r589295 -
/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java
Author: dion
Date: Sun Oct 28 01:09:37 2007
New Revision: 589295
URL: http://svn.apache.org/viewvc?rev=589295&view=rev
Log:
JEXL-25 bring across code from Peters update
Modified:
commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java
Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java?rev=589295&r1=589294&r2=589295&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java (original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java Sun Oct 28 01:09:37 2007
@@ -23,64 +23,85 @@
import java.util.Map;
import java.util.Set;
+import org.apache.commons.logging.Log;
+
/**
* This basic function of this class is to return a Method object for a
* particular class given the name of a method and the parameters to the method
* in the form of an Object[]
- *
+ * <p/>
* The first time the Introspector sees a class it creates a class method map
* for the class in question. Basically the class method map is a Hastable where
* Method objects are keyed by a concatenation of the method name and the names
* of classes that make up the parameters.
- *
+ *
* For example, a method with the following signature:
- *
+ *
* public void method(String a, StringBuffer b)
- *
+ *
* would be mapped by the key:
- *
+ *
* "method" + "java.lang.String" + "java.lang.StringBuffer"
- *
+ *
* This mapping is performed for all the methods in a class and stored for
- *
- * @since 1.0
+ *
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
* @author <a href="mailto:bob@werken.com">Bob McWhirter</a>
* @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
* @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
+ * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
* @version $Id$
+ * @since 1.0
*/
public class IntrospectorBase {
+ /** the logger. */
+ private final Log rlog;
+
/**
* Holds the method maps for the classes we know about, keyed by Class
* object.
*/
- protected Map classMethodMaps = new HashMap();
+ protected final Map classMethodMaps = new HashMap();
/**
* Holds the qualified class names for the classes we hold in the
* classMethodMaps hash.
*/
- protected Set cachedClassNames = new HashSet();
+ private Set cachedClassNames = new HashSet();
+
+ /**
+ * Create the introspector.
+ * @param log the logger to use
+ */
+ public IntrospectorBase(Log log) {
+ this.rlog = log;
+ }
/**
* Gets the method defined by <code>name</code> and <code>params</code>
* for the Class <code>c</code>.
- *
- * @param c Class in which the method search is taking place
- * @param name Name of the method being searched for
+ *
+ * @param c Class in which the method search is taking place
+ * @param name Name of the method being searched for
* @param params An array of Objects (not Classes) that describe the the
- * parameters
- *
+ * parameters
* @return The desired Method object.
- * @throws MethodMap.AmbiguousException when an ambiguous method declaration is found.
+ * @throws IllegalArgumentException When the parameters passed in can not be used for introspection.
+ * @throws MethodMap.AmbiguousException When the method map contains more than
+ * one match for the requested signature.
+ * CSOFF: RedundantThrows
*/
- public Method getMethod(Class c, String name, Object[] params) throws MethodMap.AmbiguousException {
+ public Method getMethod(Class c, String name, Object[] params)
+ throws IllegalArgumentException, MethodMap.AmbiguousException {
if (c == null) {
throw new IllegalArgumentException("Introspector.getMethod(): Class method key was null: " + name);
}
- ClassMap classMap = null;
+ if (params == null) {
+ throw new IllegalArgumentException("params object is null!");
+ }
+
+ ClassMap classMap;
synchronized (classMethodMaps) {
classMap = (ClassMap) classMethodMaps.get(c);
@@ -105,7 +126,8 @@
}
return classMap.findMethod(name, params);
- }
+ } // CSON: RedundantThrows
+
/**
* Creates a class map for specific class and registers it in the cache.
@@ -115,7 +137,7 @@
* @return a {@link ClassMap}
*/
protected ClassMap createClassMap(Class c) {
- ClassMap classMap = new ClassMap(c);
+ ClassMap classMap = new ClassMap(c,rlog);
classMethodMaps.put(c, classMap);
cachedClassNames.add(c.getName());