org.jaffa.persistence.engines.jdbcengine.util
Class Introspection

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.util.Introspection

public class Introspection
extends Object

Helper class for introspecting Domain objects.


Constructor Summary
Introspection()
           
 
Method Summary
static Field getAccessibleField(Class clazz, String fieldName, Class datatype)
          This method will introspect the input class for for a Field object having the same name as the input fieldName.
static Method getAccessorMethod(Class clazz, String fieldName, Class datatype)
          This method will introspect the input class for an accessor Method object - getFieldName() or isFieldName() If no Method is found, then it'll recursively call itself for each parent class.
static Map getAccessors(Class clazz, Map fields, Map members)
          This will introspect the input Class for an AccessibleObject, for each of the input fieldName passed in the 'fields' Map.
static Method getMutatorMethod(Class clazz, String fieldName, Class datatype)
          This method will introspect the input class for a mutator Method object - setFieldName().
static Map getMutators(Class clazz, Map fields, Map members)
          This will introspect the input Class for an AccessibleObject, for each of the input fieldName passed in the 'fields' Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Introspection

public Introspection()
Method Detail

getAccessors

public static Map getAccessors(Class clazz,
                               Map fields,
                               Map members)
This will introspect the input Class for an AccessibleObject, for each of the input fieldName passed in the 'fields' Map. For each fieldName, this method will introspect the input class for an AccessibleObject in the following order. 1- If an entry exists for the fieldName in the members Map, search for a Field object having the same name as that memberName 2- Else search for a Method object - getFieldName() or isFieldName() 3- If no AccessibleObject is found, then recursively call itself for each parent class. It will return a Map of key=fieldName/value=Field/Method object pairs. The returnType of the Field/Method will have to match the type passed in the input 'fields' Map. NOTE: An inaccessible Field/Method will be forced to be accessible !! No exception is raised, in case an appropriate method is not found for a fieldName. The calling class can always compare the size of the input Map with the Map returned by this method, and raise suitable exceptions.

Parameters:
clazz - The class to be introspected.
fields - The key of this HashMap is the name of the field (String) and the value is the data type (String).
members - This map will contain the fields which are to be introspected by using member variables as opposed to getters/setters. The key of this HashMap is the name of the field (String) and the value is the memberName (String).
Returns:
a map of key=fieldName/value=Field/Method object pairs.

getMutators

public static Map getMutators(Class clazz,
                              Map fields,
                              Map members)
This will introspect the input Class for an AccessibleObject, for each of the input fieldName passed in the 'fields' Map. For each fieldName, this method will introspect the input class for an AccessibleObject in the following order. 1- If an entry exists for the fieldName in the members Map, search for a Field object having the same name as that memberName 2- Else search for a Method object - setFieldName(Object obj) 3- If no AccessibleObject is found, then recursively call itself for each parent class. It will return a Map of key=fieldName/value=Field/Method object pairs. The returnType/paramter of the Field/Method will have to match the type passed in the input 'fields' Map. NOTE: An inaccessible Field/Method will be forced to be accessible !! No exception is raised, in case an appropriate method is not found for a fieldName. The calling class can always compare the size of the input Map with the Map returned by this method, and raise suitable exceptions.

Parameters:
clazz - The class to be introspected.
fields - The key of this HashMap is the name of the field (String) and the value is the data type (String).
members - This map will contain the fields which are to be introspected by using member variables as opposed to getters/setters. The key of this HashMap is the name of the field (String) and the value is the memberName (String).
Returns:
a map of key=fieldName/value=Field/Method object pairs.

getAccessibleField

public static Field getAccessibleField(Class clazz,
                                       String fieldName,
                                       Class datatype)
This method will introspect the input class for for a Field object having the same name as the input fieldName. If no Field is found, then it'll recursively call itself for each parent class. NOTE: An inaccessible Field will be forced to be accessible !!

Parameters:
clazz - The class to be introspected.
fieldName - The fieldName for which the Field object is to be found.
datatype - This is an optional input. If passed then it'll ensure that the Field object has the correct signature.
Returns:
the for a Field object having the same name as the input fieldName. A null is returned, in case the field doesn't exist.

getAccessorMethod

public static Method getAccessorMethod(Class clazz,
                                       String fieldName,
                                       Class datatype)
This method will introspect the input class for an accessor Method object - getFieldName() or isFieldName() If no Method is found, then it'll recursively call itself for each parent class. NOTE: An inaccessible Method will be forced to be accessible !!

Parameters:
clazz - The class to be introspected.
fieldName - The fieldName for which the accessor is to be found.
datatype - This is an optional input. If passed then it'll ensure that the accessor has the correct signature.
Returns:
the accessor Method for the property. A null is returned, in case the property doesn't exist.

getMutatorMethod

public static Method getMutatorMethod(Class clazz,
                                      String fieldName,
                                      Class datatype)
This method will introspect the input class for a mutator Method object - setFieldName(). If no Method is found, then it'll recursively call itself for each parent class. NOTE: An inaccessible Method will be forced to be accessible !!

Parameters:
clazz - The class to be introspected.
fieldName - The fieldName for which the mutator is to be found.
datatype - This is an optional input. If passed then it'll ensure that the mutator has the correct signature.
Returns:
the mutator Method for the property. A null is returned, in case the property doesn't exist.


Copyright © 2002-2004 JAFFA Project.