public class ClassCache extends java.lang.Object implements RevisionHandler
| Modifier and Type | Class and Description |
|---|---|
static class |
ClassCache.ClassFileFilter
For filtering classes.
|
static class |
ClassCache.DirectoryFilter
For filtering classes.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_PACKAGE
the key for the default package.
|
protected java.util.Hashtable<java.lang.String,java.util.HashSet<java.lang.String>> |
m_Cache
for caching all classes on the class path (package-name <-> HashSet
with classnames).
|
static boolean |
VERBOSE
whether to output some debug information.
|
| Constructor and Description |
|---|
ClassCache()
Initializes the cache.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.String classname)
Adds the classname to the cache.
|
static java.lang.String |
cleanUp(java.lang.String classname)
Fixes the classname, turns "/" and "\" into "." and removes ".class".
|
static java.lang.String |
extractPackage(java.lang.String classname)
Extracts the package name from the (clean) classname.
|
java.util.ArrayList<java.lang.String> |
find(java.lang.String matchText)
Find all classes that have the supplied matchText String in their suffix.
|
java.util.HashSet<java.lang.String> |
getClassnames(java.lang.String pkgname)
Returns all the classes for the given package.
|
java.lang.String |
getRevision()
Returns the revision string.
|
protected void |
initFromClasspathPart(java.lang.String part)
Analyzes a part of the classpath.
|
protected void |
initFromDir(java.io.File dir)
Fills the class cache with classes in the specified directory.
|
protected void |
initFromDir(java.lang.String prefix,
java.io.File dir)
Fills the class cache with classes in the specified directory.
|
protected void |
initFromJar(java.io.File file)
Fills the class cache with classes from the specified jar.
|
protected void |
initFromManifest(java.util.jar.Manifest manifest)
Analyzes the MANIFEST.MF file of a jar whether additional jars are listed
in the "Class-Path" key.
|
protected void |
initialize()
Initializes the cache.
|
protected void |
initializeNew() |
static void |
main(java.lang.String[] args)
For testing only.
|
java.util.Enumeration<java.lang.String> |
packages()
Returns all the stored packages.
|
boolean |
remove(java.lang.String classname)
Removes the classname from the cache.
|
public static final boolean VERBOSE
public static final java.lang.String DEFAULT_PACKAGE
protected java.util.Hashtable<java.lang.String,java.util.HashSet<java.lang.String>> m_Cache
public static java.lang.String cleanUp(java.lang.String classname)
classname - the classname to processpublic static java.lang.String extractPackage(java.lang.String classname)
classname - the classname to extract the package frompublic boolean add(java.lang.String classname)
classname - the classname, automatically removes ".class" and turns
"/" or "\" into "."public boolean remove(java.lang.String classname)
classname - the classname to removeprotected void initFromDir(java.lang.String prefix,
java.io.File dir)
prefix - the package prefix so far, null for default packagedir - the directory to searchprotected void initFromDir(java.io.File dir)
dir - the directory to searchprotected void initFromManifest(java.util.jar.Manifest manifest)
manifest - the manifest to analyzeprotected void initFromJar(java.io.File file)
file - the jar to inspectpublic java.util.Enumeration<java.lang.String> packages()
public java.util.HashSet<java.lang.String> getClassnames(java.lang.String pkgname)
pkgname - the package to get the classes forprotected void initFromClasspathPart(java.lang.String part)
part - the part to analyzeprotected void initialize()
protected void initializeNew()
public java.util.ArrayList<java.lang.String> find(java.lang.String matchText)
matchText - the text to matchpublic java.lang.String getRevision()
getRevision in interface RevisionHandlerpublic static void main(java.lang.String[] args)
args - ignored