Package org.marketcetera.modules.csv
Class CSVEmitter
- java.lang.Object
-
- org.marketcetera.module.Module
-
- org.marketcetera.modules.csv.CSVEmitter
-
- All Implemented Interfaces:
DataEmitter
public class CSVEmitter extends Module implements DataEmitter
A module that emits data contained in a CSV file as a series of maps, each instance containing a row of data. The first row of data is assumed to contain the column names. Each Map instance has the column name as the key and the value in the column as data. Each map instance has as many entries as the number of header columns. Rows that do not have any value for a column have an empty string value in the emitted map.All the keys and values in the map are of type string.
The module accepts request parameters of following types:
String: interpreted as a URL, if that fails, a file path from which the csv file can be read. If the string starts with 'r:', it's stripped from the string and rows are emitted in the reverse order of their appearance.File: path to the csv file.URL: the url of the csv file.
Module Features
Describes the module attributes Capabilities Data Emitter DataFlow Request Parameters String, File or URL. Usage explained above. Stops data flows Yes, if there's no more data to emit or if there was an error reading data from the file/URL. Start Operation Initializes the thread pool for emitting data. Stop Operation Shuts down the thread pool. Management Interface none Factory CSVEmitterFactory- Author:
- anshul@marketcetera.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCSVEmitter.CSVReaderThis task reads the contents of a csv file and emits each row of the csv file as a Map instance.
-
Field Summary
Fields Modifier and Type Field Description private Map<RequestID,Future<Boolean>>mRequestsprivate ExecutorServicemService(package private) static StringPREFIX_REVERSE
-
Constructor Summary
Constructors Modifier Constructor Description protectedCSVEmitter()Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel(DataFlowID inFlowID, RequestID inRequestID)protected voidpreStart()protected voidpreStop()voidrequestData(DataRequest inRequest, DataEmitterSupport inSupport)-
Methods inherited from class org.marketcetera.module.Module
getCreated, getLastStartFailure, getLastStopFailure, getStarted, getState, getStopped, getURN, isAutoCreated, isAutoStart
-
-
-
-
Field Detail
-
mService
private ExecutorService mService
-
PREFIX_REVERSE
static final String PREFIX_REVERSE
- See Also:
- Constant Field Values
-
-
Method Detail
-
requestData
public void requestData(DataRequest inRequest, DataEmitterSupport inSupport) throws UnsupportedRequestParameterType, IllegalRequestParameterValue
- Specified by:
requestDatain interfaceDataEmitter- Throws:
UnsupportedRequestParameterTypeIllegalRequestParameterValue
-
cancel
public void cancel(DataFlowID inFlowID, RequestID inRequestID)
- Specified by:
cancelin interfaceDataEmitter
-
-