Class PositionEventHandler

All Implemented Interfaces:

public class PositionEventHandler
extends Object
implements EventHandler
Event handler implementation intended to be used with a SynchronizedSpotDataParser to extract the position number from the parsed data. When cooperation is needed between multiple event handlers (eg. using the MultiEventHandler class, make sure that this event handler receives the event before any other handler that needs the position value.
Last modified
$Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
  • Field Details

    • parserIndex

      private final int parserIndex
    • posIndex

      private final int posIndex
    • posBatcher

      private final PositionBatcher posBatcher
    • reporterIndex

      private final int reporterIndex
    • externalIndex

      private final int externalIndex
    • reporterBatcher

      private ReporterBatcher reporterBatcher
    • currentPosition

      private int currentPosition
  • Constructor Details

    • PositionEventHandler

      public PositionEventHandler​(int parserIndex, int posIndex, PositionBatcher posBatcher, int reporterIndex, int externalIndex)
      Create a new event handler. The position value is expected to be found in the data column given by the two indexes. The first index is the parser index. Usually this should be 0=the master parser. The second index is the column holding the position value, eg. the ID column which should also be 0.
      parserIndex - The index of the parser, a value between 0 and the number of synchronized data parsers
      posIndex - The index of the data column holding the position number, a value between 0 and the number of columns in the parsed file
      posBatcher - An optional position batcher if a position/reporter needs to be created
      reporterIndex - The index of the data column holding the internal reporter id, ignored if no position batcher is used, -1 if the external id index should be used instead of the internal id
      externalIndex - The index of the data column holding the external reporter id, only used if reporterIndex=-1 is specified
  • Method Details

    • handleEvent

      public void handleEvent​(EventType eventType, Object eventData, BfsParser parser)
      Get the position number from the given parser/column. An exception is thrown if a valid integer value is not found.
      Specified by:
      handleEvent in interface EventHandler
      eventType - The type of event. See the parser documentation for more information about the event types it generates
      eventData - The data that is associated with the event
      parser - The parser that is resposible for parsing the file
    • getCurrentPosition

      public int getCurrentPosition()
      Get the current position.