pt.digitalis.utils.inspection
Class ClasspathUtils

java.lang.Object
  extended by pt.digitalis.utils.inspection.ClasspathUtils

public final class ClasspathUtils
extends Object

This class provides classpath searching tools for classes and files. It provides an abstraction of the Java classpath making easier the access to class path resources.

Author:
Pedro Viegas pviegas@digitalis.pt, Rodrigo Gonçalves rgoncalves@digitalis.pt

Nested Class Summary
static interface ClasspathUtils.FilenameFilter
          Defines the behavior of a filter whose filtering criteria is file-name based.
 
Method Summary
static List<String> getClasspathClassNames()
          Returns an array of the classpath classes names.
static List<String> getClasspathFileNames()
          Returns the FQNs of all the classes on the classpath.
static List<String> getClasspathFileNames(ClasspathUtils.FilenameFilter filter)
          Returns an array of the classpath file names that match the given file name filter.
static List<String> getClasspathFileNamesWithExtension(String extension)
          Returns an array of the classpath files ending with a given extension/filename suffix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClasspathClassNames

public static List<String> getClasspathClassNames()
                                           throws ResourceNotFoundException
Returns an array of the classpath classes names. The method's return consists the class's FQN without the .class file extension, thus making it useful for object instantiation with the java.lang.Class.forName(String) method.

Returns:
a String array with the classpath classes names
Throws:
ResourceNotFoundException - if a Jar file can't be found or properly opened

getClasspathFileNamesWithExtension

public static List<String> getClasspathFileNamesWithExtension(String extension)
                                                       throws ResourceNotFoundException
Returns an array of the classpath files ending with a given extension/filename suffix.

Parameters:
extension - the file extension/suffix
Returns:
an array of the classpath files that match the criteria mentioned above
Throws:
ResourceNotFoundException - if a Jar file can't be found or properly opened

getClasspathFileNames

public static List<String> getClasspathFileNames(ClasspathUtils.FilenameFilter filter)
                                          throws ResourceNotFoundException
Returns an array of the classpath file names that match the given file name filter.

Parameters:
filter - the filter object
Returns:
an array of the classpath file names matching the applied criteria
Throws:
ResourceNotFoundException - if a Jar file can't be found or properly opened

getClasspathFileNames

public static List<String> getClasspathFileNames()
                                          throws ResourceNotFoundException
Returns the FQNs of all the classes on the classpath. Checks directories and Jar files.

Returns:
a list of the classpath classes names
Throws:
ResourceNotFoundException - if a Jar file can't be found or properly opened


Copyright © 2012 Digitalis Informática Lda. All Rights Reserved.