Examples of CsvEntityReader


Examples of org.onebusaway.csv_entities.CsvEntityReader

public class NaPTANStopTest {

  @Test
  public void test() throws IOException {

    CsvEntityReader reader = new CsvEntityReader();
    reader.setInputLocation(new File(
        "src/test/resources/org/onebusaway/uk/naptan/csv/test_data"));
    AnnotationDrivenEntitySchemaFactory entitySchema = new AnnotationDrivenEntitySchemaFactory();
    entitySchema.addPackageToScan("org.onebusaway.uk.naptan.csv");
    reader.setEntitySchemaFactory(entitySchema);
    ListEntityHandler<NaPTANStop> stopHandler = new ListEntityHandler<NaPTANStop>();
    reader.addEntityHandler(stopHandler);
    reader.readEntities(NaPTANStop.class);
    reader.close();
    List<NaPTANStop> stops = stopHandler.getValues();
    assertEquals(2, stops.size());
    NaPTANStop stop = stops.get(0);
    assertEquals("010000001", stop.getAtcoCode());
    assertEquals("bstpgit", stop.getNaptanCode());
View Full Code Here

Examples of org.onebusaway.csv_entities.CsvEntityReader

  private void loadNaptanDataIfNeeded() throws IOException {
    if (_naptanCsvPath == null) {
      return;
    }

    CsvEntityReader reader = new CsvEntityReader();
    reader.setInputLocation(_naptanCsvPath);
    AnnotationDrivenEntitySchemaFactory entitySchema = new AnnotationDrivenEntitySchemaFactory();
    entitySchema.addPackageToScan("org.onebusaway.uk.naptan.csv");
    reader.setEntitySchemaFactory(entitySchema);
    reader.addEntityHandler(new EntityHandler() {
      @Override
      public void handleEntity(Object arg0) {
        NaPTANStop stop = (NaPTANStop) arg0;
        _stopsByAtcoId.put(stop.getAtcoCode(), stop);
      }
    });
    reader.readEntities(NaPTANStop.class);

    reader.close();

  }
View Full Code Here

Examples of org.onebusaway.csv_entities.CsvEntityReader

  }

  public void readStationLocations(File path) throws CsvEntityIOException,
      IOException {
    BufferedReader reader = new BufferedReader(new FileReader(path));
    CsvEntityReader csvEntityReader = new CsvEntityReader();
    csvEntityReader.addEntityHandler(new EntityHandler() {
      @Override
      public void handleEntity(Object bean) {
        StationLocation stationLocation = (StationLocation) bean;
        Point2D.Double xy = ProjectionSupport.convertFromLatLon(
            stationLocation.getLat(), stationLocation.getLon());
        stationLocation.setX(xy.x);
        stationLocation.setY(xy.y);
        _stationLocationsByTiploc.put(stationLocation.getTiploc(),
            stationLocation);
      }
    });
    csvEntityReader.readEntities(StationLocation.class, reader);
    reader.close();
  }
View Full Code Here

Examples of org.onebusaway.csv_entities.CsvEntityReader

   * Private Methods
   ****/

  @Override
  protected void setup() {
    _reader = new CsvEntityReader();

    AnnotationDrivenEntitySchemaFactory entitySchemaFactory = new AnnotationDrivenEntitySchemaFactory();
    entitySchemaFactory.addEntityClass(OrbcadRecord.class);
    _reader.setEntitySchemaFactory(entitySchemaFactory);

View Full Code Here

Examples of org.onebusaway.csv_entities.CsvEntityReader

   * Protected Methods
   ****/

  protected void setup() {

    _reader = new CsvEntityReader();

    AnnotationDrivenEntitySchemaFactory entitySchemaFactory = new AnnotationDrivenEntitySchemaFactory();
    entitySchemaFactory.addEntityClass(OrbcadRecord.class);
    _reader.setEntitySchemaFactory(entitySchemaFactory);

View Full Code Here

Examples of org.onebusaway.csv_entities.CsvEntityReader

    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);
    }
View Full Code Here

Examples of org.onebusaway.csv_entities.CsvEntityReader

  /****
   * Private Methods
   ****/

  private void register(InputStream in) throws IOException {
    CsvEntityReader reader = getReader();
    reader.addEntityHandler(new EntityHandlerImpl());
    reader.readEntities(TccParticipantRegistrationBean.class, in);
  }
View Full Code Here

Examples of org.onebusaway.csv_entities.CsvEntityReader

    reader.addEntityHandler(new EntityHandlerImpl());
    reader.readEntities(TccParticipantRegistrationBean.class, in);
  }

  private CsvEntityReader getReader() {
    CsvEntityReader reader = new CsvEntityReader();
    AnnotationDrivenEntitySchemaFactory factory = new AnnotationDrivenEntitySchemaFactory();
    factory.addEntityClass(TccParticipantRegistrationBean.class);
    reader.setEntitySchemaFactory(factory);
    return reader;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.