Top Description Fields Constructors Methods
nonapi.io.github.classgraph.fastzipfilereader

public Class ZipFileSlice

extends Object
Class Inheritance
Known Direct Subclasses
nonapi.io.github.classgraph.fastzipfilereader.LogicalZipFile
Imports
java.io.File, .IOException, java.nio.file.Path, java.util.Objects, nonapi.io.github.classgraph.fileslice.Slice, nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectLeafname

A zipfile slice (a sub-range of bytes within a PhysicalZipFile.

Field Summary

Modifier and TypeField and Description
private final ZipFileSlice
parentZipFileSlice

The parent slice, or null if this is the toplevel slice (the whole zipfile).

private final String
pathWithinParentZipFileSlice

For the toplevel zipfile slice, the zipfile path; For nested slices, the name/path of the zipfile entry.

protected final PhysicalZipFile
physicalZipFile

The underlying physical zipfile.

public Slice
slice

The Slice containing the zipfile.

Constructor Summary

AccessConstructor and Description
pack-priv
ZipFileSlice(final PhysicalZipFile
the physical zipfile
physicalZipFile
)

Create a ZipFileSlice that wraps a toplevel PhysicalZipFile.

pack-priv
ZipFileSlice(final PhysicalZipFile
a physical zipfile that has been extracted to RAM
physicalZipFile
,
final FastZipEntry
the zip entry
zipEntry
)

Create a ZipFileSlice that wraps a PhysicalZipFile that was extracted or inflated from a nested jar to memory or disk.

pack-priv
ZipFileSlice(final FastZipEntry
the zip entry
zipEntry
)

Create a ZipFileSlice that wraps a single stored (not deflated) FastZipEntry.

pack-priv
ZipFileSlice(final ZipFileSlice
the ZipFileSlice to clone.
other
)

Clone constructor.

Method Summary

Modifier and TypeMethod and Description
private void
appendPath(final StringBuilder
the buf to append the path to
buf
)

Recursively append the path in top down ancestral order.

public boolean
equals(final Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public ZipFileSlice

Returns:

the parent ZipFileslice, or null if this is a toplevel slice.
getParentZipFileSlice
()

Get the parent ZipFileslice, or return null if this is a toplevel slice (i.e. if this slice wraps an entire physical zipfile).

public String

Returns:

the path of this zipfile slice.
getPath
()

Get the path of this zipfile slice, e.g. "/path/to/jarfile.jar!/nestedjar1.jar".

public String

Returns:

the name of the slice.
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).

public File

Returns:

the physical File that this ZipFileSlice is a slice of, or null if this file was downloaded from a URL directly to RAM.
getPhysicalFile
()

Get the physical File that this ZipFileSlice is a slice of.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if this zipfile slice and all of its parent slices are accepted and not rejected in the jarfile accept/reject criteria.
isAcceptedAndNotRejected
(final AcceptReject.AcceptRejectLeafname
the jar accept/reject criteria
jarAcceptReject
)

Check whether this zipfile slice and all of its parent slices are accepted and not rejected in the jarfile accept/reject criteria.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

parentZipFileSliceback to summary
private final ZipFileSlice parentZipFileSlice

The parent slice, or null if this is the toplevel slice (the whole zipfile).

pathWithinParentZipFileSliceback to summary
private final String pathWithinParentZipFileSlice

For the toplevel zipfile slice, the zipfile path; For nested slices, the name/path of the zipfile entry.

physicalZipFileback to summary
protected final PhysicalZipFile physicalZipFile

The underlying physical zipfile.

sliceback to summary
public Slice slice

The Slice containing the zipfile.

Constructor Detail

ZipFileSliceback to summary
pack-priv ZipFileSlice(final PhysicalZipFile physicalZipFile)

Create a ZipFileSlice that wraps a toplevel PhysicalZipFile.

Parameters
physicalZipFile:PhysicalZipFile

the physical zipfile

ZipFileSliceback to summary
pack-priv ZipFileSlice(final PhysicalZipFile physicalZipFile, final FastZipEntry zipEntry)

Create a ZipFileSlice that wraps a PhysicalZipFile that was extracted or inflated from a nested jar to memory or disk.

Parameters
physicalZipFile:PhysicalZipFile

a physical zipfile that has been extracted to RAM

zipEntry:FastZipEntry

the zip entry

ZipFileSliceback to summary
pack-priv ZipFileSlice(final FastZipEntry zipEntry) throws IOException, InterruptedException

Create a ZipFileSlice that wraps a single stored (not deflated) FastZipEntry.

Parameters
zipEntry:FastZipEntry

the zip entry

Exceptions
IOException:
If an I/O exception occurs.
InterruptedException:
If the thread was interrupted.
ZipFileSliceback to summary
pack-priv ZipFileSlice(final ZipFileSlice other)

Clone constructor.

Parameters
other:ZipFileSlice

the ZipFileSlice to clone.

Method Detail

appendPathback to summary
private void appendPath(final StringBuilder buf)

Recursively append the path in top down ancestral order.

Parameters
buf:StringBuilder

the buf to append the path to

equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getParentZipFileSliceback to summary
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:ZipFileSlice

the parent ZipFileslice, or null if this is a toplevel slice.

getPathback to summary
public String getPath()

Get the path of this zipfile slice, e.g. "/path/to/jarfile.jar!/nestedjar1.jar".

Returns:String

the path of this zipfile slice.

getPathWithinParentZipFileSliceback to summary
public 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:String

the name of the slice.

getPhysicalFileback to summary
public File getPhysicalFile()

Get the physical File that this ZipFileSlice is a slice of.

Returns:File

the physical File that this ZipFileSlice is a slice of, or null if this file was downloaded from a URL directly to RAM.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isAcceptedAndNotRejectedback to summary
public boolean isAcceptedAndNotRejected(final 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:AcceptReject.AcceptRejectLeafname

the jar accept/reject criteria

Returns:boolean

true if this zipfile slice and all of its parent slices are accepted and not rejected in the jarfile accept/reject criteria.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override