Serializable
, AutoCloseable
, Cloneable
, Iterable<Resource>
, Collection<Resource>
, List<Resource>
, RandomAccess
public class ResourceList extends ArrayList<Resource> implements AutoCloseable
Resource
objects.Modifier and Type | Class | Description |
---|---|---|
static interface |
ResourceList.ByteArrayConsumer |
A
FunctionalInterface for consuming the contents of a Resource as a byte array. |
static interface |
ResourceList.ByteBufferConsumer |
|
static interface |
ResourceList.InputStreamConsumer |
|
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. |
modCount
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close all the
Resource objects in this ResourceList . |
ResourceList |
filter(ResourceList.ResourceFilter filter) |
Find the subset of the
Resource objects in this list for which the given filter predicate is true. |
void |
forEachByteArray(ResourceList.ByteArrayConsumer byteArrayConsumer) |
Fetch the content of each
Resource in this ResourceList as a byte array, pass the byte array
to the given ResourceList.ByteArrayConsumer , then close the underlying InputStream or release the underlying
ByteBuffer by calling Resource.close() . |
void |
forEachByteArray(ResourceList.ByteArrayConsumer byteArrayConsumer,
boolean ignoreIOExceptions) |
Fetch the content of each
Resource in this ResourceList as a byte array, pass the byte array
to the given ResourceList.ByteArrayConsumer , then close the underlying InputStream or release the underlying
ByteBuffer by calling Resource.close() . |
void |
forEachByteBuffer(ResourceList.ByteBufferConsumer byteBufferConsumer) |
Read each
Resource in this ResourceList as a ByteBuffer , pass the ByteBuffer
to the given ResourceList.InputStreamConsumer , then release the ByteBuffer after the
ResourceList.ByteBufferConsumer returns, by calling Resource.close() . |
void |
forEachByteBuffer(ResourceList.ByteBufferConsumer byteBufferConsumer,
boolean ignoreIOExceptions) |
Read each
Resource in this ResourceList as a ByteBuffer , pass the ByteBuffer
to the given ResourceList.InputStreamConsumer , then release the ByteBuffer after the
ResourceList.ByteBufferConsumer returns, by calling Resource.close() . |
void |
forEachInputStream(ResourceList.InputStreamConsumer inputStreamConsumer) |
Fetch an
InputStream for each Resource in this ResourceList , pass the
InputStream to the given ResourceList.InputStreamConsumer , then close the InputStream after the
ResourceList.InputStreamConsumer returns, by calling Resource.close() . |
void |
forEachInputStream(ResourceList.InputStreamConsumer inputStreamConsumer,
boolean ignoreIOExceptions) |
Fetch an
InputStream for each Resource in this ResourceList , pass the
InputStream to the given ResourceList.InputStreamConsumer , then close the InputStream after the
ResourceList.InputStreamConsumer returns, by calling Resource.close() . |
List<String> |
getPaths() |
|
List<String> |
getPathsRelativeToClasspathElement() |
|
List<URL> |
getURLs() |
|
String |
toString() |
containsAll
equals, hashCode
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
parallelStream, stream
containsAll, equals, hashCode
public List<String> getPaths()
Resource.getPath()
for each item in the list. For example, given a resource path of
"BOOT-INF/classes/com/xyz/resource.xml" and a package root of "BOOT-INF/classes/", returns
"com/xyz/resource.xml".public List<String> getPathsRelativeToClasspathElement()
Resource.getPathRelativeToClasspathElement()
for each item in the list. For example, given a
resource path of "BOOT-INF/classes/com/xyz/resource.xml", returns
"BOOT-INF/classes/com/xyz/resource.xml" (even if the package root is "BOOT-INF/classes/").public List<URL> getURLs()
Resource.getURL()
for each item in the
list.public ResourceList filter(ResourceList.ResourceFilter filter)
Resource
objects in this list for which the given filter predicate is true.filter
- The ResourceList.ResourceFilter
to apply.Resource
objects in this list for which the given filter predicate is true.public void forEachByteArray(ResourceList.ByteArrayConsumer byteArrayConsumer, boolean ignoreIOExceptions)
Resource
in this ResourceList
as a byte array, pass the byte array
to the given ResourceList.ByteArrayConsumer
, then close the underlying InputStream or release the underlying
ByteBuffer by calling Resource.close()
.byteArrayConsumer
- The ResourceList.ByteArrayConsumer
.ignoreIOExceptions
- if true, any IOException
thrown while trying to load any of the resources will be silently
ignored.IllegalArgumentException
- if ignoreExceptions is false, and an IOException
is thrown while trying to load any of
the resources.public void forEachByteArray(ResourceList.ByteArrayConsumer byteArrayConsumer)
Resource
in this ResourceList
as a byte array, pass the byte array
to the given ResourceList.ByteArrayConsumer
, then close the underlying InputStream or release the underlying
ByteBuffer by calling Resource.close()
.byteArrayConsumer
- The ResourceList.ByteArrayConsumer
.IllegalArgumentException
- if trying to load any of the resources results in an IOException
being thrown.public void forEachInputStream(ResourceList.InputStreamConsumer inputStreamConsumer, boolean ignoreIOExceptions)
InputStream
for each Resource
in this ResourceList
, pass the
InputStream
to the given ResourceList.InputStreamConsumer
, then close the InputStream
after the
ResourceList.InputStreamConsumer
returns, by calling Resource.close()
.inputStreamConsumer
- The ResourceList.InputStreamConsumer
.ignoreIOExceptions
- if true, any IOException
thrown while trying to load any of the resources will be silently
ignored.IllegalArgumentException
- if ignoreExceptions is false, and an IOException
is thrown while trying to open any of
the resources.public void forEachInputStream(ResourceList.InputStreamConsumer inputStreamConsumer)
InputStream
for each Resource
in this ResourceList
, pass the
InputStream
to the given ResourceList.InputStreamConsumer
, then close the InputStream
after the
ResourceList.InputStreamConsumer
returns, by calling Resource.close()
.inputStreamConsumer
- The ResourceList.InputStreamConsumer
.IllegalArgumentException
- if trying to open any of the resources results in an IOException
being thrown.public void forEachByteBuffer(ResourceList.ByteBufferConsumer byteBufferConsumer, boolean ignoreIOExceptions)
Resource
in this ResourceList
as a ByteBuffer
, pass the ByteBuffer
to the given ResourceList.InputStreamConsumer
, then release the ByteBuffer
after the
ResourceList.ByteBufferConsumer
returns, by calling Resource.close()
.byteBufferConsumer
- The ResourceList.ByteBufferConsumer
.ignoreIOExceptions
- if true, any IOException
thrown while trying to load any of the resources will be silently
ignored.IllegalArgumentException
- if ignoreExceptions is false, and an IOException
is thrown while trying to load any of
the resources.public void forEachByteBuffer(ResourceList.ByteBufferConsumer byteBufferConsumer)
Resource
in this ResourceList
as a ByteBuffer
, pass the ByteBuffer
to the given ResourceList.InputStreamConsumer
, then release the ByteBuffer
after the
ResourceList.ByteBufferConsumer
returns, by calling Resource.close()
.byteBufferConsumer
- The ResourceList.ByteBufferConsumer
.IllegalArgumentException
- if trying to load any of the resources results in an IOException
being thrown.public String toString()
toString
in class AbstractCollection<Resource>
public void close()
Resource
objects in this ResourceList
.close
in interface AutoCloseable
Copyright © 2018. All rights reserved.