Return to www.inductionframework.org

com.acciente.induction.util
Class ReflectUtils

java.lang.Object
  extended by com.acciente.induction.util.ReflectUtils

public class ReflectUtils
extends java.lang.Object

Internal. Some useful reflection methods. (It is not convincing enough at this time that these methods are general enough to be promoted to the com.acciente.reflect package)


Constructor Summary
ReflectUtils()
           
 
Method Summary
static java.lang.reflect.Constructor getNoArgConstructor(java.lang.Class oClass)
          This method introspects into the specified class and checks if the class has a public constructor with formal parameters (i.e.
static java.lang.reflect.Constructor getSingletonConstructor(java.lang.Class oClass)
          This method introspects into the specified class and checks if the class has only one public constructor.
static java.lang.reflect.Method getSingletonMethod(java.lang.Class oClass, java.lang.String sMethodName)
          This method introspects into the specified class and checks if the class has only one public method with the specified name.
static java.lang.reflect.Method getSingletonMethod(java.lang.Class oClass, java.lang.String sMethodName, boolean bIgnoreCase)
          This method introspects into the specified class and checks if the class has only one public method with the specified name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectUtils

public ReflectUtils()
Method Detail

getSingletonConstructor

public static java.lang.reflect.Constructor getSingletonConstructor(java.lang.Class oClass)
                                                             throws ConstructorNotFoundException
This method introspects into the specified class and checks if the class has only one public constructor. If one one constructor is found it is returned otherwise an exception is thrown.

Parameters:
oClass - the class to introspect into
Returns:
the single public constructor
Throws:
ConstructorNotFoundException - if there are no public constructors or if there is more than one public constructor

getNoArgConstructor

public static java.lang.reflect.Constructor getNoArgConstructor(java.lang.Class oClass)
                                                         throws ConstructorNotFoundException
This method introspects into the specified class and checks if the class has a public constructor with formal parameters (i.e. a no-arg constructor). If found it is returned otherwise an exception is thrown.

Parameters:
oClass - the class to introspect into
Returns:
the no-arg constructor
Throws:
ConstructorNotFoundException - if there are no no-arg constructors

getSingletonMethod

public static java.lang.reflect.Method getSingletonMethod(java.lang.Class oClass,
                                                          java.lang.String sMethodName)
                                                   throws MethodNotFoundException
This method introspects into the specified class and checks if the class has only one public method with the specified name. If one one method is found it is returned otherwise an IllegalArgumentException is thrown.

Parameters:
oClass - the class to introspect into
sMethodName - the name of the method (case-sensitive)
Returns:
the single public method found
Throws:
MethodNotFoundException - if there are no public methods with the specified name or if there is more than one public method with the specified name

getSingletonMethod

public static java.lang.reflect.Method getSingletonMethod(java.lang.Class oClass,
                                                          java.lang.String sMethodName,
                                                          boolean bIgnoreCase)
                                                   throws MethodNotFoundException
This method introspects into the specified class and checks if the class has only one public method with the specified name. If one one method is found it is returned otherwise an IllegalArgumentException is thrown.

Parameters:
oClass - the class to introspect into
sMethodName - the name of the method
bIgnoreCase - true if the method search should be case-sensitive
Returns:
the single public method found
Throws:
MethodNotFoundException - if there are no public methods with the specified name or if there is more than one public method with the specified name

Return to www.inductionframework.org

Copyright (c) 2008 Acciente, LLC. All rights reserved.