|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.importer.spotdata.SynchronizedSpotDataParser
public class SynchronizedSpotDataParser
A parser that synchronizes the parsing of multiple underlying
data parsers and a master reporter annotations parser. Before
it can be used a master parser must be set by 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.
Nested Class Summary | |
---|---|
static class |
SynchronizedSpotDataParser.SynchronizedData
This class holds information that is sent to the event handler when DATA_EVENT :s are
sent. |
Field Summary | |
---|---|
static EventType<SynchronizedSpotDataParser.SynchronizedData[]> |
DATA_EVENT
Event type that is issued for each data line. |
private List<DataParser> |
dataParsers
|
private AnnotationParser |
masterParser
|
Constructor Summary | |
---|---|
SynchronizedSpotDataParser()
Create a new synchronized data parser. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public SynchronizedSpotDataParser()
Method Detail |
---|
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
close
in interface 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 handler
IOException
- If there is an error reading the stream data
NullPointerException
- If the event handler or master parser is null
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |