Class JarLibraryInfo

java.lang.Object
org.fife.rsta.ac.java.buildpath.LibraryInfo
org.fife.rsta.ac.java.buildpath.JarLibraryInfo
All Implemented Interfaces:
Cloneable, Comparable<LibraryInfo>

public class JarLibraryInfo extends LibraryInfo
Information about a jar of classes to add to the "build path".
Version:
1.0
See Also:
  • Field Details

    • jarFile

      private File jarFile
    • bulkCreateJar

      private JarFile bulkCreateJar
  • Constructor Details

    • JarLibraryInfo

      public JarLibraryInfo(String jarFile)
    • JarLibraryInfo

      public JarLibraryInfo(File jarFile)
    • JarLibraryInfo

      public JarLibraryInfo(File jarFile, SourceLocation sourceLoc)
  • Method Details

    • bulkClassFileCreationEnd

      public void bulkClassFileCreationEnd()
      Description copied from class: LibraryInfo
      Does any cleanup necessary after a call to LibraryInfo.bulkClassFileCreationStart().
      Specified by:
      bulkClassFileCreationEnd in class LibraryInfo
      See Also:
    • bulkClassFileCreationStart

      public void bulkClassFileCreationStart()
      Description copied from class: LibraryInfo
      Readies this library for many class files being fetched via LibraryInfo.createClassFileBulk(String). After calling this method, the actual class file fetching should be done in a try/finally block that ensures a call to LibraryInfo.bulkClassFileCreationEnd(); e.g.
      libInfo.bulkClassFileCreationStart();
      try {
         String entryName = ...;
         ClassFile cf = createClassFileBulk(entryName);
         ...
      } finally {
         libInfo.bulkClassFileCreationEnd();
      }
      
      Specified by:
      bulkClassFileCreationStart in class LibraryInfo
      See Also:
    • compareTo

      public int compareTo(LibraryInfo info)
      Compares this LibraryInfo to another one. Two instances of this class are only considered equal if they represent the same class file location. Source attachment is irrelevant.
      Returns:
      The sort order of these two library infos.
    • createClassFile

      public ClassFile createClassFile(String entryName) throws IOException
      Description copied from class: LibraryInfo
      Returns the class file information for the specified class. Instances of JarReader can call this method to lazily load information on individual classes and shove it into their package maps.

      If many class files will be fetched at a time, you should prefer using LibraryInfo.bulkClassFileCreationStart() and LibraryInfo.createClassFileBulk(String) over this method, for performance reasons.

      Specified by:
      createClassFile in class LibraryInfo
      Parameters:
      entryName - The fully qualified name of the class file.
      Returns:
      The class file, or null if it isn't found in this library.
      Throws:
      IOException - If an IO error occurs.
      See Also:
    • createClassFileBulk

      public ClassFile createClassFileBulk(String entryName) throws IOException
      Description copied from class: LibraryInfo
      Returns the class file information for the specified class. Instances of JarReader can call this method to lazily load information on individual classes and shove it into their package maps.

      This method should be used when multiple classes will be fetched from this library at the same time. It should only be called after a call to LibraryInfo.bulkClassFileCreationStart(). If only a single class file is being fetched, it is simpler to call LibraryInfo.createClassFile(String).

      Specified by:
      createClassFileBulk in class LibraryInfo
      Parameters:
      entryName - The fully qualified name of the class file.
      Returns:
      The class file, or null if it isn't found in this library.
      Throws:
      IOException - If an IO error occurs.
      See Also:
    • createClassFileImpl

      private static ClassFile createClassFileImpl(JarFile jar, String entryName) throws IOException
      Throws:
      IOException
    • createPackageMap

      public PackageMapNode createPackageMap() throws IOException
      Description copied from class: LibraryInfo
      Creates and returns a map of maps representing the hierarchical package structure in this library.
      Specified by:
      createPackageMap in class LibraryInfo
      Returns:
      The package structure in this library.
      Throws:
      IOException - If an IO error occurs.
    • getLastModified

      public long getLastModified()
      Description copied from class: LibraryInfo
      Returns the time this library was last modified. For jar files, this would be the modified date of the file. For directories, this would be the time a file in the directory was most recently modified. This information is used to determine whether callers should clear their cached package map information and load it anew.

      This API may change in the future.

      Specified by:
      getLastModified in class LibraryInfo
      Returns:
      The last time this library was modified.
    • getLocationAsString

      public String getLocationAsString()
      Description copied from class: LibraryInfo
      Returns the location of this library, as a string. If this library is contained in a single jar file, this will be the full path to that jar. If it is a directory containing classes, it will be the full path of the directory. Otherwise, this value will be null.
      Specified by:
      getLocationAsString in class LibraryInfo
      Returns:
      The location of this library.
    • getJarFile

      public File getJarFile()
      Returns the jar file this instance is wrapping.
      Returns:
      The jar file.
    • hashCodeImpl

      public int hashCodeImpl()
      Description copied from class: LibraryInfo
      Subclasses should override this method since LibraryInfo.equals(Object) is overridden. Instances of LibraryInfo aren't typically stored in maps, so the hash value isn't necessarily important to RSTALanguageSupport.
      Specified by:
      hashCodeImpl in class LibraryInfo
      Returns:
      The hash code for this library.
    • setJarFile

      private void setJarFile(File jarFile)
      Sets the jar file location.
      Parameters:
      jarFile - The jar file location. This cannot be null.
    • toString

      public String toString()
      Returns a string representation of this jar information. Useful for debugging.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this object.