Class ThresholdingInputStream

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

    public abstract class ThresholdingInputStream
    extends java.io.FilterInputStream
    • Field Summary

      • Fields inherited from class java.io.FilterInputStream

        in
    • Constructor Summary

      Constructors 
      Constructor Description
      ThresholdingInputStream​(java.io.InputStream in, int thresholdBytes)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkThreshold()
      Checks whether reading count bytes would cross the limit.
      int getThreshold()  
      void mark​(int readlimit)  
      int read()  
      int read​(byte[] b)  
      int read​(byte[] b, int off, int len)  
      void reset()  
      long skip​(long n)  
      protected abstract void thresholdReached​(int current)
      Called when the threshold is about to be exceeded.
      • Methods inherited from class java.io.FilterInputStream

        available, close, markSupported
      • Methods inherited from class java.io.InputStream

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

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ThresholdingInputStream

        public ThresholdingInputStream​(java.io.InputStream in,
                                       int thresholdBytes)
    • Method Detail

      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class java.io.FilterInputStream
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • checkThreshold

        protected void checkThreshold()
                               throws java.io.IOException
        Checks whether reading count bytes would cross the limit.
        Throws:
        java.io.IOException
      • getThreshold

        public int getThreshold()
        Returns:
        the current threshold value.
      • thresholdReached

        protected abstract void thresholdReached​(int current)
                                          throws java.io.IOException
        Called when the threshold is about to be exceeded. This isn't exact; it's called whenever a write would occur that would cross the amount. Once it is called, it isn't called again.
        Parameters:
        current - is the current number of bytes that have been written
        Throws:
        java.io.IOException