Class ClasspathOrder
- java.lang.Object
-
- nonapi.io.github.classgraph.classpath.ClasspathOrder
-
public class ClasspathOrder extends java.lang.ObjectA class to find the unique ordered classpath elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClasspathOrder.ClasspathEntryA classpath element and theClassLoaderit was obtained from.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<java.lang.String>AUTOMATIC_PACKAGE_ROOT_SUFFIXESSuffixes for automatic package roots, e.g.private java.util.Set<java.lang.String>classpathEntryUniqueResolvedPathsUnique classpath entries.private java.util.List<ClasspathOrder.ClasspathEntry>orderThe classpath order.ReflectionUtilsreflectionUtilsprivate ScanSpecscanSpecThe scan spec.private static java.util.regex.PatternschemeMatcherMatch URL schemes (must consist of at least two chars, otherwise this is Windows drive letter).
-
Constructor Summary
Constructors Constructor Description ClasspathOrder(ScanSpec scanSpec, ReflectionUtils reflectionUtils)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddClasspathEntries(java.util.List<java.lang.Object> overrideClasspath, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add classpath entries, separated by the system path separator character.booleanaddClasspathEntry(java.lang.Object pathElement, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add a classpath element relative to a base file.private booleanaddClasspathEntry(java.lang.Object pathElement, java.lang.String pathElementStr, java.lang.ClassLoader classLoader, ScanSpec scanSpec)Add a classpath entry.booleanaddClasspathEntryObject(java.lang.Object pathObject, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add classpath entries from an object obtained from reflection.booleanaddClasspathPathStr(java.lang.String pathStr, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add classpath entries, separated by the system path separator character.(package private) booleanaddSystemClasspathEntry(java.lang.String pathEntry, java.lang.ClassLoader classLoader)Add a system classpath entry.private booleanfilter(java.net.URL classpathElementURL, java.lang.String classpathElementPath)Test to see if a classpath element has been filtered out by the user.java.util.Set<java.lang.String>getClasspathEntryUniqueResolvedPaths()Get the unique classpath entry strings.java.util.List<ClasspathOrder.ClasspathEntry>getOrder()Get the order of classpath elements, uniquified and in order.
-
-
-
Field Detail
-
scanSpec
private final ScanSpec scanSpec
The scan spec.
-
reflectionUtils
public ReflectionUtils reflectionUtils
-
classpathEntryUniqueResolvedPaths
private final java.util.Set<java.lang.String> classpathEntryUniqueResolvedPaths
Unique classpath entries.
-
order
private final java.util.List<ClasspathOrder.ClasspathEntry> order
The classpath order. Keys are instances ofStringorURL.
-
AUTOMATIC_PACKAGE_ROOT_SUFFIXES
private static final java.util.List<java.lang.String> AUTOMATIC_PACKAGE_ROOT_SUFFIXES
Suffixes for automatic package roots, e.g. "!/BOOT-INF/classes".
-
schemeMatcher
private static final java.util.regex.Pattern schemeMatcher
Match URL schemes (must consist of at least two chars, otherwise this is Windows drive letter).
-
-
Constructor Detail
-
ClasspathOrder
ClasspathOrder(ScanSpec scanSpec, ReflectionUtils reflectionUtils)
Constructor.- Parameters:
scanSpec- the scan spec
-
-
Method Detail
-
getOrder
public java.util.List<ClasspathOrder.ClasspathEntry> getOrder()
Get the order of classpath elements, uniquified and in order.- Returns:
- the classpath order.
-
getClasspathEntryUniqueResolvedPaths
public java.util.Set<java.lang.String> getClasspathEntryUniqueResolvedPaths()
Get the unique classpath entry strings.- Returns:
- the classpath entry strings.
-
filter
private boolean filter(java.net.URL classpathElementURL, java.lang.String classpathElementPath)Test to see if a classpath element has been filtered out by the user.- Parameters:
classpathElementURL- the classpath element URLclasspathElementPath- the classpath element path- Returns:
- true, if not filtered out
-
addSystemClasspathEntry
boolean addSystemClasspathEntry(java.lang.String pathEntry, java.lang.ClassLoader classLoader)Add a system classpath entry.- Parameters:
pathEntry- the system classpath entry -- the path string should already have been run through FastPathResolver.resolve(FileUtils.currDirPath(), path)classLoader- the classloader- Returns:
- true, if added and unique
-
addClasspathEntry
private boolean addClasspathEntry(java.lang.Object pathElement, java.lang.String pathElementStr, java.lang.ClassLoader classLoader, ScanSpec scanSpec)Add a classpath entry.- Parameters:
pathElement- theStringpath,File,Path,URLorURIof the classpath element.pathElementStr- the path element in string formatclassLoader- the classloaderscanSpec- the scan spec- Returns:
- true, if added and unique
-
addClasspathEntry
public boolean addClasspathEntry(java.lang.Object pathElement, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add a classpath element relative to a base file. May be called by a ClassLoaderHandler to add classpath elements that it knows about. ClassLoaders will be called in order.- Parameters:
pathElement- theStringpath,URLorURIof the classpath element, or some object whoseObject.toString()method can be called to obtain the classpath element.classLoader- the ClassLoader that this classpath element was obtained from.scanSpec- the scan speclog- the LogNode instance to use if logging in verbose mode.- Returns:
- true (and add the classpath element) if pathElement is not null, empty, nonexistent, or filtered out by user-specified criteria, otherwise return false.
-
addClasspathEntries
public boolean addClasspathEntries(java.util.List<java.lang.Object> overrideClasspath, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add classpath entries, separated by the system path separator character.- Parameters:
overrideClasspath- a list of delimited pathString,URL,URIorFileobjects.classLoader- the ClassLoader that this classpath was obtained from.scanSpec- the scan speclog- the LogNode instance to use if logging in verbose mode.- Returns:
- true (and add the classpath element) if pathElement is not null or empty, otherwise return false.
-
addClasspathPathStr
public boolean addClasspathPathStr(java.lang.String pathStr, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add classpath entries, separated by the system path separator character.- Parameters:
pathStr- the delimited string of URLs or paths of the classpath.classLoader- the ClassLoader that this classpath was obtained from.scanSpec- the scan speclog- the LogNode instance to use if logging in verbose mode.- Returns:
- true (and add the classpath element) if pathElement is not null or empty, otherwise return false.
-
addClasspathEntryObject
public boolean addClasspathEntryObject(java.lang.Object pathObject, java.lang.ClassLoader classLoader, ScanSpec scanSpec, LogNode log)Add classpath entries from an object obtained from reflection. The object may be aURL, aURI, aFile, aPathor aString(containing a single classpath element path, or several paths separated with File.pathSeparator), a List or other Iterable, or an array object. In the case of Iterables and arrays, the elements may be any type whosetoString()method returns a path or URL string (including theURLandPathtypes).- Parameters:
pathObject- the object containing a classpath string or strings.classLoader- the ClassLoader that this classpath was obtained from.scanSpec- the scan speclog- the LogNode instance to use if logging in verbose mode.- Returns:
- true (and add the classpath element) if pathEl)ement is not null or empty, otherwise return false.
-
-