InterfaceClassFinder V1.0
by Matthew Ford
2009/01/06

au.com.forward.interfaceClassFinder
Class ClasspathScanner<T extends IClasspathProcessor>

java.lang.Object
  extended by au.com.forward.interfaceClassFinder.ClasspathScanner<T>

public class ClasspathScanner<T extends IClasspathProcessor>
extends java.lang.Object

This class scans the classpath and calls each consumer for each class found.


Field Summary
protected  java.util.concurrent.ConcurrentLinkedQueue<T> consumers
           
static java.lang.String DOT_CLASS
           
 
Constructor Summary
ClasspathScanner()
           
 
Method Summary
 void addConsumer(T consumer)
          Add a consumer to be called for each class found.
protected  void callConsumers(java.lang.String className, java.util.jar.JarEntry jarEntry, java.io.File jarFile)
          Call all consumers for this jar file entry.
Note: the consumer must open the file and find the jarEntry passed in.
protected  void callConsumers(java.lang.String className, java.lang.String rootDir, java.io.File classFile)
          Call all consumers for this class file.
 T[] getConsumers()
          Return an array of all the current consumers registered with this scanner.
Changes to this array does not add or remove consumers.
static void main(java.lang.String[] args)
          Main class that list all the classes on the classpath and looks for duplicates.
protected  void processFileDir(java.io.File f, java.lang.String packagePath, java.lang.String rootDir)
          Process a file or directory.
protected  void processJarFile(java.io.File f)
          Scan the jar file for .class files to check
 boolean removeConsumer(T consumer)
          Remove a consumer.
 void scanClassPath()
          Scan the classpath and calls the registered consumers for each class found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOT_CLASS

public static final java.lang.String DOT_CLASS
See Also:
Constant Field Values

consumers

protected java.util.concurrent.ConcurrentLinkedQueue<T extends IClasspathProcessor> consumers
Constructor Detail

ClasspathScanner

public ClasspathScanner()
Method Detail

addConsumer

public void addConsumer(T consumer)
Add a consumer to be called for each class found.

Parameters:
consumer - the consumer to add

removeConsumer

public boolean removeConsumer(T consumer)
Remove a consumer.

Parameters:
consumer - the consumer to remove (as determined by .equals() )
Returns:
true if consumer found and removed.

getConsumers

public T[] getConsumers()
Return an array of all the current consumers registered with this scanner.
Changes to this array does not add or remove consumers.

Returns:
array of current consumers.

scanClassPath

public void scanClassPath()
Scan the classpath and calls the registered consumers for each class found. Quietly ignores files listed on the classpath that do not exist.


processJarFile

protected void processJarFile(java.io.File f)
Scan the jar file for .class files to check

Parameters:
f - the jar file to scan

processFileDir

protected void processFileDir(java.io.File f,
                              java.lang.String packagePath,
                              java.lang.String rootDir)
Process a file or directory. Recursively processes directories found.

Parameters:
f - the file or directory to process
packagePath - the current package name
rootDir - the root directory
top - true if this is the top of the package.

callConsumers

protected void callConsumers(java.lang.String className,
                             java.lang.String rootDir,
                             java.io.File classFile)
Call all consumers for this class file.

Parameters:
className - the class name
rootDir - the root directory
classFile - the class file

callConsumers

protected void callConsumers(java.lang.String className,
                             java.util.jar.JarEntry jarEntry,
                             java.io.File jarFile)
Call all consumers for this jar file entry.
Note: the consumer must open the file and find the jarEntry passed in.

Parameters:
className - the class name
jarEntry - the jar entry
jarFile - the jar file

main

public static void main(java.lang.String[] args)
Main class that list all the classes on the classpath and looks for duplicates.

Parameters:
args - ignored

©2003-2009, Forward Computing and Control Pty. Ltd
ACN 003 669 994   NSW Australia
All Rights Reserved.