public abstract class AbstractDocumentCollection extends AbstractDocumentSequence implements DocumentCollection, SafelyCloseable
safely closeable implementation of a document collection.
This class provides ready-made implementation of the iterator() method.
Concrete subclasses are encouraged to provide optimised, reuse-oriented versions of the
iterator() method. Note that since this implementation
uses document()
to implement the iterator, creating two iterators concurrently will usually lead
to unpredictable results.
As a commodity, the ensureDocumentIndex(int) method can be called
whenever it is necessary to check that a document index is not
out of range.
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractDocumentCollection.PropertyKeys
Symbolic names for common properties of a
DocumentCollection. |
DEFAULT_EXTENSION| Constructor and Description |
|---|
AbstractDocumentCollection() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
ensureDocumentIndex(int index)
Checks that the index is correct (between 0, inclusive, and
DocumentCollection.size(),
exclusive), and throws an IndexOutOfBoundsException if the index is not correct. |
DocumentIterator |
iterator()
Returns an iterator over the sequence of documents.
|
static void |
main(String[] arg) |
static void |
printAllDocuments(DocumentSequence seq)
Prints all documents in a given sequence.
|
String |
toString() |
close, filename, finalize, loadclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitcopy, document, metadata, size, streamclose, factory, filenameprotected void ensureDocumentIndex(int index)
DocumentCollection.size(),
exclusive), and throws an IndexOutOfBoundsException if the index is not correct.index - the index to be checked.public DocumentIterator iterator() throws IOException
DocumentSequenceWarning: this method can be safely called just one time. For instance, implementations based on standard input will usually throw an exception if this method is called twice.
Implementations may decide to override this restriction
(in particular, if they implement DocumentCollection). Usually,
however, it is not possible to obtain two iterators at the
same time on a collection.
iterator in interface DocumentSequenceIOExceptionDocumentCollectionpublic static void printAllDocuments(DocumentSequence seq) throws IOException
seq - the sequence.IOException