Class JarReader
java.lang.Object
org.fife.rsta.ac.java.JarReader
Reads entries from a source of class files, such as a jar or a "bin/"
directory. This class acts as an intermediary between a raw
LibraryInfo and the higher level Java completion classes.
It caches information about classes and refreshes that cache when
appropriate.- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LibraryInfoInformation about the jar or directory we're reading classes from.private longprivate PackageMapNodeData structure that cachesClassFiles. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCompletions(org.fife.ui.autocomplete.CompletionProvider provider, String[] pkgNames, Set<org.fife.ui.autocomplete.Completion> addTo) Gets the completions in this jar that match a given string.private voidChecks whether the jar or class file directory has been modified since the last use of this reader.booleancontainsClass(String className) booleancontainsPackage(String pkgName) getClassEntry(String[] items) voidgetClassesInPackage(List<ClassFile> addTo, String[] pkgs, boolean inPkg) Looks through all classes in this jar or directory, trying to find any whose unqualified names start with a given prefix.Returns the physical file on disk.private voidtoString()
-
Field Details
-
info
Information about the jar or directory we're reading classes from. -
packageMap
Data structure that cachesClassFiles. -
lastModified
private long lastModified
-
-
Constructor Details
-
JarReader
JarReader(LibraryInfo info) throws IOException Constructor.- Parameters:
info- The jar file to read from. This cannot benull.- Throws:
IOException- If an IO error occurs reading from the jar file.
-
-
Method Details
-
addCompletions
public void addCompletions(org.fife.ui.autocomplete.CompletionProvider provider, String[] pkgNames, 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
-
containsPackage
-
getClassEntry
-
getClassesInPackage
-
getClassesWithNamesStartingWith
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
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
- Throws:
IOException
-
toString
-