Class ArraySlice
- java.lang.Object
-
- nonapi.io.github.classgraph.fileslice.Slice
-
- nonapi.io.github.classgraph.fileslice.ArraySlice
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ArraySlice extends Slice
A byte array slice.
-
-
Field Summary
Fields Modifier and Type Field Description byte[]
arr
The wrapped byte array.-
Fields inherited from class nonapi.io.github.classgraph.fileslice.Slice
inflatedLengthHint, isDeflatedZipEntry, nestedJarHandler, parentSlice, sliceLength, sliceStartPos
-
-
Constructor Summary
Constructors Modifier Constructor Description ArraySlice(byte[] arr, boolean isDeflatedZipEntry, long inflatedLengthHint, NestedJarHandler nestedJarHandler)
Constructor for treating a whole array as a slice.private
ArraySlice(ArraySlice parentSlice, long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint, NestedJarHandler nestedJarHandler)
Constructor for treating a range of an array as a slice.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
int
hashCode()
byte[]
load()
Load the slice as a byte array.RandomAccessReader
randomAccessReader()
Return a new random access reader.Slice
slice(long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint)
Slice this slice to form a sub-slice.
-
-
-
Constructor Detail
-
ArraySlice
private ArraySlice(ArraySlice parentSlice, long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint, NestedJarHandler nestedJarHandler)
Constructor for treating a range of an array as a slice.- Parameters:
parentSlice
- the parent sliceoffset
- the offset of the sub-slice within the parent slicelength
- the length of the sub-sliceisDeflatedZipEntry
- true if this is a deflated zip entryinflatedLengthHint
- the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated zip entry.nestedJarHandler
- the nested jar handler
-
ArraySlice
public ArraySlice(byte[] arr, boolean isDeflatedZipEntry, long inflatedLengthHint, NestedJarHandler nestedJarHandler)
Constructor for treating a whole array as a slice.- Parameters:
arr
- the array containing the slice.isDeflatedZipEntry
- true if this is a deflated zip entryinflatedLengthHint
- the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated zip entry.nestedJarHandler
- the nested jar handler
-
-
Method Detail
-
slice
public Slice slice(long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint)
Slice this slice to form a sub-slice.- Specified by:
slice
in classSlice
- Parameters:
offset
- the offset relative to the start of this slice to use as the start of the sub-slice.length
- the length of the sub-slice.isDeflatedZipEntry
- the is deflated zip entryinflatedLengthHint
- the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated zip entry.- Returns:
- the slice
-
load
public byte[] load() throws java.io.IOException
Load the slice as a byte array.
-
randomAccessReader
public RandomAccessReader randomAccessReader()
Return a new random access reader.- Specified by:
randomAccessReader
in classSlice
- Returns:
- the random access reader
-
-