org.marketcetera.orderloader
Class RowProcessor

java.lang.Object
  extended by org.marketcetera.orderloader.RowProcessor
Direct Known Subclasses:
FIXProcessor, SystemProcessor

public abstract class RowProcessor
extends Object

A processor responsible for processing each order row.

Since:
1.0.0
Version:
$Id: RowProcessor.java 16154 2012-07-14 16:34:05Z colin $
Author:
anshul@marketcetera.com

Constructor Summary
protected RowProcessor(OrderProcessor inProcessor, BrokerID inBrokerID)
          Creates an instance.
 
Method Summary
protected  BrokerID geBrokerID()
          The brokerID value to use for each order.
 List<FailedOrderInfo> getFailedOrders()
          The list of orders that failed to process.
 int getNumFailed()
          Number of orders that failed to process.
 int getNumSuccess()
          Number of orders that were successfully processed.
 int getTotal()
          Returns the total number of orders processed.
 void initialize(String... inHeaders)
          Initialize the instance with the headers for each column.
protected abstract  Order parseOrder(String[] inRow)
          Parses the supplied row and creates an order instance from it.
 void processOrder(int inIndex, String... inRow)
          Parses the order in the supplied row and processes it using the OrderProcessor.
protected abstract  void setHeaders(String[] inHeaders)
          Implemented by subclasses to initialize themselves with the supplied headers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowProcessor

protected RowProcessor(OrderProcessor inProcessor,
                       BrokerID inBrokerID)
Creates an instance.

Parameters:
inProcessor - the processor. Cannot be null.
inBrokerID - the broker ID.
Method Detail

initialize

public final void initialize(String... inHeaders)
                      throws OrderParsingException
Initialize the instance with the headers for each column.

Parameters:
inHeaders - the headers for each column. Cannot be null.
Throws:
OrderParsingException - if the supplied row is not a valid header row.

processOrder

public final void processOrder(int inIndex,
                               String... inRow)
Parses the order in the supplied row and processes it using the OrderProcessor.

Parameters:
inIndex - the row index.
inRow - the row value, cannot be null.

getTotal

public final int getTotal()
Returns the total number of orders processed. The returned value is the sum of getNumFailed() & getNumSuccess().

Returns:
the total number of orders processed.

getNumFailed

public final int getNumFailed()
Number of orders that failed to process.

Returns:
number of failures encountered when processing orders.

getNumSuccess

public final int getNumSuccess()
Number of orders that were successfully processed.

Returns:
number of orders that were successfully processed.

getFailedOrders

public final List<FailedOrderInfo> getFailedOrders()
The list of orders that failed to process. Each pair has the order index and the actual order that could not be processed.

Returns:
the list of orders that failed to process.

geBrokerID

protected final BrokerID geBrokerID()
The brokerID value to use for each order.

Returns:
the brokerID value to use for each order.

setHeaders

protected abstract void setHeaders(String[] inHeaders)
                            throws OrderParsingException
Implemented by subclasses to initialize themselves with the supplied headers.

Parameters:
inHeaders - the headers specified in the csv file.
Throws:
OrderParsingException - if there were errors with the supplied headers.

parseOrder

protected abstract Order parseOrder(String[] inRow)
                             throws OrderParsingException
Parses the supplied row and creates an order instance from it.

Parameters:
inRow - the supplied row.
Returns:
the order created from the supplied row.
Throws:
OrderParsingException - if there were errors parsing the


Copyright © 2012. All Rights Reserved.