Class FastMultiByteArrayInputStream

    • Field Summary

      Fields 
      Modifier and Type Field Description
      byte[][] array
      The array of arrays backing the input stream, plus an additional null entry.
      byte[] current
      The current array.
      long length
      The number of valid bytes in array.
      static int SLICE_BITS
      The number of bits of an array slice index.
      static int SLICE_MASK
      The mask to retrieve a slice offset.
      static int SLICE_SIZE
      The maximum length of an array slice.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Returns the number of bytes that can be read (or skipped over) from this input stream without blocking.
      void close()
      NOP.
      long length()
      Returns the overall length of this stream (optional operation).
      void mark​(int dummy)  
      boolean markSupported()  
      long position()
      Returns the current stream position.
      void position​(long newPosition)
      Sets the current stream position.
      int read()  
      int read​(byte[] b, int offset, int length)  
      void reset()  
      long skip​(long n)  
      • Methods inherited from class java.io.InputStream

        nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SLICE_BITS

        public static final int SLICE_BITS
        The number of bits of an array slice index.
        See Also:
        Constant Field Values
      • SLICE_SIZE

        public static final int SLICE_SIZE
        The maximum length of an array slice.
        See Also:
        Constant Field Values
      • SLICE_MASK

        public static final int SLICE_MASK
        The mask to retrieve a slice offset.
        See Also:
        Constant Field Values
      • array

        public byte[][] array
        The array of arrays backing the input stream, plus an additional null entry.
      • current

        public byte[] current
        The current array.
      • length

        public long length
        The number of valid bytes in array.
    • Constructor Detail

      • FastMultiByteArrayInputStream

        public FastMultiByteArrayInputStream​(MeasurableInputStream is)
                                      throws java.io.IOException
        Creates a new multi-array input stream loading it from a measurable input stream.
        Parameters:
        is - the input stream that will fill the array.
        Throws:
        java.io.IOException
      • FastMultiByteArrayInputStream

        public FastMultiByteArrayInputStream​(java.io.InputStream is,
                                             long size)
                                      throws java.io.IOException
        Creates a new multi-array input stream loading it from an input stream.
        Parameters:
        is - the input stream that will fill the array.
        size - the number of bytes to be read from is.
        Throws:
        java.io.IOException
      • FastMultiByteArrayInputStream

        public FastMultiByteArrayInputStream​(FastMultiByteArrayInputStream is)
        Creates a new multi-array input stream sharing the backing arrays of another multi-array input stream.
        Parameters:
        is - the multi-array input stream to replicate.
      • FastMultiByteArrayInputStream

        public FastMultiByteArrayInputStream​(byte[] array)
        Creates a new multi-array input stream using a given array.
        Parameters:
        array - the backing array.
    • Method Detail

      • available

        public int available()
        Returns the number of bytes that can be read (or skipped over) from this input stream without blocking.

        Note that this number may be smaller than the number of bytes actually available from the stream if this number exceeds Integer.MAX_VALUE.

        Overrides:
        available in class java.io.InputStream
        Returns:
        the minimum among the number of available bytes and Integer.MAX_VALUE.
      • skip

        public long skip​(long n)
        Overrides:
        skip in class java.io.InputStream
      • read

        public int read()
        Specified by:
        read in class java.io.InputStream
      • read

        public int read​(byte[] b,
                        int offset,
                        int length)
        Overrides:
        read in class java.io.InputStream
      • position

        public void position​(long newPosition)
        Description copied from interface: RepositionableStream
        Sets the current stream position.
        Specified by:
        position in interface RepositionableStream
        Parameters:
        newPosition - the new stream position.
      • length

        public long length()
                    throws java.io.IOException
        Description copied from interface: MeasurableStream
        Returns the overall length of this stream (optional operation). In most cases, this will require the stream to perform some extra action, possibly changing the state of the input stream itself (typically, reading all the bytes up to the end, or flushing on output stream). Implementing classes should always document what state will the input stream be in after calling this method, and which kind of exception could be thrown.
        Specified by:
        length in interface MeasurableStream
        Throws:
        java.io.IOException
      • close

        public void close()
        NOP.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.InputStream
      • mark

        public void mark​(int dummy)
        Overrides:
        mark in class java.io.InputStream
      • reset

        public void reset()
        Overrides:
        reset in class java.io.InputStream