Top Description Inners Fields Constructors Methods
nonapi.io.github.classgraph.classpath

public Class ClasspathOrder

extends Object
Class Inheritance
Imports
java.io.File, .IOError, java.lang.reflect.Array, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, java.nio.file.InvalidPathException, .Path, .Paths, java.util.ArrayList, .HashSet, .List, .Objects, .Set, java.util.regex.Matcher, .Pattern, io.github.classgraph.ClassGraph.ClasspathElementFilter, .ClassGraph.ClasspathElementURLFilter, nonapi.io.github.classgraph.classloaderhandler.ClassLoaderHandlerRegistry, nonapi.io.github.classgraph.reflection.ReflectionUtils, nonapi.io.github.classgraph.scanspec.ScanSpec, nonapi.io.github.classgraph.utils.FastPathResolver, .FileUtils, .JarUtils, .LogNode

A class to find the unique ordered classpath elements.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ClasspathOrder.ClasspathEntry

A classpath element and the ClassLoader it was obtained from.

Field Summary

Modifier and TypeField and Description
private static final List<String>
AUTOMATIC_PACKAGE_ROOT_SUFFIXES

Suffixes for automatic package roots, e.g. "!/BOOT-INF/classes".

private final Set<String>
classpathEntryUniqueResolvedPaths

Unique classpath entries.

private final List<ClasspathOrder.ClasspathEntry>
order

The classpath order.

public ReflectionUtils
private final ScanSpec
scanSpec

The scan spec.

private static final Pattern
schemeMatcher

Match URL schemes (must consist of at least two chars, otherwise this is Windows drive letter).

Constructor Summary

AccessConstructor and Description
pack-priv
ClasspathOrder(final ScanSpec
the scan spec
scanSpec
,
final ReflectionUtils reflectionUtils)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true (and add the classpath element) if pathElement is not null or empty, otherwise return false.
addClasspathEntries
(final List<Object>
a list of delimited path String, URL, URI or File objects.
overrideClasspath
,
final ClassLoader
the ClassLoader that this classpath was obtained from.
classLoader
,
final ScanSpec
the scan spec
scanSpec
,
final LogNode
the LogNode instance to use if logging in verbose mode.
log
)

Add classpath entries, separated by the system path separator character.

private boolean

Returns:

true, if added and unique
addClasspathEntry
(final Object
the String path, File, Path, URL or URI of the classpath element.
pathElement
,
final String
the path element in string format
pathElementStr
,
final ClassLoader
the classloader
classLoader
,
final ScanSpec
the scan spec
scanSpec
)

Add a classpath entry.

public boolean

Returns:

true (and add the classpath element) if pathElement is not null, empty, nonexistent, or filtered out by user-specified criteria, otherwise return false.
addClasspathEntry
(final Object
the String path, URL or URI of the classpath element, or some object whose Object#toString() method can be called to obtain the classpath element.
pathElement
,
final ClassLoader
the ClassLoader that this classpath element was obtained from.
classLoader
,
final ScanSpec
the scan spec
scanSpec
,
final LogNode
the LogNode instance to use if logging in verbose mode.
log
)

Add a classpath element relative to a base file.

public boolean

Returns:

true (and add the classpath element) if pathEl)ement is not null or empty, otherwise return false.
addClasspathEntryObject
(final Object
the object containing a classpath string or strings.
pathObject
,
final ClassLoader
the ClassLoader that this classpath was obtained from.
classLoader
,
final ScanSpec
the scan spec
scanSpec
,
final LogNode
the LogNode instance to use if logging in verbose mode.
log
)

Add classpath entries from an object obtained from reflection.

public boolean

Returns:

true (and add the classpath element) if pathElement is not null or empty, otherwise return false.
addClasspathPathStr
(final String
the delimited string of URLs or paths of the classpath.
pathStr
,
final ClassLoader
the ClassLoader that this classpath was obtained from.
classLoader
,
final ScanSpec
the scan spec
scanSpec
,
final LogNode
the LogNode instance to use if logging in verbose mode.
log
)

Add classpath entries, separated by the system path separator character.

pack-priv boolean

Returns:

true, if added and unique
addSystemClasspathEntry
(final String
the system classpath entry -- the path string should already have been run through FastPathResolver.resolve(FileUtils.currDirPath(), path)
pathEntry
,
final ClassLoader
the classloader
classLoader
)

Add a system classpath entry.

private boolean

Returns:

true, if not filtered out
filter
(final URL
the classpath element URL
classpathElementURL
,
final String
the classpath element path
classpathElementPath
)

Test to see if a classpath element has been filtered out by the user.

public Set<String>

Returns:

the classpath entry strings.
getClasspathEntryUniqueResolvedPaths
()

Get the unique classpath entry strings.

public List<ClasspathOrder.ClasspathEntry>

Returns:

the classpath order.
getOrder
()

Get the order of classpath elements, uniquified and in order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AUTOMATIC_PACKAGE_ROOT_SUFFIXESback to summary
private static final List<String> AUTOMATIC_PACKAGE_ROOT_SUFFIXES

Suffixes for automatic package roots, e.g. "!/BOOT-INF/classes".

classpathEntryUniqueResolvedPathsback to summary
private final Set<String> classpathEntryUniqueResolvedPaths

Unique classpath entries.

orderback to summary
private final List<ClasspathOrder.ClasspathEntry> order

The classpath order. Keys are instances of String or URL.

reflectionUtilsback to summary
public ReflectionUtils reflectionUtils
scanSpecback to summary
private final ScanSpec scanSpec

The scan spec.

schemeMatcherback to summary
private static final Pattern schemeMatcher

Match URL schemes (must consist of at least two chars, otherwise this is Windows drive letter).

