Class LibraryInfo
- All Implemented Interfaces:
Cloneable,Comparable<LibraryInfo>
- Direct Known Subclasses:
ClasspathLibraryInfo,DirLibraryInfo,JarLibraryInfo
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 Summary
FieldsModifier and TypeFieldDescriptionprivate SourceLocationThe location of the source files corresponding to this library. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidDoes any cleanup necessary after a call tobulkClassFileCreationStart().abstract voidReadies this library for many class files being fetched viacreateClassFileBulk(String).clone()Returns a deep copy of this library.abstract ClassFilecreateClassFile(String entryName) Returns the class file information for the specified class.abstract ClassFilecreateClassFileBulk(String entryName) Returns the class file information for the specified class.abstract PackageMapNodeCreates and returns a map of maps representing the hierarchical package structure in this library.booleanTwoLibraryInfos are considered equal if they represent the same class file location.static LibraryInfogetJreJarInfo(File jreHome) Returns information on the "main" jar for a JRE.abstract longReturns the time this library was last modified.abstract StringReturns the location of this library, as a string.static LibraryInfoReturns information on the JRE running this application.Returns the location of the source corresponding to this library.inthashCode()abstract intSubclasses should override this method sinceequals(Object)is overridden.voidsetSourceLocation(SourceLocation sourceLoc) Sets the location of the source corresponding to this library.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
sourceLoc
The location of the source files corresponding to this library. This may benull.
-
-
Constructor Details
-
LibraryInfo
public LibraryInfo()
-
-
Method Details
-
bulkClassFileCreationEnd
Does any cleanup necessary after a call tobulkClassFileCreationStart().- Throws:
IOException- If an IO error occurs.- See Also:
-
bulkClassFileCreationStart
Readies 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:
IOException- If an IO error occurs.- See Also:
-
clone
Returns a deep copy of this library. -
createClassFile
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:
IOException- If an IO error occurs.- See Also:
-
createClassFileBulk
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:
IOException- If an IO error occurs.- See Also:
-
createPackageMap
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
TwoLibraryInfos are considered equal if they represent the same class file location. Source attachment is irrelevant. -
getJreJarInfo
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:
-
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
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
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:
-
getSourceLocation
Returns the location of the source corresponding to this library.- Returns:
- The source for this library, or
nullif none. - See Also:
-
hashCode
public int hashCode() -
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
Sets the location of the source corresponding to this library.- Parameters:
sourceLoc- The source location. This may benull.- See Also:
-