classUtils.pack.util
Interface ClassPackageExplorer

All Known Implementing Classes:
SimpleClassPackageExplorer

public interface ClassPackageExplorer

Classes implementing this interface can explore the classpath, retrieving the contents of Java packages and enumerate the classes therein.

Multiple jars or directories containing different classes in the same package are supported.

However, different jars and directories containing the same class are not.

Author:
Cristiano Sadun

Field Summary
static int IN_DIRECTORY
          Status constant mask, indicating that a certain package is found in a directory.
static int IN_JAR
          Status constant mask, indicating that a certain package is found in a jar file.
static int IN_JAR_SEALED
          Status constant mask, indicating that a certain package is found in a jar file and is sealed.
 
Method Summary
 java.lang.String getErrorLog()
          Return an error status for the explorer.
 java.io.File[] getPackageFiles(java.lang.String packageName)
          Return the one or more files or directories where a package lives.
 int getStatus(java.lang.String packageName)
          Return information on whether the package lives in a directory, a jar file, a sealed jar file or a combination.
 boolean hasErrorOccurred()
          Return an error status for the explorer.
 java.lang.String[] listPackage(java.lang.String packageName)
          Return the names of all the classes in the package.
 java.lang.String[] listPackage(java.lang.String packageName, int status)
          Return the names of the classes in the package.
 java.lang.String[] listPackageNames()
          List the available packages.
 java.lang.String[] listPackageNames(boolean rescan)
          List the available packages.
 

Field Detail

IN_DIRECTORY

static final int IN_DIRECTORY
Status constant mask, indicating that a certain package is found in a directory.

See Also:
getStatus(java.lang.String), Constant Field Values

IN_JAR

static final int IN_JAR
Status constant mask, indicating that a certain package is found in a jar file.

See Also:
getStatus(java.lang.String), Constant Field Values

IN_JAR_SEALED

static final int IN_JAR_SEALED
Status constant mask, indicating that a certain package is found in a jar file and is sealed.

See Also:
getStatus(java.lang.String), Constant Field Values
Method Detail

listPackageNames

java.lang.String[] listPackageNames()
List the available packages. The classpath is scanned for classes, and each package is reported. This can take a long time on first invocation.

Returns:
a list of package names

listPackageNames

java.lang.String[] listPackageNames(boolean rescan)
List the available packages. The classpath is scanned for classes, and each package is reported.

This can take a long time on first invocation or if rescan is true.

Parameters:
rescan - forces a re-scanning
Returns:
a list of package names

listPackage

java.lang.String[] listPackage(java.lang.String packageName,
                               int status)
Return the names of the classes in the package.

Parameters:
packageName - the name of the package
status - bit mask (see status constant masks) indicating which files to list.
Returns:
the names of the classes in the package.

listPackage

java.lang.String[] listPackage(java.lang.String packageName)
Return the names of all the classes in the package. This can take a long time on first invocation.

Parameters:
packageName - the name of the package
Returns:
the names of all the classes in the package.

getStatus

int getStatus(java.lang.String packageName)
Return information on whether the package lives in a directory, a jar file, a sealed jar file or a combination.

This can take a long time on first invocation.

Parameters:
packageName - the name of the package
Returns:
the distribution status for the given package, or -1 if the given package does not exist.

getPackageFiles

java.io.File[] getPackageFiles(java.lang.String packageName)
Return the one or more files or directories where a package lives.

This can take a long time on first invocation.

Parameters:
packageName - the name of the package
Returns:
the files containing classes belonging to the given package.

hasErrorOccurred

boolean hasErrorOccurred()
Return an error status for the explorer.

Returns:
true if an error has occurred while exploring the class path.

getErrorLog

java.lang.String getErrorLog()
Return an error status for the explorer.