Class ArrayInput<T>

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

    public class ArrayInput<T>
    extends java.lang.Object
    implements Input<T>
    Java objects array based input. Not thread safe.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int i  
      protected T[] items  
      protected int size  
      • Fields inherited from interface com.github.akurilov.commons.io.Input

        DELIMITER
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayInput​(T[] items)  
    • Method Summary

      All Methods Instance 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
      void reset()
      Reset this input making this readable from the beginning
      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

      • items

        protected final T[] items
      • size

        protected int size
      • i

        protected int i
    • Constructor Detail

      • ArrayInput

        public ArrayInput​(T[] items)
    • Method Detail

      • get

        public T get()
              throws java.io.EOFException,
                     java.io.IOException
        Description copied from interface: Input
        Get next item
        Specified by:
        get in interface Input<T>
        Returns:
        next item
        Throws:
        java.io.EOFException - if there's nothing to get more
        java.io.IOException - if failed to get some-why
      • get

        public int get​(java.util.List<T> buffer,
                       int maxCount)
                throws java.io.EOFException,
                       java.io.IOException
        Bulk get into the specified buffer
        Specified by:
        get in interface Input<T>
        Parameters:
        buffer - buffer for the items
        maxCount - the count limit
        Returns:
        the count of the items been get
        Throws:
        java.io.EOFException - if there's nothing to get more
        java.io.IOException - if failed to get some-why
      • 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
      • 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 - doesn't throw
      • close

        public void close()
                   throws java.io.IOException
        Does nothing
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - doesn't throw
      • toString

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