use of org.onebusaway.csv_entities.DelimiterTokenizerStrategy in project onebusaway-application-modules by camsys.
the class BlockLocationHistoryServiceImpl method getHistoryForTripId.
@Override
public Map<AgencyAndIdInstance, List<BlockLocationArchiveRecord>> getHistoryForTripId(AgencyAndId tripId) {
TripEntry trip = _transitGraphDao.getTripEntryForId(tripId);
if (trip == null)
return null;
BlockEntry block = trip.getBlock();
List<File> files = getFilesForBlockId(block.getId());
CsvEntityReader reader = new CsvEntityReader();
reader.setTokenizerStrategy(new DelimiterTokenizerStrategy("\t"));
EntityHandlerImpl handler = new EntityHandlerImpl(tripId);
reader.addEntityHandler(handler);
try {
for (File file : files) {
InputStream in = openFileForInput(file);
reader.readEntities(BlockLocationArchiveRecord.class, in);
in.close();
}
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
Map<AgencyAndIdInstance, List<BlockLocationArchiveRecord>> recordsByInstance = handler.getRecordsByInstance();
for (List<BlockLocationArchiveRecord> records : recordsByInstance.values()) Collections.sort(records, new DistanceAlongBlockComparator());
return recordsByInstance;
}
Aggregations