org.gjt.rec.version
Class RevisionIntrospector

java.lang.Object
  |
  +--org.gjt.rec.version.RevisionIntrospector

public final class RevisionIntrospector
extends Object

Author:
Neil Stockbridge

Nested Class Summary
static class RevisionIntrospector.Exception
           
static class RevisionIntrospector.UnexpectedFieldTypeException
           
 
Field Summary
static String COPYRIGHT
           
static String LICENSE
           
static String REVISION
           
 
Method Summary
static ClassRevision inspectClass(String className)
           
static ClassRevision inspectClass(String className, ClassLoader classLoader)
           
static List inspectClassPath(String classPathString)
           
static List inspectClassPath(String classPathString, ClassLoader classLoader)
          Scans a particular class path, using a particular class loader to load the classes and look in each for a static field of type String named REVISION and build a list of (className, revision) tuples.
static void inspectFile(String filePath, ClassLoader classLoader, Collection classRevisions)
          Tries to inspect all classes in a particular file, loading all classes for inspection on a particular class loader and adding the ClassRevision objects to a particular list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final String COPYRIGHT
See Also:
Constant Field Values

LICENSE

public static final String LICENSE
See Also:
Constant Field Values

REVISION

public static final String REVISION
See Also:
Constant Field Values
Method Detail

inspectClass

public static ClassRevision inspectClass(String className)

inspectClass

public static ClassRevision inspectClass(String className,
                                         ClassLoader classLoader)

inspectFile

public static void inspectFile(String filePath,
                               ClassLoader classLoader,
                               Collection classRevisions)
Tries to inspect all classes in a particular file, loading all classes for inspection on a particular class loader and adding the ClassRevision objects to a particular list. If there is a problem inspecting a class, a ClassRevision will be added for it, but the revision will be the empty string.

Parameters:
filePath - the path to the file that contains the class to be inspected
classLoader - the class loader to load the classes on
classRevisions - the list to add the ClassRevision objects to
Throws:
NullPointerException - if any of the arguments are null
RevisionIntrospector.Exception - if there is a problem reading the file

inspectClassPath

public static List inspectClassPath(String classPathString)
See Also:
inspectClassPath(String, ClassLoader)

inspectClassPath

public static List inspectClassPath(String classPathString,
                                    ClassLoader classLoader)
Scans a particular class path, using a particular class loader to load the classes and look in each for a static field of type String named REVISION and build a list of (className, revision) tuples. If an element of the class path is of an unknown type, this method will throw an exception. Weed such elements out and log them in application code.

Parameters:
classPathString - separated path of file locations. Each location can be a folder, a JAR or a ZIP
classLoader - the class loader on which to load the classes. If no class loader is specified in the overloaded version of this method, a new one will be used so that loaded classes can be unloaded afterwards
Throws:
NullPointerException - if classPathString is null