Class LibraryInfo

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

public abstract class LibraryInfo extends Object implements Comparable<LibraryInfo>, Cloneable
Information about a jar, compiled class folder, or other source of classes to add to the "build path" for Java completion. Instances of this class are added to a JarManager for each library that should be on the build path.

This class also keeps track of an optional source location, such as a zip file or source folder. If defined, this location is used to find the .java source corresponding to the library's classes, which is used to display Javadoc comments during code completion.

Version:
1.0
See Also:
  • Field Details

    • sourceLoc

      private SourceLocation sourceLoc
      The location of the source files corresponding to this library. This may be null.
  • Constructor Details

    • LibraryInfo

      public LibraryInfo()
  • Method Details

    • bulkClassFileCreationEnd

      public abstract void bulkClassFileCreationEnd() throws IOException
      Does any cleanup necessary after a call to bulkClassFileCreationStart().
      Throws:
      IOException - If an IO error occurs.
      See Also:
    • bulkClassFileCreationStart

      public abstract void bulkClassFileCreationStart() throws IOException
      Readies this library for many class files being fetched via createClassFileBulk(String). After calling this method, the actual class file fetching should be done in a try/finally block that ensures a call to bulkClassFileCreationEnd(); e.g.
      libInfo.bulkClassFileCreationStart();
      try {
         String entryName = ...;
         ClassFile cf = createClassFileBulk(entryName);
         ...
      } finally {
         libInfo.bulkClassFileCreationEnd();
      }
      
      Throws:
      IOException - If an IO error occurs.
      See Also:
    • clone

      public Object clone()
      Returns a deep copy of this library.
      Overrides:
      clone in class Object
      Returns:
      A deep copy.
    • createClassFile

      public abstract ClassFile createClassFile(String entryName) throws IOException
      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 bulkClassFileCreationStart() and createClassFileBulk(String) over this method, for performance reasons.

      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 abstract ClassFile createClassFileBulk(String entryName) throws IOException
      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 bulkClassFileCreationStart(). If only a single class file is being fetched, it is simpler to call createClassFile(String).

      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:
    • createPackageMap

      public abstract PackageMapNode createPackageMap() throws IOException
      Creates and returns a map of maps representing the hierarchical package structure in this library.
      Returns:
      The package structure in this library.
      Throws:
      IOException - If an IO error occurs.
    • equals

      public boolean equals(Object o)
      Two LibraryInfos are considered equal if they represent the same class file location. Source attachment is irrelevant.
      Overrides:
      equals in class Object
      Returns:
      Whether the specified instance represents the same class source as this one.
    • getJreJarInfo

      public static LibraryInfo getJreJarInfo(File jreHome)
      Returns information on the "main" jar for a JRE. This will be rt.jar everywhere except OS X, where it will be classes.jar. The associated source zip/jar file is also checked for.
      Parameters:
      jreHome - The location of the JRE.
      Returns:
      The information, or null if there is not a JRE in the specified directory.
      See Also:
    • getLastModified

      public abstract long getLastModified()
      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.

      Returns:
      The last time this library was modified.
    • getLocationAsString

      public abstract String getLocationAsString()
      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.
      Returns:
      The location of this library.
    • getMainJreJarInfo

      public static LibraryInfo getMainJreJarInfo()
      Returns information on the JRE running this application. This will be rt.jar everywhere except OS X, where it will be classes.jar. The associated source zip/jar file is also checked for.
      Returns:
      The information, or null if an error occurs.
      See Also:
    • getSourceLocation

      public SourceLocation getSourceLocation()
      Returns the location of the source corresponding to this library.
      Returns:
      The source for this library, or null if none.
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • hashCodeImpl

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

      public void setSourceLocation(SourceLocation sourceLoc)
      Sets the location of the source corresponding to this library.
      Parameters:
      sourceLoc - The source location. This may be null.
      See Also: