Class ZipFileSlice
- java.lang.Object
-
- nonapi.io.github.classgraph.fastzipfilereader.ZipFileSlice
-
- Direct Known Subclasses:
LogicalZipFile
public class ZipFileSlice extends java.lang.ObjectA zipfile slice (a sub-range of bytes within a PhysicalZipFile.
-
-
Field Summary
Fields Modifier and Type Field Description private ZipFileSliceparentZipFileSliceThe parent slice, or null if this is the toplevel slice (the whole zipfile).private java.lang.StringpathWithinParentZipFileSliceFor the toplevel zipfile slice, the zipfile path; For nested slices, the name/path of the zipfile entry.protected PhysicalZipFilephysicalZipFileThe underlying physical zipfile.SlicesliceTheSlicecontaining the zipfile.
-
Constructor Summary
Constructors Constructor Description ZipFileSlice(FastZipEntry zipEntry)Create a ZipFileSlice that wraps a single stored (not deflated)FastZipEntry.ZipFileSlice(PhysicalZipFile physicalZipFile)Create a ZipFileSlice that wraps a toplevelPhysicalZipFile.ZipFileSlice(PhysicalZipFile physicalZipFile, FastZipEntry zipEntry)Create a ZipFileSlice that wraps aPhysicalZipFilethat was extracted or inflated from a nested jar to memory or disk.ZipFileSlice(ZipFileSlice other)Clone constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendPath(java.lang.StringBuilder buf)Recursively append the path in top down ancestral order.booleanequals(java.lang.Object o)ZipFileSlicegetParentZipFileSlice()Get the parent ZipFileslice, or return null if this is a toplevel slice (i.e.java.lang.StringgetPath()Get the path of this zipfile slice, e.g.java.lang.StringgetPathWithinParentZipFileSlice()Get the name of the slice (either the entry name/path within the parent zipfile slice, or the path of the physical zipfile if this slice is a toplevel slice (i.e.java.io.FilegetPhysicalFile()Get the physicalFilethat this ZipFileSlice is a slice of.inthashCode()booleanisAcceptedAndNotRejected(AcceptReject.AcceptRejectLeafname jarAcceptReject)Check whether this zipfile slice and all of its parent slices are accepted and not rejected in the jarfile accept/reject criteria.java.lang.StringtoString()
-
-
-
Field Detail
-
parentZipFileSlice
private final ZipFileSlice parentZipFileSlice
The parent slice, or null if this is the toplevel slice (the whole zipfile).
-
physicalZipFile
protected final PhysicalZipFile physicalZipFile
The underlying physical zipfile.
-
pathWithinParentZipFileSlice
private final java.lang.String pathWithinParentZipFileSlice
For the toplevel zipfile slice, the zipfile path; For nested slices, the name/path of the zipfile entry.
-
-
Constructor Detail
-
ZipFileSlice
ZipFileSlice(PhysicalZipFile physicalZipFile)
Create a ZipFileSlice that wraps a toplevelPhysicalZipFile.- Parameters:
physicalZipFile- the physical zipfile
-
ZipFileSlice
ZipFileSlice(PhysicalZipFile physicalZipFile, FastZipEntry zipEntry)
Create a ZipFileSlice that wraps aPhysicalZipFilethat was extracted or inflated from a nested jar to memory or disk.- Parameters:
physicalZipFile- a physical zipfile that has been extracted to RAMzipEntry- the zip entry
-
ZipFileSlice
ZipFileSlice(FastZipEntry zipEntry) throws java.io.IOException, java.lang.InterruptedException
Create a ZipFileSlice that wraps a single stored (not deflated)FastZipEntry.- Parameters:
zipEntry- the zip entry- Throws:
java.io.IOException- If an I/O exception occurs.java.lang.InterruptedException- If the thread was interrupted.
-
ZipFileSlice
ZipFileSlice(ZipFileSlice other)
Clone constructor.- Parameters:
other- theZipFileSliceto clone.
-
-
Method Detail
-
isAcceptedAndNotRejected
public boolean isAcceptedAndNotRejected(AcceptReject.AcceptRejectLeafname jarAcceptReject)
Check whether this zipfile slice and all of its parent slices are accepted and not rejected in the jarfile accept/reject criteria.- Parameters:
jarAcceptReject- the jar accept/reject criteria- Returns:
- true if this zipfile slice and all of its parent slices are accepted and not rejected in the jarfile accept/reject criteria.
-
getParentZipFileSlice
public ZipFileSlice getParentZipFileSlice()
Get the parent ZipFileslice, or return null if this is a toplevel slice (i.e. if this slice wraps an entire physical zipfile).- Returns:
- the parent ZipFileslice, or null if this is a toplevel slice.
-
getPathWithinParentZipFileSlice
public java.lang.String getPathWithinParentZipFileSlice()
Get the name of the slice (either the entry name/path within the parent zipfile slice, or the path of the physical zipfile if this slice is a toplevel slice (i.e. if this slice wraps an entire physical zipfile).- Returns:
- the name of the slice.
-
appendPath
private void appendPath(java.lang.StringBuilder buf)
Recursively append the path in top down ancestral order.- Parameters:
buf- the buf to append the path to
-
getPath
public java.lang.String getPath()
Get the path of this zipfile slice, e.g. "/path/to/jarfile.jar!/nestedjar1.jar".- Returns:
- the path of this zipfile slice.
-
getPhysicalFile
public java.io.File getPhysicalFile()
Get the physicalFilethat this ZipFileSlice is a slice of.- Returns:
- the physical
Filethat this ZipFileSlice is a slice of, or null if this file was downloaded from a URL directly to RAM.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-