Top Description Inners Fields Constructors Methods
io.github.classgraph

public Class ResourceList

extends PotentiallyUnmodifiableList<Resource>
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.io.IOException, .InputStream, java.net.URI, .URL, java.nio.ByteBuffer, java.util.AbstractMap.SimpleEntry, .ArrayList, .Collection, .Comparator, .HashMap, .List, .Map, .Map.Entry, nonapi.io.github.classgraph.utils.CollectionUtils

An AutoCloseable list of AutoCloseable Resource objects.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ResourceList.ByteArrayConsumer

A FunctionalInterface for consuming the contents of a Resource as a byte array.

public static interface
ResourceList.ByteArrayConsumerThrowsIOException

A FunctionalInterface for consuming the contents of a Resource as a byte array, throwing IOException to the caller if an IO exception occurs.

public static interface
public static interface
ResourceList.ByteBufferConsumerThrowsIOException

A FunctionalInterface for consuming the contents of a Resource as a ByteBuffer, throwing IOException to the caller if an IO exception occurs.

public static interface
public static interface
ResourceList.InputStreamConsumerThrowsIOException

A FunctionalInterface for consuming the contents of a Resource as an InputStream, throwing IOException to the caller if an IO exception occurs.

public static interface
ResourceList.ResourceFilter

Filter a ResourceList using a predicate mapping a Resource object to a boolean, producing another ResourceList for all items in the list for which the predicate is true.

Field Summary

Modifier and TypeField and Description
private static final ResourceList.ResourceFilter
CLASSFILE_FILTER

Returns true if a Resource has a path ending in ".class".

pack-priv static final ResourceList
EMPTY_LIST

An unmodifiable empty ResourceList.

pack-priv static final long
Inherited from io.github.classgraph.PotentiallyUnmodifiableList:
modifiable

Constructor Summary

AccessConstructor and Description
public
ResourceList()

Create a new modifiable empty list of Resource objects.

public
ResourceList(final int
the size hint
sizeHint
)

Create a new modifiable empty list of Resource objects, given a size hint.

public
ResourceList(final Collection<Resource>
the collection of Resource objects.
resourceCollection
)

Create a new modifiable empty ResourceList, given an initial collection of Resource objects.

Method Summary

Modifier and TypeMethod and Description
public Map<String, ResourceList>

Returns:

