Methods Summary |
---|
public boolean | extendsClass(java.lang.Class aClass)Tests whether this class extends the given class.
Note that no class extends itself.
if (aClass == null)
{
return false;
}
boolean extendsClass = false;
Class superClass = mClassReflected.getSuperclass();
while (superClass != null && !extendsClass)
{
if (superClass.getName().equals(aClass.getName()))
{
extendsClass = true;
}
superClass = superClass.getSuperclass();
}
return ( extendsClass );
|
public java.lang.reflect.Method[] | getCallableInstanceMethods(java.util.Collection excludeList)Returns an array of Methods that are callable
instance methods of this class/interface. Thus the returned array contains
declared non-abstract public methods
declared public methods of superclasses/superinterfaces excluding
the classes/interfaces from excludeList param
boolean includeAll = false;
if (excludeList == null || excludeList.isEmpty())
{
includeAll = true;
}
ArrayList methodList = new ArrayList();
Class aClass = mClassReflected;
Method[] methods = null;
while (aClass != null)
{
boolean shouldInclude =
includeAll || ! excludeList.contains(aClass.getName());
if (shouldInclude)
{
Method[] declMethods = aClass.getDeclaredMethods();
for (int i = 0 ; i < declMethods.length ; i++)
{
int modifiers = declMethods[i].getModifiers();
boolean isCallableInstanceMethod = false;
boolean isPublicMethod = Modifier.isPublic(modifiers);
boolean isAbstractMethod = Modifier.isAbstract(modifiers);
boolean isStaticMethod = Modifier.isStatic(modifiers);
isCallableInstanceMethod = isPublicMethod && !isAbstractMethod
&& !isStaticMethod;
if (isCallableInstanceMethod)
{
methodList.add(declMethods[i]);
}
}
}
aClass = aClass.getSuperclass();
}
methods = new Method[methodList.size()];
return ((Method[])methodList.toArray(methods));
|
public java.lang.reflect.Method[] | getDeclaredConcretePublicMethods()
Method[] declMethods = mClassReflected.getDeclaredMethods();
ArrayList publicMethods = new ArrayList();
for (int i = 0 ; i < declMethods.length ; i++)
{
int modifiers = declMethods[i].getModifiers();
boolean isPublic = Modifier.isPublic (modifiers);
boolean isAbstract = Modifier.isAbstract(modifiers);
if (isPublic && !isAbstract)
{
publicMethods.add(declMethods[i]);
}
}
Method[] pMethods = new Method[publicMethods.size()];
return ( (Method[])publicMethods.toArray (pMethods) );
|
public java.lang.reflect.Method | getMethod(java.lang.String operationName, java.lang.String[] signature)Returns a method in this class with given name and signature.
Note that the signature for primitive parameters is "int", "boolean",
"char" and so on.
Method method = null;
Class[] parameterTypes = null;
if (signature != null)
{
parameterTypes = new Class[signature.length];
for (int i = 0 ; i < signature.length ; i++)
{
String parameterName = signature[i];
Class primitiveClass = ParamInfo.getPrimitiveClass(parameterName);
boolean parameterIsPrimitive = ( primitiveClass != null );
if (parameterIsPrimitive)
{
parameterTypes[i] = primitiveClass;
}
else
{
parameterTypes[i] = Class.forName(parameterName);
}
}
}
method = mClassReflected.getMethod(operationName, parameterTypes);
return ( method );
|
public boolean | implementsInterface(java.lang.Class aClass)Tests whether this class implements an interface represented by
the given Class Object. The Parameter may not be null. This class
implements an interface represented by parameter Class iff
parameter is not null &&
this class or any of its super classes implement the interface
represented by parameter.
boolean implInterface = false;
Class thisClass = mClassReflected;
while (aClass != null && thisClass != null && !implInterface)
{
Class[] interfaces = thisClass.getInterfaces();
for (int i = 0 ; i < interfaces.length ; i++)
{
Class anInterface = interfaces[i];
if (anInterface.getName().equals(aClass.getName()))
{
implInterface = true;
break;
}
}
thisClass = thisClass.getSuperclass();
}
return ( implInterface );
|
public java.lang.Object | invokeMethodOn(java.lang.reflect.Method method, java.lang.Object targetObject, java.lang.Object[] actualParams)Invokes the given method on this class with given runtime instance
of target object and parameter instances of the method.
Object result = null;
if (method == null || targetObject == null)// || actualParams == null)
{
throw new IllegalArgumentException();
}
result = method.invoke(targetObject, actualParams);
return ( result );
|