org.fife.rsta.ac.java
Class JarManager

java.lang.Object
  extended by org.fife.rsta.ac.java.JarManager

public class JarManager
extends Object

Manages a list of jars and gets completions from them. This can be shared amongst multiple JavaCompletionProvider instances.

Version:
1.0
Author:
Robert Futrell

Constructor Summary
JarManager()
          Constructor.
 
Method Summary
 void addCompletions(CompletionProvider p, String text, Set addTo)
          Adds completions matching the specified text to a list.
 boolean addJar(JarInfo info)
          Adds a jar to read from.
 void clearJars()
          Removes all jars from the "build path."
static boolean getCheckModifiedDatestamps()
          Returns whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data.
 ClassFile getClassEntry(String className)
           
 List getClassesInPackage(String pkgName, boolean inPkg)
           
 List getClassesWithUnqualifiedName(String name, List importDeclarations)
          Returns a list of all classes/interfaces/enums with a given (unqualified) name.
 List getJars()
          Returns the jars on the "build path."
 SortedMap getPackageEntry(String pkgName)
           
 File getSourceLocForClass(String className)
           
 boolean removeJar(File jar)
          Removes a jar from the "build path."
static void setCheckModifiedDatestamps(boolean check)
          Sets whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarManager

public JarManager()
Constructor.

Method Detail

addCompletions

public void addCompletions(CompletionProvider p,
                           String text,
                           Set addTo)
Adds completions matching the specified text to a list.

Parameters:
p - The parent completion provider.
text - The text to match.
addTo - The list to add completion choices to.

addJar

public boolean addJar(JarInfo info)
               throws IOException
Adds a jar to read from.

Parameters:
info - The jar to add. If this is null, then the current JVM's main JRE jar (rt.jar, or classes.jar on OS X) will be added. If this jar has already been added, adding it again will do nothing (except possibly update its attached source location).
Returns:
Whether this jar was added (e.g. it wasn't already loaded, or it has a new source path).
Throws:
IOException - If an IO error occurs.
See Also:
getJars(), removeJar(File)

clearJars

public void clearJars()
Removes all jars from the "build path."

See Also:
removeJar(File), addJar(JarInfo), getJars()

getCheckModifiedDatestamps

public static boolean getCheckModifiedDatestamps()
Returns whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data. This allows for code completion to update whenever dependencies are rebuilt, but has the side effect of increased file I/O. By default this option is enabled; if you somehow find the file I/O to be a bottleneck (perhaps accessing jars over a slow NFS mount), you can disable this option.

Parameters:
check - Whether to check if any jars/directories have been modified since the last access, and clear any cached completion information if so.
See Also:
setCheckModifiedDatestamps(boolean)

getClassEntry

public ClassFile getClassEntry(String className)

getClassesWithUnqualifiedName

public List getClassesWithUnqualifiedName(String name,
                                          List importDeclarations)
Returns a list of all classes/interfaces/enums with a given (unqualified) name. There may be several, since the name is unqualified.

Parameters:
name - The unqualified name of a type declaration.
importDeclarations - The imports of the compilation unit, if any.
Returns:
A list of type declarations with the given name, or null if there are none.

getClassesInPackage

public List getClassesInPackage(String pkgName,
                                boolean inPkg)
Parameters:
pkgName - A package name.
Returns:
A list of all classes in that package.

getJars

public List getJars()
Returns the jars on the "build path."

Returns:
A list of JarInfos. Modifying a JarInfo in this list will have no effect on this completion provider; in order to do that, you must re-add the jar via addJar(JarInfo). If there are no jars on the "build path," this will be an empty list.
See Also:
addJar(JarInfo)

getPackageEntry

public SortedMap getPackageEntry(String pkgName)

getSourceLocForClass

public File getSourceLocForClass(String className)

removeJar

public boolean removeJar(File jar)
Removes a jar from the "build path."

Parameters:
jar - The jar to remove.
Returns:
Whether the jar was removed. This will be false if the jar was not on the build path.
See Also:
addJar(JarInfo), getJars()

setCheckModifiedDatestamps

public static void setCheckModifiedDatestamps(boolean check)
Sets whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data. This allows for code completion to update whenever dependencies are rebuilt, but has the side effect of increased file I/O. By default this option is enabled; if you somehow find the file I/O to be a bottleneck (perhaps accessing jars over a slow NFS mount), you can disable this option.

Parameters:
check - Whether to check if any jars/directories have been modified since the last access, and clear any cached completion information if so.
See Also:
getCheckModifiedDatestamps()


Copyright © 2003-2011. All Rights Reserved.