edu.umd.cs.findbugs.ba.type
Class SubtypeQueryResult

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.type.SubtypeQueryResult

public class SubtypeQueryResult
extends java.lang.Object

Class to cache the result of an isSubtype() query so future lookups are fast. Also caches a complete list of supertypes in BFS order.

Author:
David Hovemeyer
See Also:
TypeRepository

Field Summary
private static java.lang.String[] emptyList
           
private  java.lang.String[] missingClassList
           
private  java.util.ArrayList<ObjectType> supertypeListInBFSOrder
           
private  java.util.BitSet supertypeSet
           
 
Constructor Summary
SubtypeQueryResult()
          Constructor.
 
Method Summary
 void addSupertype(ObjectType supertype)
          Set given ObjectType as a supertype.
 void finish(java.lang.String[] missingClassList)
          Mark the object as complete.
 java.util.Set<ObjectType> getSupertypeSet(ObjectType subtype, TypeRepository repos)
          Get set of supertypes.
 boolean isSupertype(ObjectType type)
          Check to see if given ObjectType is a supertype.
 java.util.Iterator<ObjectType> supertypeInBFSOrderIterator()
          Get iterator over supertypes in BFS order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supertypeSet

private java.util.BitSet supertypeSet

supertypeListInBFSOrder

private java.util.ArrayList<ObjectType> supertypeListInBFSOrder

missingClassList

private java.lang.String[] missingClassList

emptyList

private static final java.lang.String[] emptyList
Constructor Detail

SubtypeQueryResult

public SubtypeQueryResult()
Constructor.

Method Detail

addSupertype

public void addSupertype(ObjectType supertype)
Set given ObjectType as a supertype. This method should be called on supertypes in breadth-first order. This allows first-common-superclass searches to be performed using a linear search of the supertypes in BFS order.

Parameters:
supertype - the supertype

finish

public void finish(java.lang.String[] missingClassList)
Mark the object as complete.

Parameters:
missingClassList - the list of names of missing classes

isSupertype

public boolean isSupertype(ObjectType type)
                    throws java.lang.ClassNotFoundException
Check to see if given ObjectType is a supertype.

Parameters:
type - potential supertype
Returns:
true if type is a supertype, false otherwise
Throws:
java.lang.ClassNotFoundException

getSupertypeSet

public java.util.Set<ObjectType> getSupertypeSet(ObjectType subtype,
                                                 TypeRepository repos)
                                          throws java.lang.ClassNotFoundException
Get set of supertypes. This is all supertypes including the object type itself.

Parameters:
subtype - the subtype (for which this object stores the set of supertypes)
repos - the TypeRepository
Returns:
the set of supertypes (a new object, can be modified)
Throws:
java.lang.ClassNotFoundException

supertypeInBFSOrderIterator

public java.util.Iterator<ObjectType> supertypeInBFSOrderIterator()
Get iterator over supertypes in BFS order.