Top Description Fields Constructors Methods
io.github.classgraph

public Class ModuleReaderProxy

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.Closeable, .IOException, .InputStream, java.net.URI, java.nio.ByteBuffer, java.util.List, nonapi.io.github.classgraph.reflection.ReflectionUtils

A ModuleReader proxy, written using reflection to preserve backwards compatibility with JDK 7 and 8.

Field Summary

Modifier and TypeField and Description
private static Class<?>
collectorClass

Class<collector> collectorClass = Class.forName("java.util.stream.Collector");

private static Object
collectorsToList

Collector<object, ?, list collectorsToList = Collectors.toList();

private final AutoCloseable
moduleReader

The module reader.

private ReflectionUtils

Constructor Summary

AccessConstructor and Description
pack-priv
ModuleReaderProxy(final ModuleRef
the module ref
moduleRef
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Calls ModuleReader#close().

public URI

Returns:

A URI for the resource.
find
(final String
The path to the resource to open.
path
)

Use the proxied ModuleReader to find the named resource as a URI.

public List<String>

Returns:

A list of the paths of resources in the module.
list
()

Get the list of resources accessible to a ModuleReader.

public InputStream

Returns:

An InputStream for the content of the resource.
open
(final String
The path to the resource to open.
path
)

Use the proxied ModuleReader to open the named resource as an InputStream.

public ByteBuffer

Returns:

A ByteBuffer for the content of the resource.
read
(final String
The path to the resource to open.
path
)

Use the proxied ModuleReader to open the named resource as a ByteBuffer.

public void
release(final ByteBuffer
The ByteBuffer to release.
byteBuffer
)

Release a ByteBuffer allocated by calling read(String).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

collectorClassback to summary
private static Class<?> collectorClass

Class collectorClass = Class.forName("java.util.stream.Collector");

collectorsToListback to summary
private static Object collectorsToList

Collector> collectorsToList = Collectors.toList();

moduleReaderback to summary
private final AutoCloseable moduleReader

The module reader.

reflectionUtilsback to summary
private ReflectionUtils reflectionUtils

Constructor Detail

ModuleReaderProxyback to summary
pack-priv ModuleReaderProxy(final ModuleRef moduleRef) throws IOException

Constructor.

Parameters
moduleRef:ModuleRef

the module ref

Exceptions
IOException:
If an I/O exception occurs.

Method Detail

closeback to summary
public void close()

Implements java.io.Closeable.close.

Calls ModuleReader#close().

Annotations
@Override
findback to summary
public URI find(final String path)

Use the proxied ModuleReader to find the named resource as a URI.

Parameters
path:String

The path to the resource to open.

Returns:URI

A URI for the resource.

Exceptions
SecurityException:
If the module cannot be accessed.
listback to summary
public List<String> list() throws SecurityException

Get the list of resources accessible to a ModuleReader. From the documentation for ModuleReader#list(): "Whether the stream of elements includes names corresponding to directories in the module is module reader specific. In lazy implementations then an IOException may be thrown when using the stream to list the module contents. If this occurs then the IOException will be wrapped in an java.io.UncheckedIOException and thrown from the method that caused the access to be attempted. SecurityException may also be thrown when using the stream to list the module contents and access is denied by the security manager."

Returns:List<String>

A list of the paths of resources in the module.

Exceptions
SecurityException:
If the module cannot be accessed.
openback to summary
public InputStream open(final String path) throws SecurityException

Use the proxied ModuleReader to open the named resource as an InputStream.

Parameters
path:String

The path to the resource to open.

Returns:InputStream

An InputStream for the content of the resource.

Exceptions
SecurityException:
If the module cannot be accessed.
IllegalArgumentException:
If the module cannot be accessed.
readback to summary
public ByteBuffer read(final String path) throws SecurityException, OutOfMemoryError

Use the proxied ModuleReader to open the named resource as a ByteBuffer. Call release(ByteBuffer) when you have finished with the ByteBuffer.

Parameters
path:String

The path to the resource to open.

Returns:ByteBuffer

A ByteBuffer for the content of the resource.

Exceptions
SecurityException:
If the module cannot be accessed.
OutOfMemoryError:
if the resource is larger than 2GB, the maximum capacity of a byte buffer.
releaseback to summary
public void release(final ByteBuffer byteBuffer)

Release a ByteBuffer allocated by calling read(String).

Parameters
byteBuffer:ByteBuffer

The ByteBuffer to release.