Class PhysicalZipFile
- java.lang.Object
-
- nonapi.io.github.classgraph.fastzipfilereader.PhysicalZipFile
-
class PhysicalZipFile extends java.lang.Object
A physical zipfile, which is mmap'd using aFileChannel
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
file
TheFile
backing thisPhysicalZipFile
, if any.private int
hashCode
The cached hashCode.(package private) NestedJarHandler
nestedJarHandler
The nested jar handler.private java.nio.file.Path
path
ThePath
backing thisPhysicalZipFile
, if any.private java.lang.String
pathStr
The path to the zipfile.(package private) Slice
slice
TheSlice
for the zipfile.
-
Constructor Summary
Constructors Constructor Description PhysicalZipFile(byte[] arr, java.io.File outermostFile, java.lang.String pathStr, NestedJarHandler nestedJarHandler)
Construct aPhysicalZipFile
from a byte array.PhysicalZipFile(java.io.File file, NestedJarHandler nestedJarHandler, LogNode log)
Construct aPhysicalZipFile
from a file on disk.PhysicalZipFile(java.io.InputStream inputStream, long inputStreamLengthHint, java.lang.String pathStr, NestedJarHandler nestedJarHandler, LogNode log)
Construct aPhysicalZipFile
by reading from theInputStream
to an array in RAM, or spill to disk if theInputStream
is too long.PhysicalZipFile(java.nio.file.Path path, NestedJarHandler nestedJarHandler, LogNode log)
Construct aPhysicalZipFile
from aPath
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.io.File
getFile()
Get theFile
for the outermost jar file of this PhysicalZipFile.java.nio.file.Path
getPath()
Get thePath
for the outermost jar file of this PhysicalZipFile.java.lang.String
getPathStr()
Get the path for this PhysicalZipFile, which is the file path, if it is file-backed, or a compound nested jar path, if it is memory-backed.int
hashCode()
long
length()
Get the length of the mapped file, or the initial remaining bytes in the wrapped ByteBuffer if a buffer was wrapped.java.lang.String
toString()
-
-
-
Field Detail
-
path
private java.nio.file.Path path
ThePath
backing thisPhysicalZipFile
, if any.
-
file
private java.io.File file
TheFile
backing thisPhysicalZipFile
, if any.
-
pathStr
private final java.lang.String pathStr
The path to the zipfile.
-
nestedJarHandler
NestedJarHandler nestedJarHandler
The nested jar handler.
-
hashCode
private int hashCode
The cached hashCode.
-
-
Constructor Detail
-
PhysicalZipFile
PhysicalZipFile(java.io.File file, NestedJarHandler nestedJarHandler, LogNode log) throws java.io.IOException
Construct aPhysicalZipFile
from a file on disk.- Parameters:
file
- the filenestedJarHandler
- the nested jar handlerlog
- the log- Throws:
java.io.IOException
- if an I/O exception occurs.
-
PhysicalZipFile
PhysicalZipFile(java.nio.file.Path path, NestedJarHandler nestedJarHandler, LogNode log) throws java.io.IOException
Construct aPhysicalZipFile
from aPath
.- Parameters:
path
- the pathnestedJarHandler
- the nested jar handlerlog
- the log- Throws:
java.io.IOException
- if an I/O exception occurs.
-
PhysicalZipFile
PhysicalZipFile(byte[] arr, java.io.File outermostFile, java.lang.String pathStr, NestedJarHandler nestedJarHandler) throws java.io.IOException
Construct aPhysicalZipFile
from a byte array.- Parameters:
arr
- the array containing the zipfile.outermostFile
- the outermost filepathStr
- the pathnestedJarHandler
- the nested jar handler- Throws:
java.io.IOException
- if an I/O exception occurs.
-
PhysicalZipFile
PhysicalZipFile(java.io.InputStream inputStream, long inputStreamLengthHint, java.lang.String pathStr, NestedJarHandler nestedJarHandler, LogNode log) throws java.io.IOException
Construct aPhysicalZipFile
by reading from theInputStream
to an array in RAM, or spill to disk if theInputStream
is too long.- Parameters:
inputStream
- the input streaminputStreamLengthHint
- The number of bytes to read in inputStream, or -1 if unknown.pathStr
- the source URL the InputStream was opened from, or the zip entry path of this entry in the parent zipfilenestedJarHandler
- the nested jar handlerlog
- the log- Throws:
java.io.IOException
- if an I/O exception occurs.
-
-
Method Detail
-
getPath
public java.nio.file.Path getPath()
Get thePath
for the outermost jar file of this PhysicalZipFile.- Returns:
- the
Path
for the outermost jar file of this PhysicalZipFile, or null if this file was downloaded from a URL directly to RAM, or is backed by aFile
.
-
getFile
public java.io.File getFile()
Get theFile
for the outermost jar file of this PhysicalZipFile.- Returns:
- the
File
for the outermost jar file of this PhysicalZipFile, or null if this file was downloaded from a URL directly to RAM, or is backed by aPath
.
-
getPathStr
public java.lang.String getPathStr()
Get the path for this PhysicalZipFile, which is the file path, if it is file-backed, or a compound nested jar path, if it is memory-backed.- Returns:
- the path for this PhysicalZipFile, which is the file path, if it is file-backed, or a compound nested jar path, if it is memory-backed.
-
length
public long length()
Get the length of the mapped file, or the initial remaining bytes in the wrapped ByteBuffer if a buffer was wrapped.- Returns:
- the length of the mapped file
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-