Class ArraySlice

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

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

      • arr

        public byte[] arr
        The wrapped byte array.
    • 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 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 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 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 java.io.IOException
        Load the slice as a byte array.
        Specified by:
        load in class Slice
        Returns:
        the byte[]
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class Slice
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Slice