Class FileArrayIterator<T>

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

    public abstract class FileArrayIterator<T>
    extends FilterIterator<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 Detail

      • FileArrayIterator

        protected FileArrayIterator​(File[] files)
    • Method Detail

      • filter

        protected T filter​(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<File,​T>
        Parameters:
        f - A given file
        Returns:
        An object in the T domain, or null
      • getNext

        protected abstract T getNext​(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.