}
@SuppressWarnings("unchecked")
@Override
public void read(ILineSender lineSender) {
ITransformer transformer = null;
if(!dataTransform.isEmpty()) {
transformer = TransformerFactory.create(dataTransform);
}
String item = null;
while(cursor.hasNext()){
ILine line = lineSender.createNewLine();
current = cursor.next();
log.debug("current cursor object:" + current);
if (!allFieldsOrNot){
for(String field : fieldsSet){
item = String.valueOf(current.get(field));
if(fieldNeedSplit && fieldsSet.size()==1) {
int start = 0;
int end = item.indexOf(fieldSplitChar);
while(end!=-1) {
String fieldStr = null;
if(start != end) {
fieldStr = item.substring(start,end);
}
line.addField(fieldStr);
start = end + 1;
end = item.indexOf(fieldSplitChar,start);
}
if(start == item.length()) {
line.addField(null);
}else {
line.addField(item.substring(start));
}
}else if (null == item){
line.addField(null);
}else {
line.addField(item);
}
}
}else{
log.info("Using all fields strategy, it is not appreciable. ");
Map<String, BSONObject> keys = current.toMap();
for (Map.Entry<String, BSONObject> entry : keys.entrySet()) {
line.addField(entry.getValue().toString());
}
}
if(!dataTransform.isEmpty()) {
line = transformer.transform(line);
}
log.debug("send line to bufferLineExchanger:" + line.toString('\t'));
if (lineSender.send(line)){
getMonitor().increaseSuccessLines();
}else{