jon 00/11/24 16:00:06
Modified: src/java/org/apache/velocity/util/introspection
Introspector.java
Log:
added this stuff here cause it is general purpose
Revision Changes Path
1.7 +20 -1
jakarta-velocity/src/java/org/apache/velocity/util/introspection/Introspector.java
Index: Introspector.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/util/introspection/Introspector.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Introspector.java 2000/11/01 21:36:58 1.6
+++ Introspector.java 2000/11/25 00:00:06 1.7
@@ -83,7 +83,7 @@
* and stored for
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Bob McWhirter</a>
- * @version $Id: Introspector.java,v 1.6 2000/11/01 21:36:58 jvanzyl Exp $
+ * @version $Id: Introspector.java,v 1.7 2000/11/25 00:00:06 jon Exp $
*/
// isAssignable checks for arguments that are subclasses
@@ -131,5 +131,24 @@
{
ClassMap classMethodMap = (ClassMap) classMethodMaps.get(c);
return classMethodMap.findMethod(name, params);
+ }
+
+ /**
+ * Checks whether the provided object implements a given method.
+ *
+ * @param object The object to check.
+ * @param methodName The method to check for.
+ * @return Whether the method is implemented.
+ */
+ public static boolean implementsMethod(Object object, String methodName)
+ {
+ int m;
+
+ Method[] methods = object.getClass().getMethods();
+ for (m = 0 ; m < methods.length ; ++m)
+ if (methodName.equals(methods[m].getName()))
+ break;
+
+ return (m < methods.length);
}
}