Class SynchronizedSpotDataParser

All Implemented Interfaces:
AutoCloseable, 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.
Last modified
$Date: 2010-04-20 10:02:16 +0200 (ti, 20 apr 2010) $
  • Field Details

  • Constructor Details

    • SynchronizedSpotDataParser

      public SynchronizedSpotDataParser()
      Create a new synchronized data parser.
  • Method Details

    • 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
      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
      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
      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
      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 AutoCloseable
      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.
      handler - An event handler
      IOException - If there is an error reading the stream data
      NullPointerException - If the event handler or master parser is null