Package org.fife.rsta.ac.java
Class JarReader
- java.lang.Object
-
- org.fife.rsta.ac.java.JarReader
-
class JarReader extends java.lang.ObjectReads entries from a source of class files, such as a jar or a "bin/" directory. This class acts as an intermediary between a rawLibraryInfoand the higher level Java completion classes. It caches information about classes and refreshes that cache when appropriate.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private LibraryInfoinfoInformation about the jar or directory we're reading classes from.private longlastModifiedprivate PackageMapNodepackageMapData structure that cachesClassFiles.
-
Constructor Summary
Constructors Constructor Description JarReader(LibraryInfo info)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCompletions(org.fife.ui.autocomplete.CompletionProvider provider, java.lang.String[] pkgNames, java.util.Set<org.fife.ui.autocomplete.Completion> addTo)Gets the completions in this jar that match a given string.private voidcheckLastModified()Checks whether the jar or class file directory has been modified since the last use of this reader.booleancontainsClass(java.lang.String className)booleancontainsPackage(java.lang.String pkgName)ClassFilegetClassEntry(java.lang.String[] items)voidgetClassesInPackage(java.util.List<ClassFile> addTo, java.lang.String[] pkgs, boolean inPkg)java.util.List<ClassFile>getClassesWithNamesStartingWith(java.lang.String prefix)Looks through all classes in this jar or directory, trying to find any whose unqualified names start with a given prefix.LibraryInfogetLibraryInfo()Returns the physical file on disk.private voidloadCompletions()java.lang.StringtoString()
-
-
-
Field Detail
-
info
private LibraryInfo info
Information about the jar or directory we're reading classes from.
-
packageMap
private PackageMapNode packageMap
Data structure that cachesClassFiles.
-
lastModified
private long lastModified
-
-
Constructor Detail
-
JarReader
JarReader(LibraryInfo info) throws java.io.IOException
Constructor.- Parameters:
info- The jar file to read from. This cannot benull.- Throws:
java.io.IOException- If an IO error occurs reading from the jar file.
-
-
Method Detail
-
addCompletions
public void addCompletions(org.fife.ui.autocomplete.CompletionProvider provider, java.lang.String[] pkgNames, java.util.Set<org.fife.ui.autocomplete.Completion> addTo)Gets the completions in this jar that match a given string.- Parameters:
provider- The parent completion provider.pkgNames- The text to match, split into tokens around the '.' character. This should be (the start of) a fully-qualified class, interface, or enum name.addTo- The list to add completion choices to.
-
checkLastModified
private void checkLastModified()
Checks whether the jar or class file directory has been modified since the last use of this reader. If it has, then any cachedClassFiles are cleared, in case any classes have been updated.
-
containsClass
public boolean containsClass(java.lang.String className)
-
containsPackage
public boolean containsPackage(java.lang.String pkgName)
-
getClassEntry
public ClassFile getClassEntry(java.lang.String[] items)
-
getClassesInPackage
public void getClassesInPackage(java.util.List<ClassFile> addTo, java.lang.String[] pkgs, boolean inPkg)
-
getClassesWithNamesStartingWith
public java.util.List<ClassFile> getClassesWithNamesStartingWith(java.lang.String prefix)
Looks through all classes in this jar or directory, trying to find any whose unqualified names start with a given prefix.- Parameters:
prefix- The prefix of the class names. Case is ignored on this parameter.- Returns:
- A list of
ClassFiles representing classes in this jar or directory whose unqualified names start with the prefix. This will never benull, but may of course be empty.
-
getLibraryInfo
public LibraryInfo getLibraryInfo()
Returns the physical file on disk.Modifying the returned object will not have any effect on code completion; e.g. changing the source location will not have any effect.
- Returns:
- The info.
-
loadCompletions
private void loadCompletions() throws java.io.IOException- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-