}
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
Parser parser = endpoint.createParser(exchange);
DataSet dataSet = parser.parse();
if (dataSet.getErrorCount() > 0) {
StringBuilder sb = new StringBuilder();
sb.append(String.format("Flatpack has found %s errors while parsing", dataSet.getErrorCount()));
throw new FlatpackException(sb.toString(), exchange, dataSet.getErrors());
}
if (endpoint.isSplitRows()) {
int counter = 0;
while (dataSet.next()) {
endpoint.processDataSet(exchange, dataSet, counter++);
}
} else {
endpoint.processDataSet(exchange, dataSet, dataSet.getRowCount());
}
}