org.sape.carbon.core.util.reflection
Class ClassTree

java.lang.Object
  |
  +--org.sape.carbon.core.util.reflection.ClassTree

public class ClassTree
extends Object

This class creates a tree structure that maps inheritance hierarchies of classes. A developer can place any number of classes into this object and retrieve the closest super class or the class itself.

Copyright 2001 Sapient

Since:
EJFW 2.7
Version:
$Revision: 1.4 $($Author: dvoet $ / $Date: 2003/05/05 21:21:23 $)
Author:
Greg Hinkle, January 2001

Nested Class Summary
static class ClassTree.ClassTreeNode
          Inner class representing each node in the tree.
 
Field Summary
protected  ClassTree.ClassTreeNode bottom
           
 
Constructor Summary
ClassTree(Class specificClass)
          Constructs a ClassTree that represents all classes and interfaces that are generalizations of the provided class.
 
Method Summary
private  void buildList(ClassTree.ClassTreeNode node, List output)
          Build breadth first in order to maintain sudo ordering as per class declarations (i.e.
 ClassTree.ClassTreeNode getBottom()
           
 List getOrderedList()
          Constructs an ordered list starting at the highest (most general) class in the tree and moving down the tree, ensuring no generalization comes after one of its specializations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bottom

protected ClassTree.ClassTreeNode bottom
Constructor Detail

ClassTree

public ClassTree(Class specificClass)
Constructs a ClassTree that represents all classes and interfaces that are generalizations of the provided class. This ends up with a tree structure of the inheritance hierarchy for that provided class all the way up to java.lang.Object.

Parameters:
specificClass - The class to build the tree for.
Method Detail

getBottom

public ClassTree.ClassTreeNode getBottom()

getOrderedList

public List getOrderedList()
Constructs an ordered list starting at the highest (most general) class in the tree and moving down the tree, ensuring no generalization comes after one of its specializations.

Returns:
a list ordered as above

buildList

private void buildList(ClassTree.ClassTreeNode node,
                       List output)

Build breadth first in order to maintain sudo ordering as per class declarations (i.e. if A implements B, C... B is closer in the chain to A than C is, because B comes first in the implements clause.

Note that the list coming out here is preordered, but not natural ordered. (i.e. some classes are out of order in relation to classes they have direct relationships with. This is later fixed by a sort on the list by natural ordering. Collecitons.sort, does preserve the preordering for nodes that have no relationship.

Parameters:
node - the node to be browsed.
output - this list is altered to add the contents as they are browsed in breadth-first order. Start with a list containing only the bottom node.


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.