Closeable
, AutoCloseable
public class ScanResult extends Object implements Closeable
Modifier and Type | Method | Description |
---|---|---|
long |
classpathContentsLastModifiedTime() |
Find the maximum last-modified timestamp of any whitelisted file/directory/jarfile encountered during the
scan.
|
boolean |
classpathContentsModifiedSinceScan() |
Determine whether the classpath contents have been modified since the last scan.
|
void |
close() |
Free any temporary files created by extracting jars or files from within jars.
|
protected void |
finalize() |
|
static ScanResult |
fromJSON(String json) |
Deserialize a ScanResult from previously-serialized JSON.
|
ClassInfoList |
getAllAnnotations() |
Get all annotation classes found during the scan.
|
ClassInfoList |
getAllClasses() |
Get all classes, interfaces and annotations found during the scan.
|
ClassInfoList |
getAllInterfaces() |
Get all interface classes found during the scan (not including annotations, which are also technically
interfaces).
|
ClassInfoList |
getAllInterfacesAndAnnotations() |
Get all interface or annotation classes found during the scan.
|
ResourceList |
getAllResources() |
|
ClassInfoList |
getAllStandardClasses() |
Get all standard (non-interface/non-annotation) classes found during the scan.
|
ClassInfoList |
getAnnotationsOnClass(String className) |
Get annotations on the named class.
|
ClassInfoList |
getClassesImplementing(String interfaceName) |
Get all classes that implement (or have superclasses that implement) the named interface (or one of its
subinterfaces).
|
ClassInfoList |
getClassesWithAnnotation(String annotationName) |
Get classes with the named class annotation or meta-annotation.
|
ClassInfoList |
getClassesWithFieldAnnotation(String fieldAnnotationName) |
Get classes that have a field with an annotation of the named type.
|
ClassInfoList |
getClassesWithMethodAnnotation(String methodAnnotationName) |
Get classes that have a method with an annotation of the named type.
|
ClassInfo |
getClassInfo(String className) |
Get the ClassInfo object for the named class, or null if no class of the requested name was found in a
whitelisted/non-blacklisted package during scanning.
|
String |
getClasspath() |
Returns all unique directories or zip/jarfiles on the classpath, in classloader resolution order, as a
classpath string, delineated with the standard path separator character.
|
List<File> |
getClasspathFiles() |
Returns the list of File objects for unique classpath elements (directories or jarfiles), in classloader
resolution order.
|
List<URL> |
getClasspathURLs() |
Returns the list of unique classpath element paths as URLs, in classloader resolution order.
|
ClassInfoList |
getInterfaces(String className) |
Get all interfaces implemented by the named class or by one of its superclasses, if this is a standard class,
or the superinterfaces extended by this interface, if this is an interface.
|
List<ModuleRef> |
getModules() |
|
ResourceList |
getResourcesMatchingPattern(Pattern pattern) |
|
ResourceList |
getResourcesWithExtension(String extension) |
|
ResourceList |
getResourcesWithLeafName(String leafName) |
|
ResourceList |
getResourcesWithPath(String resourcePath) |
|
ClassInfoList |
getSubclasses(String superclassName) |
Get all subclasses of the named superclass.
|
ClassInfoList |
getSuperclasses(String subclassName) |
Get superclasses of the named subclass.
|
String |
toJSON() |
Serialize a ScanResult to minified (un-indented) JSON.
|
String |
toJSON(int indentWidth) |
Serialize a ScanResult to JSON.
|
public List<File> getClasspathFiles()
public String getClasspath()
public List<URL> getClasspathURLs()
public ResourceList getAllResources()
public ResourceList getResourcesWithPath(String resourcePath)
resourcePath
- A complete resource path, relative to the classpath entry package root.public ResourceList getResourcesWithLeafName(String leafName)
leafName
- A resource leaf filename.public ResourceList getResourcesWithExtension(String extension)
extension
- A filename extension, e.g. "xml" to match all resources ending in ".xml".public ResourceList getResourcesMatchingPattern(Pattern pattern)
pattern
- A pattern to match Resource
paths with.public boolean classpathContentsModifiedSinceScan()
public long classpathContentsLastModifiedTime()
This method cannot in general tell if classpath has changed (or modules have been added or removed) if it is run twice during the same runtime session.
public ClassInfo getClassInfo(String className)
className
- The class name.public ClassInfoList getAllClasses()
public ClassInfoList getAllStandardClasses()
public ClassInfoList getSubclasses(String superclassName)
superclassName
- The name of the superclass.public ClassInfoList getSuperclasses(String subclassName)
subclassName
- The name of the subclass.public ClassInfoList getClassesWithMethodAnnotation(String methodAnnotationName)
methodAnnotationName
- the name of the method annotation.public ClassInfoList getClassesWithFieldAnnotation(String fieldAnnotationName)
fieldAnnotationName
- the name of the field annotation.public ClassInfoList getAllInterfaces()
getAllInterfacesAndAnnotations()
.public ClassInfoList getInterfaces(String className)
className
- The class name.public ClassInfoList getClassesImplementing(String interfaceName)
interfaceName
- The interface name.public ClassInfoList getAllAnnotations()
getAllInterfacesAndAnnotations()
.public ClassInfoList getAllInterfacesAndAnnotations()
public ClassInfoList getClassesWithAnnotation(String annotationName)
annotationName
- The name of the class annotation or meta-annotation.public ClassInfoList getAnnotationsOnClass(String className)
getClassInfo(String)
to get the ClassInfo
object for the named class, then if the
ClassInfo
object is non-null, call ClassInfo.getAnnotationInfo()
to get detailed annotation
info.className
- The name of the class.public static ScanResult fromJSON(String json)
json
- The JSON string for the serialized ScanResult
.ScanResult
.public String toJSON(int indentWidth)
indentWidth
- If greater than 0, JSON will be formatted (indented), otherwise it will be minified (un-indented).ScanResult
, serialized as a JSON string.public String toJSON()
ScanResult
, serialized as a JSON string.protected void finalize() throws Throwable
public void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
Copyright © 2018. All rights reserved.