net.sf.basedb.util.importer.spotdata
Class PositionEventHandler
java.lang.Object
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) $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
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
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 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.