## edu.stanford.nlp.objectbank
Class ReaderIteratorFactory

    java.lang.Object
      edu.stanford.nlp.objectbank.ReaderIteratorFactory

All Implemented Interfaces:
  Iterable<Reader>

    public class ReaderIteratorFactory

extends Object
implements Iterable<Reader>

A ReaderIteratorFactory provides a means of getting an Iterator which returns java.util.Readers over a Collection of input sources. Currently supported input sources are: Files, Strings, URLs and Readers. A ReaderIteratorFactory may take a Collection on construction and new sources may be added either individually (via the add(Object) method) or as a Collection (via the addAll(Collection method). The implementation automatically determines the type of input and produces a java.util.Reader accordingly. If you wish to add support for a new kind of input, refer the the setNextObject() method of the nested class ReaderIterator.

The Readers returned by this class are not closed by the class when you move to the next element (nor at any other time). So, if you want the files closed, then the caller needs to close them. The caller can only do this if they pass in Readers. Otherwise, this class should probably close them but currently doesn't.

TODO: Have this class close the files that it opens.

Author:
  Jenny Finkel

Field Summary
`protected Collection<Object>` `c` The underlying Collection of input sources.
`protected String` `enc` The encoding for file input.

Constructor Summary
`ReaderIteratorFactory()`
`ReaderIteratorFactory(Collection<?> c)` Constructs a ReaderIteratorFactory from the input sources contained in the Collection.
`ReaderIteratorFactory(Collection<?> c, String encoding)`
`ReaderIteratorFactory(Object o)` Convenience constructor to construct a ReaderIteratorFactory from a single input source.
`ReaderIteratorFactory(Object o, String encoding)`

Method Summary
`boolean` `add(Object o)` Adds an Object to the underlying Collection of input sources.
`boolean` `addAll(Collection<?> c)` Adds all Objects in Collection c to the underlying Collection of input sources.
`Iterator<Reader>` `iterator()` Returns an Iterator over the input sources in the underlying Collection.
`boolean` `remove(Object o)` Removes an Object from the underlying Collection of input sources.
`boolean` `removeAll(Collection<?> c)` Removes all Objects in Collection c from the underlying Collection of input sources.
`boolean` `retainAll(Collection<?> c)` Removes all Objects from the underlying Collection of input sources except those in Collection c

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### c

    protected Collection<Object> c

  The underlying Collection of input sources. Currently supported input sources are: Files, Strings, URLs and Readers. The implementation automatically determines the type of input and produces a java.util.Reader accordingly.

### enc

    protected String enc

  The encoding for file input. This is defaulted to "utf-8" only applies when c is of type `File` .

Constructor Detail

### ReaderIteratorFactory

    public ReaderIteratorFactory(Collection<?> c)

  Constructs a ReaderIteratorFactory from the input sources contained in the Collection. The Collection should contain Objects of type File, String, URL and Reader. See class description for details.

  Parameters:
    `c` - Collection of input sources.

### ReaderIteratorFactory

    public ReaderIteratorFactory(Collection<?> c,
                                 String encoding)

### ReaderIteratorFactory

    public ReaderIteratorFactory(Object o)

  Convenience constructor to construct a ReaderIteratorFactory from a single input source. The Object should be of type File, String, URL and Reader. See class description for details.

  Parameters:
    `o` - an input source that can be converted into a Reader

### ReaderIteratorFactory

    public ReaderIteratorFactory(Object o,
                                 String encoding)

### ReaderIteratorFactory

    public ReaderIteratorFactory()

Method Detail

### iterator

    public Iterator<Reader> iterator()

  Returns an Iterator over the input sources in the underlying Collection.

  Specified by:
    `iterator` in interface `Iterable<Reader>`
  Returns:
    an Iterator over the input sources in the underlying Collection.

### add

    public boolean add(Object o)

  Adds an Object to the underlying Collection of input sources.

  Parameters:
    `o` - Input source to be added to the underlying Collection.

### remove

    public boolean remove(Object o)

  Removes an Object from the underlying Collection of input sources.

  Parameters:
    `o` - Input source to be removed from the underlying Collection.

### addAll

    public boolean addAll(Collection<?> c)

  Adds all Objects in Collection c to the underlying Collection of input sources.

  Parameters:
    `c` - Collection of input sources to be added to the underlying Collection.

### removeAll

    public boolean removeAll(Collection<?> c)

  Removes all Objects in Collection c from the underlying Collection of input sources.

  Parameters:
    `c` - Collection of input sources to be removed from the underlying Collection.

### retainAll

    public boolean retainAll(Collection<?> c)

  Removes all Objects from the underlying Collection of input sources except those in Collection c

  Parameters:
    `c` - Collection of input sources to be retained in the underlying Collection.

Stanford NLP Group