Class FileArrayIterator<T>

  • Type Parameters:
    T - The type returned by the FileArrayIterator
    All Implemented Interfaces:
    java.util.Iterator<T>

    public abstract class FileArrayIterator<T>
    extends FilterIterator<java.io.File,​T>
    An iterator that iterates over elements that can be read from files, given an array of files. It is robust against disappearing files, but does not try to find new ones that appear while iterating. It keeps the Iterator contract that next() returns an element if hasNext() returned true since last next(). This may mean that the underlying file has disappeared by the time next() is called, but the object is returned anyway.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected FileArrayIterator​(java.io.File[] files)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected T filter​(java.io.File f)
      Returns the T object corresponding to the given file, or null if that object is to be skipped.
      protected abstract T getNext​(java.io.File file)
      Gives an object created from the given file, or null.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Method Detail

      • filter

        protected T filter​(java.io.File f)
        Returns the T object corresponding to the given file, or null if that object is to be skipped.
        Specified by:
        filter in class FilterIterator<java.io.File,​T>
        Parameters:
        f - A given file
        Returns:
        An object in the T domain, or null
      • getNext

        protected abstract T getNext​(java.io.File file)
        Gives an object created from the given file, or null.
        Parameters:
        file - The file to read
        Returns:
        An object of the type iterated over by the list, or null if the file does not exist or cannot be used to create an appropriate object.