Package org.gedcomx.util
Class XmlRecordSetIterator
java.lang.Object
org.gedcomx.util.XmlRecordSetIterator
- All Implemented Interfaces:
Iterator<Gedcomx>,RecordSetIterator
Class for iterating through the 'record' elements (GedcomX documents) in a RecordSet one at a time
from a stream (e.g., a gzipped byte array) without having to inflate all the records at once.
This is for a RecordSet serialized to XML.
User: Randy Wilson
Date: 7/31/2014
Time: 1:58 PM
-
Constructor Summary
ConstructorsConstructorDescriptionXmlRecordSetIterator(BufferedReader reader) Constructor for a record iterator that takes a BufferedReader of a RecordSet file and iterates through its record elements.XmlRecordSetIterator(InputStream inputStream) Constructor for a record iterator that takes an InputStream of a RecordSet file and iterates through its record elements.XmlRecordSetIterator(InputStream inputStream, boolean isGzipped) XmlRecordSetIterator(String filename) Constructor for a record iterator that takes a filename of a RecordSet file and iterates through its record elements. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the input stream and accompanying reader if they are still open.Retrieve the metadata for the RecordSet.booleanhasNext()Tell whether the RecordIterator has another GedcomX record to return.next()Get the next Gedcomx Record from the RecordSet.voidremove()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
XmlRecordSetIterator
Constructor for a record iterator that takes a filename of a RecordSet file and iterates through its record elements.- Parameters:
filename- - Filename to read a GedcomX RecordSet file from.- Throws:
IOException- If there's an I/O problem.
-
XmlRecordSetIterator
- Throws:
IOException
-
XmlRecordSetIterator
Constructor for a record iterator that takes an InputStream of a RecordSet file and iterates through its record elements.- Parameters:
inputStream- - InputStream to read a GedcomX RecordSet file from.- Throws:
IOException- If there's an I/O problem.
-
XmlRecordSetIterator
Constructor for a record iterator that takes a BufferedReader of a RecordSet file and iterates through its record elements.- Parameters:
reader- - BufferedReader to read a GedcomX RecordSet file from.- Throws:
IOException- If there's an I/O problem.
-
-
Method Details
-
hasNext
public boolean hasNext()Tell whether the RecordIterator has another GedcomX record to return.- Specified by:
hasNextin interfaceIterator<Gedcomx>- Specified by:
hasNextin interfaceRecordSetIterator- Returns:
- true if there is another record to read; false otherwise.
-
next
Description copied from interface:RecordSetIteratorGet the next Gedcomx Record from the RecordSet.- Specified by:
nextin interfaceIterator<Gedcomx>- Specified by:
nextin interfaceRecordSetIterator- Returns:
- the next Gedcomx Record from the RecordSet.
-
getMetadata
Description copied from interface:RecordSetIteratorRetrieve the metadata for the RecordSet.- Specified by:
getMetadatain interfaceRecordSetIterator- Returns:
- A Gedcomx document representing the metadata (or collection information) of the RecordSet.
-
remove
public void remove()- Specified by:
removein interfaceIterator<Gedcomx>- Specified by:
removein interfaceRecordSetIterator
-
close
public void close()Close the input stream and accompanying reader if they are still open. If an exception occurs trying to close things, it is caught here.- Specified by:
closein interfaceRecordSetIterator
-