This ResourceList as a map from resource path (obtained from Resource#getPath()) to a ResourceList of Resource objects that have that path.
asMap
()

Return this ResourceList as a map from resource path (obtained from Resource#getPath()) to a ResourceList of Resource objects that have that path.

public ResourceList

Returns:

A new ResourceList consisting of only the resources with the filename extension ".class".
classFilesOnly
()

Return a new ResourceList consisting of only the resources with the filename extension ".class".

public void
close()

Implements java.lang.AutoCloseable.close.

Close all the Resource objects in this ResourceList.

public static ResourceList

Returns:

the unmodifiable empty ResourceList.
emptyList
()

Return an unmodifiable empty ResourceList.

public ResourceList

Returns:

The subset of the Resource objects in this list for which the given filter predicate is true.
filter
(final ResourceList.ResourceFilter
The ResourceFilter to apply.
filter
)

Find the subset of the Resource objects in this list for which the given filter predicate is true.

public List<Map.Entry<String, ResourceList>>

Returns:

A List of Entry objects for all resources in the classpath and/or module path that have a non-unique path (i.e. where there are at least two resources with the same path). The key of each returned Entry is the path (obtained from Resource#getPath()), and the value is a ResourceList of at least two unique Resource objects that have that path.
findDuplicatePaths
()

Find duplicate resource paths within this ResourceList.

public void
forEachByteArray(final ResourceList.ByteArrayConsumer byteArrayConsumer, final boolean
if true, any IOException thrown while trying to load any of the resources will be silently ignored.
ignoreIOExceptions
)

Fetch the content of each Resource in this ResourceList as a byte array, pass the byte array to the given ByteArrayConsumer, then close the underlying InputStream or release the underlying ByteBuffer by calling Resource#close().

public void
forEachByteArray(final ResourceList.ByteArrayConsumer byteArrayConsumer)

Fetch the content of each Resource in this ResourceList as a byte array, pass the byte array to the given ByteArrayConsumer, then close the underlying InputStream or release the underlying ByteBuffer by calling Resource#close().

public void
forEachByteArrayIgnoringIOException(final ResourceList.ByteArrayConsumer byteArrayConsumer)

Fetch the content of each Resource in this ResourceList as a byte array, pass the byte array to the given ByteArrayConsumer, then close the underlying InputStream or release the underlying ByteBuffer by calling Resource#close() for each Resource.

public void
forEachByteArrayThrowingIOException(final ResourceList.ByteArrayConsumerThrowsIOException byteArrayConsumerThrowsIOException)

Fetch the content of each Resource in this ResourceList as a byte array, pass the byte array to the given ByteArrayConsumer, then close the underlying InputStream or release the underlying ByteBuffer by calling Resource#close().

public void
forEachByteBuffer(final ResourceList.ByteBufferConsumer byteBufferConsumer, final boolean
if true, any IOException thrown while trying to load any of the resources will be silently ignored.
ignoreIOExceptions
)

Read each Resource in this ResourceList as a ByteBuffer, pass the ByteBuffer to the given InputStreamConsumer, then release the ByteBuffer after the ByteBufferConsumer returns, by calling Resource#close() for each Resource.

public void
forEachByteBuffer(final ResourceList.ByteBufferConsumer byteBufferConsumer)

Read each Resource in this ResourceList as a ByteBuffer, pass the ByteBuffer to the given InputStreamConsumer, then release the ByteBuffer after the ByteBufferConsumer returns, by calling Resource#close() for each Resource.

public void
forEachByteBufferIgnoringIOException(final ResourceList.ByteBufferConsumer byteBufferConsumer)

Read each Resource in this ResourceList as a ByteBuffer, pass the ByteBuffer to the given InputStreamConsumer, then release the ByteBuffer after the ByteBufferConsumer returns, by calling Resource#close() for each Resource.

public void
forEachByteBufferThrowingIOException(final ResourceList.ByteBufferConsumerThrowsIOException byteBufferConsumerThrowsIOException)

Read each Resource in this ResourceList as a ByteBuffer, pass the ByteBuffer to the given InputStreamConsumer, then release the ByteBuffer after the ByteBufferConsumer returns, by calling Resource#close().

public void
forEachInputStream(final ResourceList.InputStreamConsumer inputStreamConsumer, final boolean
if true, any IOException thrown while trying to load any of the resources will be silently ignored.
ignoreIOExceptions
)

Fetch an InputStream for each Resource in this ResourceList, pass the InputStream to the given InputStreamConsumer, then close the InputStream after the InputStreamConsumer returns, by calling Resource#close() for each Resource.

public void
forEachInputStream(final ResourceList.InputStreamConsumer inputStreamConsumer)

Fetch an InputStream for each Resource in this ResourceList, pass the InputStream to the given InputStreamConsumer, then close the InputStream after the InputStreamConsumer returns, by calling Resource#close() for each Resource.

public void
forEachInputStreamIgnoringIOException(final ResourceList.InputStreamConsumer inputStreamConsumer)

Fetch an InputStream for each Resource in this ResourceList, pass the InputStream to the given InputStreamConsumer, then close the InputStream after the InputStreamConsumer returns, by calling Resource#close() for each Resource.

public void
forEachInputStreamThrowingIOException(final ResourceList.InputStreamConsumerThrowsIOException inputStreamConsumerThrowsIOException)

Fetch an InputStream for each Resource in this ResourceList, pass the InputStream to the given InputStreamConsumer, then close the InputStream after the InputStreamConsumer returns, by calling Resource#close().

public ResourceList

Returns:

A ResourceList of Resource objects in this list that have the given path (there may be more than one resource with a given path, from different classpath elements or modules, so this returns a ResourceList rather than a single Resource.) Returns the empty list if no resource with is found with a matching path.
get
(final String
The path of a resource
resourcePath
)

Returns a list of all resources with the requested path.

public List<String>

Returns:

The paths of all resources in this list relative to the package root, by calling Resource#getPath() for each item in the list.
getPaths
()

Get the paths of all resources in this list relative to the package root.

public List<String>

Returns:

The paths of all resources in this list relative to the root of the classpath element, by calling Resource#getPathRelativeToClasspathElement() for each item in the list.
getPathsRelativeToClasspathElement
()

Get the paths of all resources in this list relative to the root of the classpath element.

public List<URI>

Returns:

The URIs of all resources in this list.
getURIs
()

Get the URIs of all resources in this list, by calling Resource#getURI() for each item in the list.

public List<URL>

Returns:

The URLs of all resources in this list.
getURLs
()

Get the URLs of all resources in this list, by calling Resource#getURL() for each item in the list.

public ResourceList

Returns:

A new ResourceList consisting of only the resources that do not have the filename extension ".class".
nonClassFilesOnly
()

Return a new ResourceList consisting of non-classfile resources only.

Inherited from io.github.classgraph.PotentiallyUnmodifiableList:
addaddaddAlladdAllclearequalshashCodeiteratorlistIteratormakeUnmodifiableremoveremoveremoveAllretainAllset