Class BufferingInputBase<T>

  • All Implemented Interfaces:
    Input<T>, java.io.Closeable, java.lang.AutoCloseable

    public abstract class BufferingInputBase<T>
    extends ListInput<T>
    An abstract input which is designed to load more items when it's needed to get more items. Not thread safe.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int capacity  
      • Fields inherited from interface com.github.akurilov.commons.io.Input

        DELIMITER
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferingInputBase​(int capacity)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Does nothing
      T get()
      Get next item
      int get​(java.util.List<T> buffer, int maxCount)
      Bulk get into the specified buffer
      protected abstract int loadMoreItems​(T lastItem)
      Called when the elements buffer is exhausted.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • capacity

        protected final int capacity
    • Constructor Detail

      • BufferingInputBase

        public BufferingInputBase​(int capacity)
    • Method Detail

      • loadMoreItems

        protected abstract int loadMoreItems​(T lastItem)
                                      throws java.io.IOException
        Called when the elements buffer is exhausted. Should put more (but not more than "capacity") new elements into the empty buffer.
        Returns:
        the count of the items was actually loaded into the "items" buffer or 0 if no more items are available.
        Throws:
        java.io.IOException
      • get

        public final T get()
                    throws java.io.IOException
        Description copied from interface: Input
        Get next item
        Specified by:
        get in interface Input<T>
        Overrides:
        get in class ListInput<T>
        Returns:
        next item
        Throws:
        java.io.EOFException - if no item available more
        java.io.IOException - if failed to get some-why
      • get

        public final int get​(java.util.List<T> buffer,
                             int maxCount)
                      throws java.io.IOException
        Description copied from class: ListInput
        Bulk get into the specified buffer
        Specified by:
        get in interface Input<T>
        Overrides:
        get in class ListInput<T>
        Parameters:
        buffer - buffer for the items
        maxCount - the count limit
        Returns:
        the count of the items been get
        Throws:
        java.io.EOFException - if no item available more
        java.io.IOException - if failed to get some-why
      • close

        public void close()
                   throws java.io.IOException
        Description copied from class: ListInput
        Does nothing
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class ListInput<T>
        Throws:
        java.io.IOException - doesn't throw