Class ClasspathLibraryInfo
- java.lang.Object
-
- org.fife.rsta.ac.java.buildpath.LibraryInfo
-
- org.fife.rsta.ac.java.buildpath.ClasspathLibraryInfo
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Comparable<LibraryInfo>
public class ClasspathLibraryInfo extends LibraryInfo
Information about specific classes on the current application's classpath to add to the "build path." This type of container is useful if your application ships with specific classes you want included in code completion, but you don't want to add the entire jar to the build path.Since there is no real way to determine all classes in a package via reflection, you must explicitly enumerate all classes that are on the classpath that you want on the build path. To make this easier, you can use the
ClassEnumerationReaderclass to read a list of classes from a plain text file or other resource.If you're delivering the corresponding .java source files also on the classpath (i.e. you have a library "hard-coded" to be on the build path), you can set the source location to be a
ClasspathSourceLocationto get the source located automatically.- Version:
- 1.0
- See Also:
JarLibraryInfo,DirLibraryInfo,ClasspathSourceLocation
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,ClassFile>classNameToClassFileMapping of class names toClassFiles.
-
Constructor Summary
Constructors Constructor Description ClasspathLibraryInfo(java.lang.String[] classes)Constructor.ClasspathLibraryInfo(java.util.List<java.lang.String> classes)Constructor.ClasspathLibraryInfo(java.util.List<java.lang.String> classes, SourceLocation sourceLoc)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbulkClassFileCreationEnd()Does any cleanup necessary after a call toLibraryInfo.bulkClassFileCreationStart().voidbulkClassFileCreationStart()Readies this library for many class files being fetched viaLibraryInfo.createClassFileBulk(String).intcompareTo(LibraryInfo info)ClassFilecreateClassFile(java.lang.String entryName)Returns the class file information for the specified class.ClassFilecreateClassFileBulk(java.lang.String entryName)Returns the class file information for the specified class.private ClassFilecreateClassFileImpl(java.lang.String res)PackageMapNodecreatePackageMap()Creates and returns a map of maps representing the hierarchical package structure in this library.longgetLastModified()Since stuff on the current classpath never changes (we don't support hotswapping), this method always returns0.java.lang.StringgetLocationAsString()Returns the location of this library, as a string.inthashCodeImpl()Subclasses should override this method sinceLibraryInfo.equals(Object)is overridden.-
Methods inherited from class org.fife.rsta.ac.java.buildpath.LibraryInfo
clone, equals, getJreJarInfo, getMainJreJarInfo, getSourceLocation, hashCode, setSourceLocation
-
-
-
-
Field Detail
-
classNameToClassFile
private java.util.Map<java.lang.String,ClassFile> classNameToClassFile
Mapping of class names toClassFiles. This information is cached even though it's also cached at theJarReaderlevel because the class definitions are effectively immutable since they're on the classpath. This allows you to theoretically share a singleClasspathLibraryInfoacross several different jar managers.
-
-
Constructor Detail
-
ClasspathLibraryInfo
public ClasspathLibraryInfo(java.lang.String[] classes)
Constructor.- Parameters:
classes- A list of fully-qualified class names for classes you want added to the build path.
-
ClasspathLibraryInfo
public ClasspathLibraryInfo(java.util.List<java.lang.String> classes)
Constructor.- Parameters:
classes- A list of fully-qualified class names for classes you want added to the build path.
-
ClasspathLibraryInfo
public ClasspathLibraryInfo(java.util.List<java.lang.String> classes, SourceLocation sourceLoc)Constructor.- Parameters:
classes- A list of fully-qualified class names for classes you want added to the build path.sourceLoc- The location of the source files for the classes given. This may benull.
-
-
Method Detail
-
bulkClassFileCreationEnd
public void bulkClassFileCreationEnd()
Description copied from class:LibraryInfoDoes any cleanup necessary after a call toLibraryInfo.bulkClassFileCreationStart().- Specified by:
bulkClassFileCreationEndin classLibraryInfo- See Also:
LibraryInfo.bulkClassFileCreationStart(),LibraryInfo.createClassFileBulk(String)
-
bulkClassFileCreationStart
public void bulkClassFileCreationStart()
Description copied from class:LibraryInfoReadies this library for many class files being fetched viaLibraryInfo.createClassFileBulk(String). After calling this method, the actual class file fetching should be done in a try/finally block that ensures a call toLibraryInfo.bulkClassFileCreationEnd(); e.g.libInfo.bulkClassFileCreationStart(); try { String entryName = ...; ClassFile cf = createClassFileBulk(entryName); ... } finally { libInfo.bulkClassFileCreationEnd(); }- Specified by:
bulkClassFileCreationStartin classLibraryInfo- See Also:
LibraryInfo.bulkClassFileCreationEnd(),LibraryInfo.createClassFileBulk(String)
-
compareTo
public int compareTo(LibraryInfo info)
-
createClassFile
public ClassFile createClassFile(java.lang.String entryName) throws java.io.IOException
Description copied from class:LibraryInfoReturns 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
LibraryInfo.bulkClassFileCreationStart()andLibraryInfo.createClassFileBulk(String)over this method, for performance reasons.- Specified by:
createClassFilein classLibraryInfo- 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:
LibraryInfo.createClassFileBulk(String)
-
createClassFileBulk
public ClassFile createClassFileBulk(java.lang.String entryName) throws java.io.IOException
Description copied from class:LibraryInfoReturns 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
LibraryInfo.bulkClassFileCreationStart(). If only a single class file is being fetched, it is simpler to callLibraryInfo.createClassFile(String).- Specified by:
createClassFileBulkin classLibraryInfo- 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:
LibraryInfo.createClassFile(String)
-
createClassFileImpl
private ClassFile createClassFileImpl(java.lang.String res) throws java.io.IOException
- Throws:
java.io.IOException
-
createPackageMap
public PackageMapNode createPackageMap()
Description copied from class:LibraryInfoCreates and returns a map of maps representing the hierarchical package structure in this library.- Specified by:
createPackageMapin classLibraryInfo- Returns:
- The package structure in this library.
-
getLastModified
public long getLastModified()
Since stuff on the current classpath never changes (we don't support hotswapping), this method always returns0.- Specified by:
getLastModifiedin classLibraryInfo- Returns:
0always.
-
getLocationAsString
public java.lang.String getLocationAsString()
Description copied from class:LibraryInfoReturns 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.- Specified by:
getLocationAsStringin classLibraryInfo- Returns:
- The location of this library.
-
hashCodeImpl
public int hashCodeImpl()
Description copied from class:LibraryInfoSubclasses should override this method sinceLibraryInfo.equals(Object)is overridden. Instances ofLibraryInfoaren't typically stored in maps, so the hash value isn't necessarily important toRSTALanguageSupport.- Specified by:
hashCodeImplin classLibraryInfo- Returns:
- The hash code for this library.
-
-