Class PositionEventHandler
java.lang.Object
net.sf.basedb.util.importer.spotdata.PositionEventHandler
- All Implemented Interfaces:
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: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private final int
private final int
private final PositionBatcher
private final int
private ReporterBatcher
private final int
-
Constructor Summary
ConstructorDescriptionPositionEventHandler
(int parserIndex, int posIndex, PositionBatcher posBatcher, int reporterIndex, int externalIndex) Create a new event handler. -
Method Summary
Modifier and TypeMethodDescriptionint
Get the current position.void
handleEvent
(EventType eventType, Object eventData, BfsParser parser) Get the position number from the given parser/column.
-
Field Details
-
parserIndex
private final int parserIndex -
posIndex
private final int posIndex -
posBatcher
-
reporterIndex
private final int reporterIndex -
externalIndex
private final int externalIndex -
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.- Parameters:
parserIndex
- The index of the parser, a value between 0 and the number of synchronized data parsersposIndex
- The index of the data column holding the position number, a value between 0 and the number of columns in the parsed fileposBatcher
- An optional position batcher if a position/reporter needs to be createdreporterIndex
- 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 idexternalIndex
- The index of the data column holding the external reporter id, only used if reporterIndex=-1 is specified
-
-
Method Details
-
handleEvent
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 interfaceEventHandler
- Parameters:
eventType
- The type of event. See the parser documentation for more information about the event types it generateseventData
- The data that is associated with the eventparser
- The parser that is resposible for parsing the file
-
getCurrentPosition
public int getCurrentPosition()Get the current position.
-