Class ArraySlice

java.lang.Object
nonapi.io.github.classgraph.fileslice.Slice
nonapi.io.github.classgraph.fileslice.ArraySlice
All Implemented Interfaces:
Closeable, AutoCloseable

public class ArraySlice extends Slice
A byte array slice.
  • Field Details

    • arr

      public byte[] arr
      The wrapped byte array.
  • Constructor Details

    • 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 slice
      offset - the offset of the sub-slice within the parent slice
      length - the length of the sub-slice
      isDeflatedZipEntry - true if this is a deflated zip entry
      inflatedLengthHint - 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 entry
      inflatedLengthHint - 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 Details

    • slice

      public Slice slice(long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint)
      Slice this slice to form a sub-slice.
      Specified by:
      slice in class Slice
      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 entry
      inflatedLengthHint - 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 IOException
      Load the slice as a byte array.
      Specified by:
      load in class Slice
      Returns:
      the byte[]
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • randomAccessReader

      public RandomAccessReader randomAccessReader()
      Return a new random access reader.
      Specified by:
      randomAccessReader in class Slice
      Returns:
      the random access reader
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Slice
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Slice