public class SynchronizedSpotDataParser extends Object implements BfsParser
setMasterParser(AnnotationParser)
.
Then, one or more data parsers is needed addDataParser(DataParser)
.
All parsers must have been parsed to beginning-of-file
(eg. AnnotationParser.parseToBof()
and DataParser.parseToBof()
) before
they are added to this class. The parse(EventHandler)
method will then
call AnnotationParser.nextData()
and DataParser.nextData()
for each parser as long as data is returned. All parsers must resturn at least
as many data lines as the master parser or an exception is thrown.Modifier and Type | Class and Description |
---|---|
static class |
SynchronizedSpotDataParser.SynchronizedData
This class holds information that is sent to the event
handler when
DATA_EVENT :s are
sent. |
Modifier and Type | Field and Description |
---|---|
static EventType<SynchronizedSpotDataParser.SynchronizedData[]> |
DATA_EVENT
Event type that is issued for each data line.
|
private List<DataParser> |
dataParsers |
private AnnotationParser |
masterParser |
Constructor and Description |
---|
SynchronizedSpotDataParser()
Create a new synchronized data parser.
|
Modifier and Type | Method and Description |
---|---|
void |
addDataParser(DataParser parser)
Adds a data parser.
|
void |
close()
Close the parser and relase underlying system resources that
are associated with it.
|
int |
getCurrentLine()
Get the current line number.
|
String |
getFilename()
Get the filename of the file that is being parsed.
|
long |
getFileSize()
Get the size of the file that is being parsed.
|
long |
getParsedBytes()
Get the number of parsed bytes so far.
|
void |
parse(EventHandler handler)
Begin parsing and issue events to the given event handler.
|
void |
setMasterParser(AnnotationParser parser)
Sets the master parser.
|
public static final EventType<SynchronizedSpotDataParser.SynchronizedData[]> DATA_EVENT
SynchronizedSpotDataParser.SynchronizedData
objects. The first entry in the
array contains information from the master parser, the following
entries contain information for the data parsers in the order
they were added.private AnnotationParser masterParser
private List<DataParser> dataParsers
public SynchronizedSpotDataParser()
public void setMasterParser(AnnotationParser parser)
public void addDataParser(DataParser parser)
public String getFilename()
BfsParser
getFilename
in interface BfsParser
public long getFileSize()
BfsParser
getFileSize
in interface BfsParser
public int getCurrentLine()
BfsParser
getCurrentLine
in interface BfsParser
public long getParsedBytes()
BfsParser
getParsedBytes
in interface BfsParser
public void close()
BfsParser
public void parse(EventHandler handler) throws IOException
DATA_EVENT
is sent to the event handler. When
the end-of-file has been a DataParser.END_OF_FILE_EVENT
is
sent.handler
- An event handlerIOException
- If there is an error reading the stream dataNullPointerException
- If the event handler or master parser is null