Class TailOverridingRebufferer

  • All Implemented Interfaces:
    java.lang.AutoCloseable, ReaderFileProxy, Rebufferer, Rebufferer.BufferHolder

    @NotThreadSafe
    public class TailOverridingRebufferer
    extends WrappingRebufferer
    Special rebufferer that replaces the tail of the file (from the specified cutoff point) with the given buffer.

    Instantiated once per RandomAccessReader, thread-unsafe. The instances reuse themselves as the BufferHolder to avoid having to return a new object for each rebuffer call. Only one BufferHolder can be active at a time. Calling rebuffer(long) before the previously obtained buffer holder is released will throw AssertionError.

    • Constructor Detail

      • TailOverridingRebufferer

        public TailOverridingRebufferer​(Rebufferer source,
                                        long cutoff,
                                        java.nio.ByteBuffer tail)
    • Method Detail

      • rebuffer

        public Rebufferer.BufferHolder rebuffer​(long position)
        Description copied from interface: Rebufferer
        Rebuffer (move on or seek to) a given position, and return a buffer that can be used there. The only guarantee about the size of the returned data is that unless rebuffering at the end of the file, the buffer will not be empty and will contain the requested position, i.e. offset <= position < offset + bh.buffer().limit(), but the buffer will not be positioned there.
        Specified by:
        rebuffer in interface Rebufferer
        Overrides:
        rebuffer in class WrappingRebufferer