Package org.gedcomx.util
Class JsonRecordSetIterator
- java.lang.Object
-
- org.gedcomx.util.JsonRecordSetIterator
-
- All Implemented Interfaces:
Iterator<Gedcomx>,RecordSetIterator
public class JsonRecordSetIterator extends Object implements 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 reads JSON-formatted Records. User: Brent Hale Date: 6/3/2015
-
-
Constructor Summary
Constructors Constructor Description JsonRecordSetIterator(InputStream inputStream)Constructor for a record iterator that takes an InputStream of a RecordSet file and iterates through its record elements.JsonRecordSetIterator(InputStream inputStream, boolean isGzipped)JsonRecordSetIterator(String filename)Constructor for a record iterator that takes a filename of a RecordSet file and iterates through its record elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the input stream and accompanying reader if they are still open.StringgetId()GedcomxgetMetadata()This should be read last as you cannot be sure of when the metadata will appear in the data stream.booleanhasNext()Tell whether the RecordIterator has another GedcomX record to return.Gedcomxnext()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, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
JsonRecordSetIterator
public JsonRecordSetIterator(String filename) throws IOException
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.
-
JsonRecordSetIterator
public JsonRecordSetIterator(InputStream inputStream, boolean isGzipped) throws IOException
- Throws:
IOException
-
JsonRecordSetIterator
public JsonRecordSetIterator(InputStream inputStream) throws IOException
Constructor for a record iterator that takes an InputStream of a RecordSet file and iterates through its record elements. This creates a BufferedInputStream on the InputStream.- Parameters:
inputStream- - InputStream to read a GedcomX RecordSet file from.- Throws:
IOException- If there's an I/O problem.
-
-
Method Detail
-
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
public Gedcomx 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
public Gedcomx getMetadata()
This should be read last as you cannot be sure of when the metadata will appear in the data stream.- Specified by:
getMetadatain interfaceRecordSetIterator- Returns:
- The Metadata document.
-
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 you want to get the metadata and id of the RecordSet, then get them before you close().- Specified by:
closein interfaceRecordSetIterator
-
getId
public String getId() throws IOException
- Throws:
IOException
-
-