Class LoggingReader

All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class LoggingReader extends WrappedReader
A wrapper around an Reader that logs read and skip actions.
Since:
9.3.8
Author:
Philip Helger
  • Constructor Details

    • LoggingReader

      public LoggingReader(@NonNull Reader aSourceReader)
      Parameters:
      aSourceReader - The reader that should be logged. May not be null.
  • Method Details

    • getPosition

      public final long getPosition()
      Returns:
      The current read position. Always ≥ 0.
    • onRead

      @OverrideOnDemand protected void onRead(int nBytesRead, long nNewPosition)
    • onSkip

      @OverrideOnDemand protected void onSkip(long nBytesSkipped, long nNewPosition)
    • onMark

      @OverrideOnDemand protected void onMark(int nReadLimit, long nCurrentPosition)
    • onReset

      @OverrideOnDemand protected void onReset(long nCurrentPosition)
    • onClose

      @OverrideOnDemand protected void onClose(long nCurrentPosition)
    • read

      public final int read() throws IOException
      Overrides:
      read in class FilterReader
      Throws:
      IOException
    • read

      public final int read(char[] aBuf, int nOffset, int nLength) throws IOException
      Overrides:
      read in class FilterReader
      Throws:
      IOException
    • skip

      public final long skip(@Nonnegative long n) throws IOException
      Overrides:
      skip in class FilterReader
      Throws:
      IOException
    • mark

      public final void mark(@Nonnegative int nReadlimit) throws IOException
      Overrides:
      mark in class FilterReader
      Throws:
      IOException
    • reset

      public final void reset() throws IOException
      Overrides:
      reset in class FilterReader
      Throws:
      IOException
    • close

      public final void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterReader
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class WrappedReader