ch.sahits.util
Class ClassFinder

java.lang.Object
  extended by ch.sahits.util.ClassFinder

public class ClassFinder
extends java.lang.Object

This class is a nice utility to retrive class Object that are anywhere on the classpath.

Version:
1.0
Author:
andi Hotz (c) Sahits.ch 2007

Constructor Summary
ClassFinder()
          Default constructur initializes the directories indicated by the CLASSPATH, if they are not yet initialized.
 
Method Summary
 java.lang.Class[] getAll(java.lang.String packageName)
          Retrive all classes of the indicated package.
 java.lang.Class[] getAll(java.lang.String packageName, java.lang.String jarFileName)
          Retrive all classes of the indicated package from the indicated jar file.
 java.lang.Class[] getAllRecursive(java.lang.String packageName)
          Retrive all classes of the indicated package and all subpackages.
 java.lang.Class[] getAllRecursive(java.lang.String packageName, java.lang.String jarFileName)
          Retrive all classes of the indicated package and all subpackages from the indicated jar file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFinder

public ClassFinder()
Default constructur initializes the directories indicated by the CLASSPATH, if they are not yet initialized.

Method Detail

getAll

public java.lang.Class[] getAll(java.lang.String packageName)
                         throws java.lang.ClassNotFoundException
Retrive all classes of the indicated package. The package is searched in all classpath directories that are directories

Parameters:
packageName - name of the package as 'ch.sahits.civ'
Returns:
Array of found classes
Throws:
java.lang.ClassNotFoundException

getAllRecursive

public java.lang.Class[] getAllRecursive(java.lang.String packageName)
                                  throws java.lang.ClassNotFoundException
Retrive all classes of the indicated package and all subpackages. The package is searched in all classpath directories that are directories

Parameters:
packageName - name of the package as 'ch.sahits.civ'
Returns:
Array of found classes
Throws:
java.lang.ClassNotFoundException

getAll

public java.lang.Class[] getAll(java.lang.String packageName,
                                java.lang.String jarFileName)
Retrive all classes of the indicated package from the indicated jar file. The package is searched in all classpath directories that are directories

Parameters:
packageName - name of the package as 'ch.sahits.civ'
jarFileName - name of the jar file
Returns:
Array of found classes
Throws:
java.lang.ClassNotFoundException

getAllRecursive

public java.lang.Class[] getAllRecursive(java.lang.String packageName,
                                         java.lang.String jarFileName)
Retrive all classes of the indicated package and all subpackages from the indicated jar file. The package is searched in all classpath directories that are directories

Parameters:
packageName - name of the package as 'ch.sahits.civ'
jarFileName - name of the jar file
Returns:
Array of found classes
Throws:
java.lang.ClassNotFoundException