@Override protected void setDoctype(String doctype) { super.setDoctype(doctype); if ("transitSchedule_v2.dtd".equals(doctype)) { this.delegate = new TransitScheduleReaderV2(externalInputCRS, targetCRS, this.scenario); } else if ("transitSchedule_v1.dtd".equals(doctype)) { this.delegate = new TransitScheduleReaderV1( externalInputCRS != null ? TransformationFactory.getCoordinateTransformation(externalInputCRS, targetCRS) : new IdentityTransformation(), this.scenario); } else { throw new IllegalArgumentException("Unsupported doctype: " + doctype); } }
/** * Tests that the default format written is in v2 format. * * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ @Test public void testDefaultV2() throws IOException, SAXException, ParserConfigurationException { String filename = this.utils.getOutputDirectory() + "schedule.xml"; TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitSchedule schedule = builder.createTransitSchedule(); TransitLine line = builder.createTransitLine(Id.create(1, TransitLine.class)); schedule.addTransitLine(line); TransitScheduleWriter writer = new TransitScheduleWriter(schedule); writer.writeFile(filename); TransitScheduleFactory builder2 = new TransitScheduleFactoryImpl(); TransitSchedule schedule2 = builder2.createTransitSchedule(); new TransitScheduleReaderV2(schedule2, new RouteFactories()).readFile(filename); Assert.assertEquals(1, schedule2.getTransitLines().size()); }