|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.spif.util.Reflection
Static convenience methods for finding methods and making reflection invocation methods without being drowned in exception handling
Method Summary | |
static java.lang.reflect.Method |
findAdderMatching(java.lang.Class type,
java.lang.reflect.Method collectionGetter)
Returns the first (any) adder matching the given getter collection, or null if none is found |
static java.lang.reflect.Method |
findAdderMatching(java.lang.Class type,
java.lang.reflect.Method collectionGetter,
java.lang.Class adderType)
Returns an adder matching the given getter collection, or null if none is found |
static java.util.List |
findCollectionGetters(java.lang.Class type)
Returns the collection getters of a given type. |
static java.lang.reflect.Constructor |
findConstructor(java.lang.Class type,
java.lang.Class[] argTypes)
Finds a constructor and returns it, or null if it was not found |
static java.lang.reflect.Method |
findGetter(java.lang.Class type,
java.lang.String propertyName)
Returns a getter for the given name, or null if there is no such getter Case is not significant. |
static java.util.List |
findGetters(java.lang.Class type)
Returns all the getters in the given type. |
static java.lang.reflect.Method |
findMethod(java.lang.Class type,
java.lang.String name)
Finds a method witrh no arguments and returns it, or null if it was not found |
static java.lang.reflect.Method |
findMethod(java.lang.Class type,
java.lang.String name,
java.lang.Class[] argTypes)
Finds a method and returns it, or null if it was not found |
static java.lang.reflect.Method |
findSetter(java.lang.Class type,
java.lang.String propertyName,
java.lang.Class argType)
Returns a setter for the given name, or null if there is no such setter. |
static java.lang.reflect.Method |
findSetterMatching(java.lang.Class type,
java.lang.reflect.Method getter)
Returns a setter matching the given getter, or null if none is found |
static java.util.List |
findSetters(java.lang.Class type)
Returns all the setters in the given type. |
static java.lang.Object |
invoke(java.lang.reflect.Constructor constructor)
Invokes a constructor taking no arguments |
static java.lang.Object |
invoke(java.lang.reflect.Constructor constructor,
java.lang.Object argument)
Invokes a constructor taking one argument |
static java.lang.Object |
invoke(java.lang.reflect.Constructor constructor,
java.lang.Object[] arguments)
Invokes a constructor |
static java.lang.Object |
invoke(java.lang.Object on,
java.lang.reflect.Method method)
Invokes a no-argument method on an object |
static java.lang.Object |
invoke(java.lang.Object on,
java.lang.reflect.Method method,
java.lang.Object argument)
Invokes a single argument method on an object |
static java.lang.Object |
invoke(java.lang.Object on,
java.lang.reflect.Method method,
java.lang.Object[] arguments)
Invokes a method on an object |
static java.lang.Object |
newInstance(java.lang.Class type)
Creates an instance of the given class if possible |
static java.lang.Object |
newInstance(java.lang.Class type,
java.lang.Object argument)
Creates an instance of the given class if possible |
static java.lang.String |
toName(java.lang.Class type)
Returns the short name of a class |
static java.lang.String |
toPropertyName(java.lang.reflect.Method accessor)
Returns the name of the property the given method is a getter or setter for, in lowercase only. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static java.lang.Object invoke(java.lang.Object on, java.lang.reflect.Method method) throws ReflectionException
a
- runtime ReflectionException for any error
ReflectionException
public static java.lang.Object invoke(java.lang.Object on, java.lang.reflect.Method method, java.lang.Object argument) throws ReflectionException
a
- runtime ReflectionException for any error
ReflectionException
public static java.lang.Object invoke(java.lang.Object on, java.lang.reflect.Method method, java.lang.Object[] arguments) throws ReflectionException
a
- runtime ReflectionException for any error
ReflectionException
public static java.lang.Object invoke(java.lang.reflect.Constructor constructor)
a
- runtime ReflectionException for any errorpublic static java.lang.Object invoke(java.lang.reflect.Constructor constructor, java.lang.Object argument)
a
- runtime ReflectionException for any errorpublic static java.lang.Object invoke(java.lang.reflect.Constructor constructor, java.lang.Object[] arguments) throws ReflectionException
a
- runtime ReflectionException for any error
ReflectionException
public static java.lang.Object newInstance(java.lang.Class type)
ReflectionException
- if an instance could not be createdpublic static java.lang.Object newInstance(java.lang.Class type, java.lang.Object argument)
public static java.lang.reflect.Constructor findConstructor(java.lang.Class type, java.lang.Class[] argTypes)
public static java.lang.reflect.Method findMethod(java.lang.Class type, java.lang.String name)
public static java.lang.reflect.Method findMethod(java.lang.Class type, java.lang.String name, java.lang.Class[] argTypes)
public static java.lang.reflect.Method findSetterMatching(java.lang.Class type, java.lang.reflect.Method getter)
public static java.lang.reflect.Method findAdderMatching(java.lang.Class type, java.lang.reflect.Method collectionGetter, java.lang.Class adderType)
type
- the type containing the addercollectionGetter
- the getter to matchadderType
- the type of the adder, or null to return the first name matchpublic static java.lang.reflect.Method findAdderMatching(java.lang.Class type, java.lang.reflect.Method collectionGetter)
type
- the type containing the addercollectionGetter
- the getter to matchpublic static java.lang.reflect.Method findGetter(java.lang.Class type, java.lang.String propertyName)
public static java.lang.reflect.Method findSetter(java.lang.Class type, java.lang.String propertyName, java.lang.Class argType)
public static java.util.List findGetters(java.lang.Class type)
public static java.util.List findCollectionGetters(java.lang.Class type)
public static java.util.List findSetters(java.lang.Class type)
public static java.lang.String toName(java.lang.Class type)
public static java.lang.String toPropertyName(java.lang.reflect.Method accessor)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |