|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--bsh.classpath.BshClassPath
A BshClassPath encapsulates knowledge about a class path of URLs. It can maps all classes the path which may include: jar/zip files and base dirs A BshClassPath may composite other BshClassPaths as components of its path and will reflect changes in those components through its methods and listener interface. Classpath traversal is done lazily when a call is made to getClassesForPackage() or getClassSource() or can be done explicitily through insureInitialized(). Feedback on mapping progress is provided through the MappingFeedback interface. Design notes: Several times here we traverse ourselves and our component paths to produce a composite view of some thing relating to the path. This would be an opportunity for a visitor pattern.
Nested Class Summary | |
static class |
BshClassPath.AmbiguousName
|
static class |
BshClassPath.ClassSource
|
static class |
BshClassPath.DirClassSource
|
static class |
BshClassPath.JarClassSource
|
static interface |
BshClassPath.MappingFeedback
|
(package private) static class |
BshClassPath.UnqualifiedNameTable
|
Nested classes inherited from class bsh.NameSource |
NameSource.Listener |
Field Summary | |
(package private) static BshClassPath |
bootClassPath
|
private java.util.Map |
classSource
Map of source (URL or File dir) of every clas |
private java.util.List |
compPaths
Ordered list of components BshClassPaths |
(package private) java.util.Vector |
listeners
|
(package private) static BshClassPath.MappingFeedback |
mappingFeedbackListener
only allow one for now |
private boolean |
mapsInitialized
The packageMap and classSource maps have been built. |
(package private) java.lang.String |
name
|
private boolean |
nameCompletionIncludesUnqNames
This used to be configurable, but now we always include them. |
(package private) java.util.List |
nameSourceListeners
|
private java.util.Map |
packageMap
Set of classes in a package mapped by package name |
private java.util.List |
path
The URL path components |
private BshClassPath.UnqualifiedNameTable |
unqNameTable
|
(package private) static BshClassPath |
userClassPath
|
(package private) static java.net.URL[] |
userClassPathComp
The user classpath from system property java.class.path |
Constructor Summary | |
BshClassPath(java.lang.String name)
|
|
BshClassPath(java.lang.String name,
java.net.URL[] urls)
|
Method Summary | |
void |
add(java.net.URL url)
|
void |
add(java.net.URL[] urls)
|
void |
addComponent(BshClassPath bcp)
Add the specified BshClassPath as a component of our path. |
void |
addListener(ClassPathListener l)
|
static void |
addMappingFeedback(BshClassPath.MappingFeedback mf)
|
void |
addNameSourceListener(NameSource.Listener listener)
Implements NameSource Add a listener who is notified upon changes to names in this space. |
private BshClassPath.UnqualifiedNameTable |
buildUnqualifiedNameTable()
|
static java.lang.String |
canonicalizeClassName(java.lang.String name)
Create a proper class name from a messy thing. |
(package private) void |
classMapping(java.lang.String msg)
|
void |
classPathChanged()
|
private void |
clearCachedStructures()
Clear anything cached. |
(package private) void |
endClassMapping()
|
(package private) void |
errorWhileMapping(java.lang.String s)
|
java.lang.String[] |
getAllNames()
|
static BshClassPath |
getBootClassPath()
Get the boot path including the lib/rt.jar if possible. |
java.util.Set |
getClassesForPackage(java.lang.String pack)
Return the set of class names in the specified package including all component paths. |
java.lang.String |
getClassNameByUnqName(java.lang.String name)
Support for super import "*"; Get the full name associated with the unqualified name in this classpath. |
BshClassPath.ClassSource |
getClassSource(java.lang.String className)
Return the source of the specified class which may lie in component path |
protected java.util.List |
getFullPath()
Get the full path including component paths. |
java.util.Set |
getPackagesSet()
Get a list of all of the known packages |
java.net.URL[] |
getPathComponents()
Get the path components including any component paths. |
private BshClassPath.UnqualifiedNameTable |
getUnqualifiedNameTable()
|
static BshClassPath |
getUserClassPath()
A BshClassPath initialized to the user path from java.class.path |
static java.net.URL[] |
getUserClassPathComponents()
|
void |
insureInitialized()
If the claspath map is not initialized, do it now. |
protected void |
insureInitialized(boolean topPath)
|
static boolean |
isArchiveFileName(java.lang.String name)
|
static boolean |
isClassFileName(java.lang.String name)
|
static void |
main(java.lang.String[] args)
|
private void |
map(java.lang.String[] classes,
java.lang.Object source)
|
(package private) void |
map(java.net.URL url)
|
(package private) void |
map(java.net.URL[] urls)
call map(url) for each url in the array |
private void |
mapClass(java.lang.String className,
java.lang.Object source)
|
(package private) void |
nameSpaceChanged()
Fire the NameSourceListeners |
(package private) void |
notifyListeners()
|
static java.util.Collection |
removeInnerClassNames(java.util.Collection col)
Return a new collection without any inner class names |
void |
removeListener(ClassPathListener l)
|
private void |
reset()
Clear everything and reset the path to empty. |
(package private) static java.lang.String[] |
searchJarForClasses(java.net.URL jar)
Get the class file entries from the Jar |
void |
setPath(java.net.URL[] urls)
|
static java.lang.String[] |
splitClassname(java.lang.String classname)
Split class name into package and name |
(package private) void |
startClassMapping()
|
java.lang.String |
toString()
|
(package private) static java.lang.String[] |
traverseDirForClasses(java.io.File dir)
|
(package private) static java.util.List |
traverseDirForClassesAux(java.io.File topDir,
java.io.File dir)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
java.lang.String name
private java.util.List path
private java.util.List compPaths
private java.util.Map packageMap
private java.util.Map classSource
private boolean mapsInitialized
private BshClassPath.UnqualifiedNameTable unqNameTable
private boolean nameCompletionIncludesUnqNames
java.util.Vector listeners
static java.net.URL[] userClassPathComp
static BshClassPath userClassPath
static BshClassPath bootClassPath
java.util.List nameSourceListeners
static BshClassPath.MappingFeedback mappingFeedbackListener
Constructor Detail |
public BshClassPath(java.lang.String name)
public BshClassPath(java.lang.String name, java.net.URL[] urls)
Method Detail |
public void setPath(java.net.URL[] urls)
public void addComponent(BshClassPath bcp)
public void add(java.net.URL[] urls)
public void add(java.net.URL url) throws java.io.IOException
java.io.IOException
public java.net.URL[] getPathComponents()
public java.util.Set getClassesForPackage(java.lang.String pack)
public BshClassPath.ClassSource getClassSource(java.lang.String className)
public void insureInitialized()
protected void insureInitialized(boolean topPath)
topPath
- indicates that this is the top level classpath
component and it should send the startClassMapping messageprotected java.util.List getFullPath()
public java.lang.String getClassNameByUnqName(java.lang.String name) throws ClassPathException
ClassPathException
private BshClassPath.UnqualifiedNameTable getUnqualifiedNameTable()
private BshClassPath.UnqualifiedNameTable buildUnqualifiedNameTable()
public java.lang.String[] getAllNames()
getAllNames
in interface NameSource
void map(java.net.URL[] urls)
void map(java.net.URL url) throws java.io.IOException
java.io.IOException
private void map(java.lang.String[] classes, java.lang.Object source)
private void mapClass(java.lang.String className, java.lang.Object source)
private void reset()
private void clearCachedStructures()
public void classPathChanged()
classPathChanged
in interface ClassPathListener
static java.lang.String[] traverseDirForClasses(java.io.File dir) throws java.io.IOException
java.io.IOException
static java.util.List traverseDirForClassesAux(java.io.File topDir, java.io.File dir) throws java.io.IOException
java.io.IOException
static java.lang.String[] searchJarForClasses(java.net.URL jar) throws java.io.IOException
java.io.IOException
public static boolean isClassFileName(java.lang.String name)
public static boolean isArchiveFileName(java.lang.String name)
public static java.lang.String canonicalizeClassName(java.lang.String name)
public static java.lang.String[] splitClassname(java.lang.String classname)
public static java.util.Collection removeInnerClassNames(java.util.Collection col)
public static java.net.URL[] getUserClassPathComponents() throws ClassPathException
ClassPathException
public java.util.Set getPackagesSet()
public void addListener(ClassPathListener l)
public void removeListener(ClassPathListener l)
void notifyListeners()
public static BshClassPath getUserClassPath() throws ClassPathException
ClassPathException
public static BshClassPath getBootClassPath() throws ClassPathException
ClassPathException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
void nameSpaceChanged()
public void addNameSourceListener(NameSource.Listener listener)
addNameSourceListener
in interface NameSource
public static void addMappingFeedback(BshClassPath.MappingFeedback mf)
void startClassMapping()
void classMapping(java.lang.String msg)
void errorWhileMapping(java.lang.String s)
void endClassMapping()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |