org.neodatis.odb.impl.core.layers.layer1.introspector
Class AbstractClassIntrospector

java.lang.Object
  extended by org.neodatis.odb.impl.core.layers.layer1.introspector.AbstractClassIntrospector
All Implemented Interfaces:
ITwoPhaseInit, IClassIntrospector
Direct Known Subclasses:
AndroidClassIntrospector, DefaultClassIntrospector

public abstract class AbstractClassIntrospector
extends java.lang.Object
implements IClassIntrospector

The ClassIntrospector is used to introspect classes. It uses Reflection to extract class information. It transforms a native Class into a ClassInfo (a meta representation of the class) that contains all informations about the class.

Author:
osmadja

Constructor Summary
AbstractClassIntrospector()
           
 
Method Summary
protected  void addConstructor(java.lang.String className, java.lang.reflect.Constructor constructor)
           
 void addFullInstanciationHelper(java.lang.Class clazz, FullInstantiationHelper helper)
           
 void addFullInstantiationHelper(java.lang.String clazz, FullInstantiationHelper helper)
           
 void addInstanciationHelper(java.lang.Class clazz, InstantiationHelper helper)
           
 void addInstantiationHelper(java.lang.String clazz, InstantiationHelper helper)
           
 void addParameterHelper(java.lang.Class clazz, ParameterHelper helper)
           
 void addParameterHelper(java.lang.String clazz, ParameterHelper helper)
           
 IOdbList<java.lang.reflect.Field> getAllFields(java.lang.String fullClassName)
           
 byte getClassCategory(java.lang.String fullClassName)
           
 ClassInfo getClassInfo(java.lang.String fullClassName, ClassInfo existingClassInfo)
          Builds a class info from a class and an existing class info
 java.lang.reflect.Constructor getConstructorOf(java.lang.String fullClassName)
           
 java.lang.reflect.Field getField(java.lang.Class clazz, java.lang.String fieldName)
           
 java.util.List<java.lang.Class> getSuperClasses(java.lang.String fullClassName, boolean includingThis)
           
 void init2()
          Two phase init method
 java.util.Map<java.lang.String,ClassInfo> instrospect(IOdbList<ClassInfo> classInfos)
          introspect a list of classes This method return the current meta model based on the classes that currently exist in the execution classpath.
 ClassInfoList introspect(java.lang.Class clazz, boolean recursive)
           
 ClassInfoList introspect(java.lang.String fullClassName, boolean recursive)
           
 boolean isSystemClass(java.lang.String fullClassName)
           
 java.lang.Object newFullInstanceOf(java.lang.Class clazz, NonNativeObjectInfo nnoi)
           
 java.lang.Object newInstanceOf(java.lang.Class clazz)
           
 void persistFieldOfClass(java.lang.String className, java.lang.String fieldName, boolean yesNo)
          To force persisting a field or to avoid a field from being persiste
 void removeFullInstantiationHelper(java.lang.Class clazz)
           
 void removeFullInstantiationHelper(java.lang.String canonicalName)
           
 void removeInstantiationHelper(java.lang.Class clazz)
           
 void removeInstantiationHelper(java.lang.String canonicalName)
           
 void removeParameterHelper(java.lang.Class clazz)
           
 void removeParameterHelper(java.lang.String canonicalName)
           
 IOdbList<java.lang.reflect.Field> removeUnnecessaryFields(java.lang.String className, IOdbList<java.lang.reflect.Field> fields)
           
 void reset()
           
protected abstract  boolean tryToCreateAnEmptyConstructor(java.lang.Class clazz)
          Tries to create a default constructor (with no parameter) for the class and stores it the constructor cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractClassIntrospector

public AbstractClassIntrospector()
Method Detail

reset

public void reset()
Specified by:
reset in interface IClassIntrospector

init2

public void init2()
Two phase init method

Specified by:
init2 in interface ITwoPhaseInit

addInstanciationHelper

public void addInstanciationHelper(java.lang.Class clazz,
                                   InstantiationHelper helper)
Specified by:
addInstanciationHelper in interface IClassIntrospector

addParameterHelper

public void addParameterHelper(java.lang.Class clazz,
                               ParameterHelper helper)
Specified by:
addParameterHelper in interface IClassIntrospector

addFullInstanciationHelper

public void addFullInstanciationHelper(java.lang.Class clazz,
                                       FullInstantiationHelper helper)
Specified by:
addFullInstanciationHelper in interface IClassIntrospector

addInstantiationHelper

public void addInstantiationHelper(java.lang.String clazz,
                                   InstantiationHelper helper)
Specified by:
addInstantiationHelper in interface IClassIntrospector

addParameterHelper

public void addParameterHelper(java.lang.String clazz,
                               ParameterHelper helper)
Specified by:
addParameterHelper in interface IClassIntrospector

addFullInstantiationHelper

