2.17.2: 2011-06-17

net.sf.basedb.util.importer.spotdata
Class SynchronizedSpotDataParser

java.lang.Object
  extended by net.sf.basedb.util.importer.spotdata.SynchronizedSpotDataParser
All Implemented Interfaces:
BfsParser

public class SynchronizedSpotDataParser
extends Object
implements BfsParser

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.

Version:
2.15
Author:
Nicklas
Last modified
$Date: 2010-04-20 10:02:16 +0200 (Tue, 20 Apr 2010) $

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

DATA_EVENT

public static final EventType<SynchronizedSpotDataParser.SynchronizedData[]> DATA_EVENT
Event type that is issued for each data line. The event data is an array with 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.


masterParser

private AnnotationParser masterParser

dataParsers

private List<DataParser> dataParsers
Constructor Detail

SynchronizedSpotDataParser

public SynchronizedSpotDataParser()
Create a new synchronized data parser.

Method Detail

setMasterParser

public void setMasterParser(AnnotationParser parser)
Sets the master parser. This parser should normally parse a reporter annotations file.


addDataParser

public void addDataParser(DataParser parser)
Adds a data parser. The parser should parse a data file that has the same number of data lines as the master parser. Each line contains data identified by the corresponding reporter in the master parser file.


getFilename

public String getFilename()
Description copied from interface: BfsParser
Get the filename of the file that is being parsed.

Specified by:
getFilename in interface BfsParser
Returns:
Always null, since we are parsing multiple files

getFileSize

public long getFileSize()
Description copied from interface: BfsParser
Get the size of the file that is being parsed.

Specified by:
getFileSize in interface BfsParser
Returns:
The file size of the master parser

getCurrentLine

public int getCurrentLine()
Description copied from interface: BfsParser
Get the current line number.

Specified by:
getCurrentLine in interface BfsParser
Returns:
The current line number in the file parsed by the master parser

getParsedBytes

public long getParsedBytes()
Description copied from interface: BfsParser
Get the number of parsed bytes so far.

Specified by:
getParsedBytes in interface BfsParser
Returns:
The number of bytes parsed by the master parser

close

public void close()
Description copied from interface: BfsParser
Close the parser and relase underlying system resources that are associated with it.

Specified by:
close in interface BfsParser

parse

public void parse(EventHandler handler)
           throws IOException
Begin parsing and issue events to the given event handler. For each data line a DATA_EVENT is sent to the event handler. When the end-of-file has been a DataParser.END_OF_FILE_EVENT is sent.

Parameters:
handler - An event handler
Throws:
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