• Field Detail

      • cache

        protected byte[] cache

        The byte cache itself.

      • ptr

        protected int ptr

        The 0-based index into cache of the _next_ byte to return. If ptr == validLen, data must be read from the stream into the cache.

      • validLen

        protected int validLen

        A count of the number of bytes in cache that contain data read from the stream.

      • in

        protected InputStream in

        The underlying input stream whose data we're caching

    • Method Detail

      • seek

        public void seek​(long pos)
                  throws IOException

        Description copied from interface: Seekable

        Moves the pointer in the inputstream such that the byte starting at pos are returned by the next read.

        Specified by:
        seek in interface Seekable
        Parameters:
        pos - the position to which to seek
        Throws:
        IOException - when there's an I/O problem
      • expandCache

        protected void expandCache​(int additionalBytes)

        Expands the cache to hold some number of additionalBytes. Expansion is done multiplicatively for efficiency. Immediately after calling this method, you must fill the additional bytes from the stream because this method also updates validLen.