Class ClasspathLibraryInfo
- All Implemented Interfaces:
Cloneable, Comparable<LibraryInfo>
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 ClassEnumerationReader class 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 ClasspathSourceLocation
to get the source located automatically.
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionMapping of class names toClassFiles. -
Constructor Summary
ConstructorsConstructorDescriptionClasspathLibraryInfo(String[] classes) Constructor.ClasspathLibraryInfo(List<String> classes) Constructor.ClasspathLibraryInfo(List<String> classes, SourceLocation sourceLoc) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidDoes any cleanup necessary after a call toLibraryInfo.bulkClassFileCreationStart().voidReadies this library for many class files being fetched viaLibraryInfo.createClassFileBulk(String).intcompareTo(LibraryInfo info) createClassFile(String entryName) Returns the class file information for the specified class.createClassFileBulk(String entryName) Returns the class file information for the specified class.private ClassFileCreates and returns a map of maps representing the hierarchical package structure in this library.longSince stuff on the current classpath never changes (we don't support hotswapping), this method always returns0.Returns the location of this library, as a string.intSubclasses should override this method sinceLibraryInfo.equals(Object)is overridden.Methods inherited from class LibraryInfo
clone, equals, getJreJarInfo, getMainJreJarInfo, getSourceLocation, hashCode, setSourceLocation
-
Field Details
-
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 Details
-
ClasspathLibraryInfo
Constructor.- Parameters:
classes- A list of fully-qualified class names for classes you want added to the build path.
-
ClasspathLibraryInfo
-
ClasspathLibraryInfo
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 Details
-
bulkClassFileCreationEnd
public void bulkClassFileCreationEnd()Description copied from class:LibraryInfoDoes any cleanup necessary after a call toLibraryInfo.bulkClassFileCreationStart().- Specified by:
bulkClassFileCreationEndin classLibraryInfo- See Also:
-
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:
-
compareTo
-
createClassFile
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:
IOException- If an IO error occurs.- See Also:
-
createClassFileBulk
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:
IOException- If an IO error occurs.- See Also:
-
createClassFileImpl
- Throws:
IOException
-
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
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.
-