Class BinInput<T>

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

    public class BinInput<T>
    extends java.lang.Object
    implements Input<T>
    The item input implementation deserializing the data items from the specified stream
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.ObjectInputStream itemsSrc  
      protected T[] srcBuff  
      protected int srcBuffPos  
      • Fields inherited from interface com.github.akurilov.commons.io.Input

        DELIMITER
    • Constructor Summary

      Constructors 
      Constructor Description
      BinInput​(java.io.ObjectInputStream itemsSrc)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      T get()
      Get next item
      int get​(java.util.List<T> dstBuff, int dstCountLimit)
      Bulk items get.
      void reset()
      Reset this input making this readable from the beginning
      void setItemsSrc​(java.io.ObjectInputStream itemsSrc)  
      long skip​(long itemsCount)
      Skip some items.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • itemsSrc

        protected java.io.ObjectInputStream itemsSrc
      • srcBuff

        protected T[] srcBuff
      • srcBuffPos

        protected int srcBuffPos
    • Constructor Detail

      • BinInput

        public BinInput​(java.io.ObjectInputStream itemsSrc)
    • Method Detail

      • setItemsSrc

        public void setItemsSrc​(java.io.ObjectInputStream itemsSrc)
      • get

        public final T get()
                    throws java.io.IOException
        Description copied from interface: Input
        Get next item
        Specified by:
        get in interface Input<T>
        Returns:
        next item or null if no items available more
        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> dstBuff,
                             int dstCountLimit)
                      throws java.io.IOException
        Description copied from interface: Input
        Bulk items get.
        Specified by:
        get in interface Input<T>
        Parameters:
        dstBuff - buffer for the items
        dstCountLimit - max count of the items to put into the buffer
        Returns:
        count of the items have been get and put into the buffer actually
        Throws:
        java.io.EOFException - if no item available more
        java.io.IOException - if failed to get some-why
      • reset

        public void reset()
                   throws java.io.IOException
        Description copied from interface: Input
        Reset this input making this readable from the beginning
        Specified by:
        reset in interface Input<T>
        Throws:
        java.io.IOException
      • skip

        public long skip​(long itemsCount)
                  throws java.io.IOException
        Description copied from interface: Input
        Skip some items.
        Specified by:
        skip in interface Input<T>
        Parameters:
        itemsCount - count of items should be skipped from the input stream
        Throws:
        java.io.IOException - if failed to skip such amount of bytes
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object