public class NestedJarHandler
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
InterruptionChecker |
interruptionChecker
The interruption checker.
|
SingletonMap<ModuleRef,Recycler<ModuleReaderProxy,java.io.IOException>,java.io.IOException> |
moduleRefToModuleReaderProxyRecyclerMap
A singleton map from a
ModuleRef to a ModuleReaderProxy recycler for the module. |
SingletonMap<java.lang.String,java.util.Map.Entry<LogicalZipFile,java.lang.String>,java.io.IOException> |
nestedPathToLogicalZipFileAndPackageRootMap
A singleton map from nested jarfile path to a tuple of the logical zipfile for the path, and the package root
within the logical zipfile.
|
ScanSpec |
scanSpec
The
ScanSpec. |
static java.lang.String |
TEMP_FILENAME_LEAF_SEPARATOR
The separator between random temp filename part and leafname.
|
| Constructor and Description |
|---|
NestedJarHandler(ScanSpec scanSpec,
InterruptionChecker interruptionChecker)
A handler for nested jars.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(LogNode log)
Close zipfiles, modules, and recyclers, and delete temporary files.
|
java.io.File |
makeTempFile(java.lang.String filePathBase,
boolean onlyUseLeafname)
Create a temporary file, and mark it for deletion on exit.
|
void |
markSliceAsClosed(Slice slice)
Mark a
Slice as closed. |
void |
markSliceAsOpen(Slice slice)
Mark a
Slice as open, so it can be closed when the ScanResult is closed. |
java.io.InputStream |
openInflaterInputStream(java.io.InputStream rawInputStream)
Wrap an
InputStream with an InflaterInputStream, recycling the Inflater instance. |
static byte[] |
readAllBytesAsArray(java.io.InputStream inputStream,
long uncompressedLengthHint)
Read all the bytes in an
InputStream. |
Slice |
readAllBytesWithSpilloverToDisk(java.io.InputStream inputStream,
java.lang.String tempFileBaseName,
long inputStreamLengthHint,
LogNode log)
Read all the bytes in an
InputStream, with spillover to a temporary file on disk if a maximum buffer
size is exceeded. |
public SingletonMap<java.lang.String,java.util.Map.Entry<LogicalZipFile,java.lang.String>,java.io.IOException> nestedPathToLogicalZipFileAndPackageRootMap
public SingletonMap<ModuleRef,Recycler<ModuleReaderProxy,java.io.IOException>,java.io.IOException> moduleRefToModuleReaderProxyRecyclerMap
ModuleRef to a ModuleReaderProxy recycler for the module.public static final java.lang.String TEMP_FILENAME_LEAF_SEPARATOR
public InterruptionChecker interruptionChecker
public NestedJarHandler(ScanSpec scanSpec, InterruptionChecker interruptionChecker)
scanSpec - The ScanSpec.interruptionChecker - the interruption checkerpublic java.io.File makeTempFile(java.lang.String filePathBase,
boolean onlyUseLeafname)
throws java.io.IOException
filePathBase - The path to derive the temporary filename from.onlyUseLeafname - If true, only use the leafname of filePath to derive the temporary filename.File.java.io.IOException - If the temporary file could not be created.public void markSliceAsOpen(Slice slice) throws java.io.IOException
Slice as open, so it can be closed when the ScanResult is closed.slice - the Slice that was just opened.java.io.IOException - Signals that an I/O exception has occurred.public void markSliceAsClosed(Slice slice)
Slice as closed.slice - the Slice to close.public java.io.InputStream openInflaterInputStream(java.io.InputStream rawInputStream)
throws java.io.IOException
InputStream with an InflaterInputStream, recycling the Inflater instance.rawInputStream - the raw input streamjava.io.IOException - Signals that an I/O exception has occurred.public Slice readAllBytesWithSpilloverToDisk(java.io.InputStream inputStream, java.lang.String tempFileBaseName, long inputStreamLengthHint, LogNode log) throws java.io.IOException
InputStream, with spillover to a temporary file on disk if a maximum buffer
size is exceeded.inputStream - the InputStream to read from.tempFileBaseName - the source URL or zip entry that inputStream was opened from (used to name temporary file, if
needed).inputStreamLengthHint - the length of inputStream if known, else -1L.log - the log.InputStream could be read into a byte array, an ArraySlice will be returned.
If this fails and the InputStream is spilled over to disk, a FileSlice will be
returned.java.io.IOException - If the contents could not be read.public static byte[] readAllBytesAsArray(java.io.InputStream inputStream,
long uncompressedLengthHint)
throws java.io.IOException
InputStream.inputStream - The InputStream.uncompressedLengthHint - The length of the data once inflated from the InputStream, if known, otherwise -1L.InputStream as a byte array.java.io.IOException - If the contents could not be read.public void close(LogNode log)
ScanResult.close().log - The log.