2.17.2: 2011-06-17

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

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

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.

Version:
2.15
Author:
Nicklas
Last modified
$Date: 2010-02-01 14:30:59 +0100 (Mon, 01 Feb 2010) $

Field Summary
private  int currentPosition
           
private  int externalIndex
           
private  int parserIndex
           
private  PositionBatcher posBatcher
           
private  int posIndex
           
private  ReporterBatcher reporterBatcher
           
private  int reporterIndex
           
 
Constructor Summary
PositionEventHandler(int parserIndex, int posIndex, PositionBatcher posBatcher, int reporterIndex, int externalIndex)
          Create a new event handler.
 
Method Summary
 int getCurrentPosition()
          Get the current position.
 void handleEvent(EventType eventType, Object eventData, BfsParser parser)
          Get the position number from the given parser/column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 Detail

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.

Parameters:
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 Detail

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
Parameters:
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.


2.17.2: 2011-06-17