org.filteredpush.rdf.reflection
Class ClassDeconstructor

java.lang.Object
  extended by org.filteredpush.rdf.reflection.ClassDeconstructor

public class ClassDeconstructor
extends java.lang.Object

Starting with a top-level class, works recursively on the tree of related classes (fields, methods, collections and sets) and stores java reflection information about how to access each classes members. Once initialized, can be used on an instance of the same top-level class to return all associated objects as a DeconstructedObjectGraph.

Author:
dlowery

Constructor Summary
ClassDeconstructor(java.lang.Class<?> clazz)
          Constructor will take the top-level class given as an argument and walk the tree recursively to find all classes and all their members.
 
Method Summary
 ClassMembers addClass(java.lang.Class<?> clazz)
          Add a class and its members if it does not already exist in the list, otherwise, return the members of the existing entry.
 DeconstructedObjectGraph deconstruct(java.lang.Object topLevelObj)
          Given an instance of the top-level class this ClassDeconstructor was initialized with, deconstruct the object and return a DeconstructedObjectGraph.
 DeconstructedObject getStaticClassInstance(java.lang.Class<?> clazz)
          If an instance of a class which is not in the package of the top-level class package is needed, this method can be used to create and return an instance of that class (assuming the constructor takes no arguments and fields/methods are static.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassDeconstructor

public ClassDeconstructor(java.lang.Class<?> clazz)
                   throws java.io.IOException,
                          java.lang.ClassNotFoundException
Constructor will take the top-level class given as an argument and walk the tree recursively to find all classes and all their members.

Parameters:
clazz -
Throws:
java.io.IOException
java.lang.ClassNotFoundException
Method Detail

addClass

public ClassMembers addClass(java.lang.Class<?> clazz)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException
Add a class and its members if it does not already exist in the list, otherwise, return the members of the existing entry.

Parameters:
clazz -
Returns:
class members object
Throws:
java.io.IOException
java.lang.ClassNotFoundException

deconstruct

public DeconstructedObjectGraph deconstruct(java.lang.Object topLevelObj)
                                     throws java.lang.IllegalArgumentException,
                                            java.lang.IllegalAccessException,
                                            java.lang.reflect.InvocationTargetException,
                                            java.lang.Exception
Given an instance of the top-level class this ClassDeconstructor was initialized with, deconstruct the object and return a DeconstructedObjectGraph.

Parameters:
topLevelObj -
Returns:
DeconstructedObjectGraph
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.Exception

getStaticClassInstance

public DeconstructedObject getStaticClassInstance(java.lang.Class<?> clazz)
                                           throws java.lang.InstantiationException,
                                                  java.lang.IllegalAccessException,
                                                  java.io.IOException,
                                                  java.lang.ClassNotFoundException
If an instance of a class which is not in the package of the top-level class package is needed, this method can be used to create and return an instance of that class (assuming the constructor takes no arguments and fields/methods are static.

Parameters:
clazz -
Returns:
DeconstructedObject
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.ClassNotFoundException