use of org.structr.api.util.RangesIterator in project structr by structr.
the class CsvHelper method cleanAndParseCSV.
public static Iterable<JsonInput> cleanAndParseCSV(final SecurityContext securityContext, final Reader input, final Class type, final Character fieldSeparator, final Character quoteCharacter, final String range, final Map<String, String> propertyMapping) throws FrameworkException, IOException {
final CSVReader reader;
if (quoteCharacter == null) {
reader = new CSVReader(input, fieldSeparator);
} else {
reader = new CSVReader(input, fieldSeparator, quoteCharacter, true);
}
final String[] propertyNames = reader.readNext();
return new Iterable<JsonInput>() {
@Override
public Iterator<JsonInput> iterator() {
final Iterator<JsonInput> iterator = new CsvIterator(reader, propertyNames, propertyMapping, type, securityContext.getUser(false).getName());
if (StringUtils.isNotBlank(range)) {
return new RangesIterator<>(iterator, range);
} else {
return iterator;
}
}
};
}
Aggregations