Constructor Detail

ClasspathOrderback to summary
pack-priv ClasspathOrder(final ScanSpec scanSpec, final ReflectionUtils reflectionUtils)

Constructor.

Parameters
scanSpec:ScanSpec

the scan spec

Method Detail

addClasspathEntriesback to summary
public boolean addClasspathEntries(final List<Object> overrideClasspath, final ClassLoader classLoader, final ScanSpec scanSpec, final LogNode log)

Add classpath entries, separated by the system path separator character.

Parameters
overrideClasspath:List<Object>

a list of delimited path String, URL, URI or File objects.

classLoader:ClassLoader

the ClassLoader that this classpath was obtained from.

scanSpec:ScanSpec

the scan spec

log:LogNode

the LogNode instance to use if logging in verbose mode.

Returns:boolean

true (and add the classpath element) if pathElement is not null or empty, otherwise return false.

addClasspathEntryback to summary
private boolean addClasspathEntry(final Object pathElement, final String pathElementStr, final ClassLoader classLoader, final ScanSpec scanSpec)

Add a classpath entry.

Parameters
pathElement:Object

the String path, File, Path, URL or URI of the classpath element.

pathElementStr:String

the path element in string format

classLoader:ClassLoader

the classloader

scanSpec:ScanSpec

the scan spec

Returns:boolean

true, if added and unique

addClasspathEntryback to summary
public boolean addClasspathEntry(final Object pathElement, final ClassLoader classLoader, final ScanSpec scanSpec, final 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:Object

the String path, URL or URI of the classpath element, or some object whose Object#toString() method can be called to obtain the classpath element.

classLoader:ClassLoader

the ClassLoader that this classpath element was obtained from.

scanSpec:ScanSpec

the scan spec

log:LogNode

the LogNode instance to use if logging in verbose mode.

Returns:boolean

true (and add the classpath element) if pathElement is not null, empty, nonexistent, or filtered out by user-specified criteria, otherwise return false.

addClasspathEntryObjectback to summary
public boolean addClasspathEntryObject(final Object pathObject, final ClassLoader classLoader, final ScanSpec scanSpec, final LogNode log)

Add classpath entries from an object obtained from reflection. The object may be a URL, a URI, a File, a Path or a String (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 whose toString() method returns a path or URL string (including the URL and Path types).

Parameters
pathObject:Object

the object containing a classpath string or strings.

classLoader:ClassLoader

the ClassLoader that this classpath was obtained from.

scanSpec:ScanSpec

the scan spec

log:LogNode

the LogNode instance to use if logging in verbose mode.

Returns:boolean

true (and add the classpath element) if pathEl)ement is not null or empty, otherwise return false.

addClasspathPathStrback to summary
public boolean addClasspathPathStr(final String pathStr, final ClassLoader classLoader, final ScanSpec scanSpec, final LogNode log)

Add classpath entries, separated by the system path separator character.

Parameters
pathStr:String

the delimited string of URLs or paths of the classpath.

classLoader:ClassLoader

the ClassLoader that this classpath was obtained from.

scanSpec:ScanSpec

the scan spec

log:LogNode

the LogNode instance to use if logging in verbose mode.

Returns:boolean

true (and add the classpath element) if pathElement is not null or empty, otherwise return false.

addSystemClasspathEntryback to summary
pack-priv boolean addSystemClasspathEntry(final String pathEntry, final ClassLoader classLoader)

Add a system classpath entry.

Parameters
pathEntry:String

the system classpath entry -- the path string should already have been run through FastPathResolver.resolve(FileUtils.currDirPath(), path)

classLoader:ClassLoader

the classloader

Returns:boolean

true, if added and unique

filterback to summary
private boolean filter(final URL classpathElementURL, final String classpathElementPath)

Test to see if a classpath element has been filtered out by the user.

Parameters
classpathElementURL:URL

the classpath element URL

classpathElementPath:String

the classpath element path

Returns:boolean

true, if not filtered out

getClasspathEntryUniqueResolvedPathsback to summary
public Set<String> getClasspathEntryUniqueResolvedPaths()

Get the unique classpath entry strings.

Returns:Set<String>

the classpath entry strings.

getOrderback to summary
public List<ClasspathOrder.ClasspathEntry> getOrder()

Get the order of classpath elements, uniquified and in order.

Returns:List<ClasspathOrder.ClasspathEntry>

the classpath order.

nonapi.io.github.classgraph.classpath back to summary

public Class ClasspathOrder.ClasspathEntry

extends Object
Class Inheritance
  • java.lang.Object
  • nonapi.io.github.classgraph.classpath.ClasspathOrder.ClasspathEntry

A classpath element and the ClassLoader it was obtained from.

Field Summary

Modifier and TypeField and Description
public final ClassLoader
classLoader

The classloader the classpath element was obtained from.

public final Object
classpathEntryObj

The classpath entry object (a String path, Path, URL or URI).

Constructor Summary

AccessConstructor and Description
public
ClasspathEntry(final Object
the classpath entry object (a String or URL or Path).
classpathEntryObj
,
final ClassLoader
the classloader the classpath element was obtained from.
classLoader
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

classLoaderback to summary
public final ClassLoader classLoader

The classloader the classpath element was obtained from.

classpathEntryObjback to summary
public final Object classpathEntryObj

The classpath entry object (a String path, Path, URL or URI).

Constructor Detail

ClasspathEntryback to summary
public ClasspathEntry(final Object classpathEntryObj, final ClassLoader classLoader)

Constructor.

Parameters
classpathEntryObj:Object

the classpath entry object (a String or URL or Path).

classLoader:ClassLoader

the classloader the classpath element was obtained from.

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override