|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.ReflectionUtility
public final class ReflectionUtility
A utility class to handle common reflection tasks.
Copyright 2006 Sans Pareil Technologies, Inc.
| Constructor Summary | |
|---|---|
private |
ReflectionUtility()
Default constructor. |
| Method Summary | |
|---|---|
static java.lang.reflect.Method |
fetchAccessor(java.lang.String property,
java.lang.Class cls)
Fetches the accessor method for the specified property in the specified class. |
static java.lang.reflect.Method |
fetchAccessor(java.lang.String property,
java.lang.Object object)
Fetches the accessor method for the specified property in the specified object. |
static java.lang.reflect.Field |
fetchField(java.lang.String name,
java.lang.Object object)
Return the Field instance with the specified name
from the object. |
static java.util.Map<java.lang.String,java.lang.reflect.Field> |
fetchFields(java.lang.Class cls)
Return the declared fields for the specified Class. |
static java.util.Map<java.lang.String,java.lang.reflect.Field> |
fetchFields(java.lang.Object object)
Return the declared fields for the specified object. |
static java.lang.reflect.Method |
fetchMethod(java.lang.Class cls,
java.lang.String name,
java.lang.Class[] parameters)
Fetch the Method defined in the specified class with
the specified name that accepts the specified
parameters. |
static java.lang.reflect.Method |
fetchMethod(java.lang.reflect.Field field,
java.lang.String name,
java.lang.Class[] parameters)
Fetch the Method defined in the specified field with
the specified name that accepts the specified
parameters. |
static java.lang.reflect.Method |
fetchMethod(java.lang.Object object,
java.lang.String name,
java.lang.Class[] parameters)
Fetch the Method defined in the specified object with
the specified name that accepts the specified
parameters. |
static java.lang.reflect.Method |
fetchMutator(java.lang.String property,
java.lang.Class cls)
Fetches the mutator method for the specified property in the specified class. |
static java.lang.reflect.Method |
fetchMutator(java.lang.String property,
java.lang.Object object)
Fetches the mutator method for the specified property in the specified object. |
static java.lang.Object |
fetchObject(java.lang.String name,
java.lang.Object object)
Return the Object instance represented by the
specified name from object. |
static java.util.Map<java.lang.String,java.lang.Object> |
fetchObjects(java.lang.Object object)
Return the Object instances representing the declared
fields for the specified object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
private ReflectionUtility()
| Method Detail |
|---|
public static final java.lang.reflect.Field fetchField(java.lang.String name,
java.lang.Object object)
throws java.lang.NoSuchFieldException
Field instance with the specified name
from the object. Sets the field accessible if
it is not accessible.
name - The name of the field to look up.object - The object from which the field is to be retrieved.
java.lang.NoSuchFieldException - If no field with the specified name
exists in object.
public static final java.lang.Object fetchObject(java.lang.String name,
java.lang.Object object)
throws java.lang.NoSuchFieldException,
java.lang.IllegalAccessException
Object instance represented by the
specified name from object.
name - The name of the object to fetch.object - The object from which the field is to be retrieved.
java.lang.NoSuchFieldException - If no field with the specified name
exists in object.
java.lang.IllegalAccessException - If the field cannot be accessed
due to custom security policies.fetchField(java.lang.String, java.lang.Object)public static final java.util.Map<java.lang.String,java.lang.reflect.Field> fetchFields(java.lang.Object object)
object.
object - The object whose declared fields are to be
retrieved.
key and
the field as valuefetchFields( Class )public static final java.util.Map<java.lang.String,java.lang.reflect.Field> fetchFields(java.lang.Class cls)
Class.
cls - The class whose declared fields are to be
retrieved.
key and
the field as value
public static final java.util.Map<java.lang.String,java.lang.Object> fetchObjects(java.lang.Object object)
throws java.lang.IllegalAccessException
Object instances representing the declared
fields for the specified object.
object - The object for which objects for the declared fields
are to be retrieved.
key and
the object as value
java.lang.IllegalAccessException - If a custom security policy prevents
access to the fields.fetchFields(java.lang.Object)
public static final java.lang.reflect.Method fetchMethod(java.lang.reflect.Field field,
java.lang.String name,
java.lang.Class[] parameters)
Method defined in the specified field with
the specified name that accepts the specified
parameters.
field - The field whose method is to be retrieved.name - The name of the method to retrieve.parameters - The parameters accepted by the method.fetchMethod( Class, String, Class[] )
public static final java.lang.reflect.Method fetchMethod(java.lang.Object object,
java.lang.String name,
java.lang.Class[] parameters)
Method defined in the specified object with
the specified name that accepts the specified
parameters.
object - The object whose method is to be retrieved.name - The name of the method to retrieve.parameters - The parameters accepted by the method.fetchMethod( Class, String, Class[] )
public static final java.lang.reflect.Method fetchMethod(java.lang.Class cls,
java.lang.String name,
java.lang.Class[] parameters)
Method defined in the specified class with
the specified name that accepts the specified
parameters.
cls - The cls whose method is to be retrieved.name - The name of the method to retrieve.parameters - The parameters accepted by the method.
public static final java.lang.reflect.Method fetchAccessor(java.lang.String property,
java.lang.Object object)
throws java.beans.IntrospectionException
property - The property whose accessor is to be fetched.object - The object to which the property belongs.
java.beans.IntrospectionException - If errors are encountered while
introspecting the specified class.fetchAccessor( String, Class )
public static final java.lang.reflect.Method fetchAccessor(java.lang.String property,
java.lang.Class cls)
throws java.beans.IntrospectionException
property - The property whose accessor is to be fetched.cls - The class to which the property belongs.
java.beans.IntrospectionException - If errors are encountered while
introspecting the specified class.
public static final java.lang.reflect.Method fetchMutator(java.lang.String property,
java.lang.Object object)
throws java.beans.IntrospectionException
property - The property whose mutator is to be fetched.object - The object to which the property belongs.
java.beans.IntrospectionException - If errors are encountered while
introspecting the specified class.fetchMutator( String, Class )
public static final java.lang.reflect.Method fetchMutator(java.lang.String property,
java.lang.Class cls)
throws java.beans.IntrospectionException
property - The property whose mutator is to be fetched.cls - The class to which the property belongs.
java.beans.IntrospectionException - If errors are encountered while
introspecting the specified class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||