public void addFullInstantiationHelper(java.lang.String clazz,
                                       FullInstantiationHelper helper)
Specified by:
addFullInstantiationHelper in interface IClassIntrospector

removeInstantiationHelper

public void removeInstantiationHelper(java.lang.Class clazz)
Specified by:
removeInstantiationHelper in interface IClassIntrospector

removeInstantiationHelper

public void removeInstantiationHelper(java.lang.String canonicalName)
Specified by:
removeInstantiationHelper in interface IClassIntrospector

removeParameterHelper

public void removeParameterHelper(java.lang.Class clazz)
Specified by:
removeParameterHelper in interface IClassIntrospector

removeParameterHelper

public void removeParameterHelper(java.lang.String canonicalName)
Specified by:
removeParameterHelper in interface IClassIntrospector

removeFullInstantiationHelper

public void removeFullInstantiationHelper(java.lang.Class clazz)
Specified by:
removeFullInstantiationHelper in interface IClassIntrospector

removeFullInstantiationHelper

public void removeFullInstantiationHelper(java.lang.String canonicalName)
Specified by:
removeFullInstantiationHelper in interface IClassIntrospector

introspect

public ClassInfoList introspect(java.lang.Class clazz,
                                boolean recursive)
Specified by:
introspect in interface IClassIntrospector
Parameters:
clazz - The class to instrospect
recursive - If true, goes does the hierarchy to try to analyse all classes
Returns:
The list of class info detected while introspecting the class

instrospect

public java.util.Map<java.lang.String,ClassInfo> instrospect(IOdbList<ClassInfo> classInfos)
introspect a list of classes This method return the current meta model based on the classes that currently exist in the execution classpath. The result will be used to check meta model compatiblity between the meta model that is currently persisted in the database and the meta model currently executing in JVM. This is used b the automatic meta model refactoring

Specified by:
instrospect in interface IClassIntrospector
Parameters:
classInfos, - the classinfo currently existng in the meta model
Returns:

getClassInfo

public ClassInfo getClassInfo(java.lang.String fullClassName,
                              ClassInfo existingClassInfo)
Description copied from interface: IClassIntrospector
Builds a class info from a class and an existing class info
 The existing class info is used to make sure that fields with the same name will have
 the same id
 

Specified by:
getClassInfo in interface IClassIntrospector
Parameters:
fullClassName - The name of the class to get info
Returns:
A ClassInfo - a meta representation of the class

getSuperClasses

public java.util.List<java.lang.Class> getSuperClasses(java.lang.String fullClassName,
                                                       boolean includingThis)
Specified by:
getSuperClasses in interface IClassIntrospector
Returns:
The list of super classes

getField

public java.lang.reflect.Field getField(java.lang.Class clazz,
                                        java.lang.String fieldName)
Specified by:
getField in interface IClassIntrospector

getAllFields

public IOdbList<java.lang.reflect.Field> getAllFields(java.lang.String fullClassName)
Specified by:
getAllFields in interface IClassIntrospector

removeUnnecessaryFields

public IOdbList<java.lang.reflect.Field> removeUnnecessaryFields(java.lang.String className,
                                                                 IOdbList<java.lang.reflect.Field> fields)
Specified by:
removeUnnecessaryFields in interface IClassIntrospector

introspect

public ClassInfoList introspect(java.lang.String fullClassName,
                                boolean recursive)
Specified by:
introspect in interface IClassIntrospector

getConstructorOf

public java.lang.reflect.Constructor getConstructorOf(java.lang.String fullClassName)
Specified by:
getConstructorOf in interface IClassIntrospector

newFullInstanceOf

public java.lang.Object newFullInstanceOf(java.lang.Class clazz,
                                          NonNativeObjectInfo nnoi)
Specified by:
newFullInstanceOf in interface IClassIntrospector

newInstanceOf

public java.lang.Object newInstanceOf(java.lang.Class clazz)
Specified by:
newInstanceOf in interface IClassIntrospector

tryToCreateAnEmptyConstructor

protected abstract boolean tryToCreateAnEmptyConstructor(java.lang.Class clazz)
Tries to create a default constructor (with no parameter) for the class and stores it the constructor cache.

Parameters:
clazz -
Returns:

isSystemClass

public boolean isSystemClass(java.lang.String fullClassName)
Specified by:
isSystemClass in interface IClassIntrospector

getClassCategory

public byte getClassCategory(java.lang.String fullClassName)
Specified by:
getClassCategory in interface IClassIntrospector

addConstructor

protected void addConstructor(java.lang.String className,
                              java.lang.reflect.Constructor constructor)

persistFieldOfClass

public void persistFieldOfClass(java.lang.String className,
                                java.lang.String fieldName,
                                boolean yesNo)
Description copied from interface: IClassIntrospector
To force persisting a field or to avoid a field from being persiste
 

Specified by:
persistFieldOfClass in interface IClassIntrospector