jfreerails.util
Class ClassPath

java.lang.Object
  extended by jfreerails.util.ClassPath

public class ClassPath
extends java.lang.Object

ClassPath finds and records the fully qualified name of every Class on the classpath via the system property "java.class.path".

Based on original prototype by duncanIdaho for javagaming.org.

Author:
adam@jgf

Field Summary
protected  java.util.LinkedList<java.io.File> jarsThatHAveAlreadyBeenProcessed
           
protected  java.util.logging.Logger logger
           
protected  java.util.LinkedList<java.lang.String> pathElementsThatHaveAlreadyBeenProcessed
           
 
Constructor Summary
ClassPath()
          create a new ClassPath instance and find all classes on the classpath
 
Method Summary
protected  java.lang.String convertToClass(java.io.File classFile)
           
protected  java.util.LinkedList<java.lang.String> findPathElementsInJar(java.util.jar.Manifest man, java.util.jar.JarFile jar, java.io.File jarFile)
          Finds all path elements in the supplied JAR and returns them as a list
 java.util.List getAllClassNames()
           
private  java.lang.String getClassNameFrom(java.lang.String entryName)
          replace ANY slashes with dots and remove the .class at the end of the file name.
protected  java.util.LinkedList<java.lang.String> getDirectoryContents(java.io.File dir)
          This method takes a top level classpath dir i.e.
protected  java.util.LinkedList<java.lang.String> getDirectoryContents(java.lang.String pathTo, java.io.File dir)
          This method does the real directory recursion, passing along the the corresponding package-path to this directory.
protected  java.util.LinkedList<java.lang.String> getZipContents(java.io.File zipFile)
          Adds all class names found in the zip mentioned
protected  java.util.LinkedList<java.lang.String> processPendingElement(java.lang.String pathElement)
          Clones the supplied list, then goes through it processing every element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected java.util.logging.Logger logger

pathElementsThatHaveAlreadyBeenProcessed

protected java.util.LinkedList<java.lang.String> pathElementsThatHaveAlreadyBeenProcessed

jarsThatHAveAlreadyBeenProcessed

protected java.util.LinkedList<java.io.File> jarsThatHAveAlreadyBeenProcessed
Constructor Detail

ClassPath

public ClassPath()
create a new ClassPath instance and find all classes on the classpath

Method Detail

getAllClassNames

public java.util.List getAllClassNames()

processPendingElement

protected java.util.LinkedList<java.lang.String> processPendingElement(java.lang.String pathElement)
Clones the supplied list, then goes through it processing every element.


convertToClass

protected java.lang.String convertToClass(java.io.File classFile)
Parameters:
classFile - a class file listed on the classpath itself.

getClassNameFrom

private java.lang.String getClassNameFrom(java.lang.String entryName)
replace ANY slashes with dots and remove the .class at the end of the file name.

Parameters:
entryName - a file name relative to the classpath. A class of package org found in directory bin would be passed into this method as "org/MyClass.class"
Returns:
a fully qualified Class name.

findPathElementsInJar

protected java.util.LinkedList<java.lang.String> findPathElementsInJar(java.util.jar.Manifest man,
                                                                       java.util.jar.JarFile jar,
                                                                       java.io.File jarFile)
Finds all path elements in the supplied JAR and returns them as a list

Parameters:
man - the manifest of the given jar
jar - the jar associated with the given manifest.

getZipContents

protected java.util.LinkedList<java.lang.String> getZipContents(java.io.File zipFile)
Adds all class names found in the zip mentioned

Parameters:
zipFile -

getDirectoryContents

protected java.util.LinkedList<java.lang.String> getDirectoryContents(java.io.File dir)
This method takes a top level classpath dir i.e. 'classes' or bin

Parameters:
dir -

getDirectoryContents

protected java.util.LinkedList<java.lang.String> getDirectoryContents(java.lang.String pathTo,
                                                                      java.io.File dir)
This method does the real directory recursion, passing along the the corresponding package-path to this directory.

Parameters:
pathTo - the preceding path to this directory
dir - a directory to search for class files