Class LibraryInfo
- java.lang.Object
-
- org.fife.rsta.ac.java.buildpath.LibraryInfo
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Comparable<LibraryInfo>
- Direct Known Subclasses:
ClasspathLibraryInfo,DirLibraryInfo,JarLibraryInfo
public abstract class LibraryInfo extends java.lang.Object implements java.lang.Comparable<LibraryInfo>, java.lang.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 aJarManagerfor 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:
DirLibraryInfo,JarLibraryInfo,ClasspathLibraryInfo
-
-
Field Summary
Fields Modifier and Type Field Description private SourceLocationsourceLocThe location of the source files corresponding to this library.
-
Constructor Summary
Constructors Constructor Description LibraryInfo()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidbulkClassFileCreationEnd()Does any cleanup necessary after a call tobulkClassFileCreationStart().abstract voidbulkClassFileCreationStart()Readies this library for many class files being fetched viacreateClassFileBulk(String).java.lang.Objectclone()Returns a deep copy of this library.abstract ClassFilecreateClassFile(java.lang.String entryName)Returns the class file information for the specified class.abstract ClassFilecreateClassFileBulk(java.lang.String entryName)Returns the class file information for the specified class.abstract PackageMapNodecreatePackageMap()Creates and returns a map of maps representing the hierarchical package structure in this library.booleanequals(java.lang.Object o)TwoLibraryInfos are considered equal if they represent the same class file location.static LibraryInfogetJreJarInfo(java.io.File jreHome)Returns information on the "main" jar for a JRE.abstract longgetLastModified()Returns the time this library was last modified.abstract java.lang.StringgetLocationAsString()Returns the location of this library, as a string.static LibraryInfogetMainJreJarInfo()Returns information on the JRE running this application.SourceLocationgetSourceLocation()Returns the location of the source corresponding to this library.inthashCode()abstract inthashCodeImpl()Subclasses should override this method sinceequals(Object)is overridden.voidsetSourceLocation(SourceLocation sourceLoc)Sets the location of the source corresponding to this library.
-
-
-
Field Detail
-
sourceLoc
private SourceLocation sourceLoc
The location of the source files corresponding to this library. This may benull.
-
-
Method Detail
-
bulkClassFileCreationEnd
public abstract void bulkClassFileCreationEnd() throws java.io.IOExceptionDoes any cleanup necessary after a call tobulkClassFileCreationStart().- Throws:
java.io.IOException- If an IO error occurs.- See Also:
bulkClassFileCreationStart(),createClassFileBulk(String)
-
bulkClassFileCreationStart
public abstract void bulkClassFileCreationStart() throws java.io.IOExceptionReadies this library for many class files being fetched viacreateClassFileBulk(String). After calling this method, the actual class file fetching should be done in a try/finally block that ensures a call tobulkClassFileCreationEnd(); e.g.libInfo.bulkClassFileCreationStart(); try { String entryName = ...; ClassFile cf = createClassFileBulk(entryName); ... } finally { libInfo.bulkClassFileCreationEnd(); }- Throws:
java.io.IOException- If an IO error occurs.- See Also:
bulkClassFileCreationEnd(),createClassFileBulk(String)
-
clone
public java.lang.Object clone()
Returns a deep copy of this library.- Overrides:
clonein classjava.lang.Object- Returns:
- A deep copy.
-
createClassFile
public abstract ClassFile createClassFile(java.lang.String entryName) throws java.io.IOException
Returns the class file information for the specified class. Instances ofJarReadercan 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()andcreateClassFileBulk(String)over this method, for performance reasons.- Parameters:
entryName- The fully qualified name of the class file.- Returns:
- The class file, or
nullif it isn't found in this library. - Throws:
java.io.IOException- If an IO error occurs.- See Also:
createClassFileBulk(String)
-
createClassFileBulk
public abstract ClassFile createClassFileBulk(java.lang.String entryName) throws java.io.IOException
Returns the class file information for the specified class. Instances ofJarReadercan 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 callcreateClassFile(String).- Parameters:
entryName- The fully qualified name of the class file.- Returns:
- The class file, or
nullif it isn't found in this library. - Throws:
java.io.IOException- If an IO error occurs.- See Also:
createClassFile(String)
-
createPackageMap
public abstract PackageMapNode createPackageMap() throws java.io.IOException
Creates and returns a map of maps representing the hierarchical package structure in this library.- Returns:
- The package structure in this library.
- Throws:
java.io.IOException- If an IO error occurs.
-
equals
public boolean equals(java.lang.Object o)
TwoLibraryInfos are considered equal if they represent the same class file location. Source attachment is irrelevant.- Overrides:
equalsin classjava.lang.Object- Returns:
- Whether the specified instance represents the same class source as this one.
-
getJreJarInfo
public static LibraryInfo getJreJarInfo(java.io.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
nullif there is not a JRE in the specified directory. - See Also:
getMainJreJarInfo()
-
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 java.lang.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 benull.- 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
nullif an error occurs. - See Also:
getJreJarInfo(File)
-
getSourceLocation
public SourceLocation getSourceLocation()
Returns the location of the source corresponding to this library.- Returns:
- The source for this library, or
nullif none. - See Also:
setSourceLocation(SourceLocation)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
hashCodeImpl
public abstract int hashCodeImpl()
Subclasses should override this method sinceequals(Object)is overridden. Instances ofLibraryInfoaren't typically stored in maps, so the hash value isn't necessarily important toRSTALanguageSupport.- 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 benull.- See Also:
getSourceLocation()
-
-