Class JarReader

java.lang.Object
org.fife.rsta.ac.java.JarReader

class JarReader extends Object
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 Details

    • info

      private LibraryInfo info
      Information about the jar or directory we're reading classes from.
    • packageMap

      private PackageMapNode packageMap
      Data structure that caches ClassFiles.
    • lastModified

      private long lastModified
  • Constructor Details

    • JarReader

      JarReader(LibraryInfo info) throws IOException
      Constructor.
      Parameters:
      info - The jar file to read from. This cannot be null.
      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 cached ClassFiles are cleared, in case any classes have been updated.
    • containsClass

      public boolean containsClass(String className)
    • containsPackage

      public boolean containsPackage(String pkgName)
    • getClassEntry

      public ClassFile getClassEntry(String[] items)
    • getClassesInPackage

      public void getClassesInPackage(List<ClassFile> addTo, String[] pkgs, boolean inPkg)
    • getClassesWithNamesStartingWith

      public List<ClassFile> getClassesWithNamesStartingWith(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 be null, 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 IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object