public class LimitedOneLinePerDocumentIterator extends Object implements Iterator<Document>
Document
instances given a file
that contains list of files. This iterator allows an upper limit on the
number of documents returned to be set. Once this limit has been reached,
the iterator must be reset before it can return more documents.
This class is thread-safe.
Constructor and Description |
---|
LimitedOneLinePerDocumentIterator(Iterator<Document> iter,
int docLimit,
boolean useMultipleResets)
Constructs an
Iterator for the documents contained in the
provided file. |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Returns
true if there are more documents in the provided file. |
Document |
next()
Returns the next document from the file.
|
void |
remove()
Throws an
UnsupportedOperationException if called. |
void |
reset()
Reset the iterator so that new documents may be returned.
|
public LimitedOneLinePerDocumentIterator(Iterator<Document> iter, int docLimit, boolean useMultipleResets) throws IOException
Iterator
for the documents contained in the
provided file.documentsFile
- a file that contains one document per lineIOException
- if any error occurs when reading documentsFile
public boolean hasNext()
true
if there are more documents in the provided file.public Document next()
public void reset()
public void remove()
UnsupportedOperationException
if called.Copyright © 2012. All Rights Reserved.