| 
 | org.netbeans.api.java/1 1.10.22 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.api.java.classpath.GlobalPathRegistry
public final class GlobalPathRegistry
Maintains a global registry of "interesting" classpaths of various kinds.
 You may add and remove different kinds of ClassPaths to the registry
 and listen to changes in them.
 
 It is permitted to register the same classpath more than once; unregistration
 keeps track of the number of registrations so that the operation is symmetric.
 However getPaths(java.lang.String) only ever returns one copy of the classpath, and
 listeners are only notified the first time a given classpath is added to the
 registry, or the last time it is removed.
 (Classpath identity is object identity, so there could be multiple paths
 returned that at the time share the same list of roots. There may also be
 several paths which contain some shared roots.)
 
The registry is not persisted between JVM sessions.
Intended usage patterns:
When a project is opened using
 ProjectOpenedHook it should add any paths
 it defines, i.e. paths it might return from a
 ClassPathProvider.
 When closed it should remove them.
The Fast Open feature of the editor and other features which
 require a global list of relevant sources should use getSourceRoots() or
 the equivalent.
The Javadoc Index Search feature and View →
 Documentation Indices submenu should operate on open Javadoc paths,
 meaning that Javadoc corresponding to registered compile and boot classpaths
 (according to JavadocForBinaryQuery).
Stack trace hyperlinking can use the global list of source paths
 to find sources, in case no more specific information about their origin is
 available. The same would be true of debugging: if the debugger cannot find
 Java-like sources using more precise means (SourceForBinaryQuery), it
 can use findResource(java.lang.String) as a fallback.
| Method Summary | |
|---|---|
|  void | addGlobalPathRegistryListener(GlobalPathRegistryListener l)Add a listener to the registry. | 
|  FileObject | findResource(String resource)Convenience method to find a particular source file by resource path. | 
| static GlobalPathRegistry | getDefault()Get the singleton instance of the registry. | 
|  Set | getPaths(String id)Find all paths of a certain type. | 
|  Set | getSourceRoots()Convenience method to find all relevant source roots. | 
|  void | register(String id,
         ClassPath[] paths)Register some classpaths of a certain type. | 
|  void | removeGlobalPathRegistryListener(GlobalPathRegistryListener l)Remove a listener to the registry. | 
|  void | unregister(String id,
           ClassPath[] paths)Unregister some classpaths of a certain type. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Method Detail | 
|---|
public static GlobalPathRegistry getDefault()
public Set getPaths(String id)
id - a classpath type, e.g. ClassPath.SOURCE
ClassPaths of that type (may be empty but not null)public void register(String id, ClassPath[] paths)
id - a classpath type, e.g. ClassPath.SOURCEpaths - a list of classpaths to add to the registrypublic void unregister(String id, ClassPath[] paths) throws IllegalArgumentException
id - a classpath type, e.g. ClassPath.SOURCEpaths - a list of classpaths to remove from the registry
IllegalArgumentException - if they had not been registered beforepublic void addGlobalPathRegistryListener(GlobalPathRegistryListener l)
l - a listener to addpublic void removeGlobalPathRegistryListener(GlobalPathRegistryListener l)
l - a listener to removepublic Set getSourceRoots()
ClassPath.SOURCE paths.
 SourceForBinaryQuery) of all registered
     ClassPath.COMPILE paths.
 ClassPath.BOOT paths.
 
 Currently there is no reliable way to listen for changes in the
 value of this method: while you can listen to changes in the paths
 mentioned, it is possible for SourceForBinaryQuery results to
 change. In the future a change listener might be added for the value
 of the source roots.
 
FileObject source rootspublic FileObject findResource(String resource)
getSourceRoots() to find possible roots and
 looks up the resource among them.
 In case more than one source root contains the resource, one is chosen
 arbitrarily.
resource - a resource path, e.g. somepkg/Foo.java
| 
 | org.netbeans.api.java/1 1.10.22 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||