@Override protected void setDoctype(final String doctype) { super.setDoctype(doctype); // Currently the only counts-type is v1 if (COUNTS_V1.equals(doctype)) { this.delegate = new CountsReaderMatsimV1( coordinateTransformation , this.counts); log.info("using counts_v1-reader."); } else { throw new IllegalArgumentException("Doctype \"" + doctype + "\" not known."); } }
@Override public void startTag(final String name, final Attributes atts, final Stack<String> context) { if (VOLUME.equals(name)) { startVolume(atts); } else if (COUNT.equals(name)) { startCount(atts); } else if (COUNTS.equals(name)) { startCounts(atts); } }
public void testSEVolume() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); reader.startTag("count", attributeFactory.createCountAttributes(), null); reader.startTag("volume", attributeFactory.createVolumeAttributes(), null); assertEquals("Volume attribute setting failed", 100.0, counts.getCount(Id.create(1, Link.class)).getVolume(1).getValue(), EPSILON); } }
/** * @throws SAXException * @throws ParserConfigurationException * @throws IOException * * @author mrieser */ @Test public void testWriteParse_nameIsNull() throws SAXException, ParserConfigurationException, IOException { CountsFixture f = new CountsFixture(); f.setUp(); f.counts.setName(null); Assert.assertNull(f.counts.getName()); String filename = this.utils.getOutputDirectory() + "counts.xml"; new CountsWriter(f.counts).write(filename); Counts counts2 = new Counts(); new CountsReaderMatsimV1(counts2).readFile(filename); Assert.assertEquals("", counts2.getName()); } }
public void testSECount() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); reader.startTag("count", attributeFactory.createCountAttributes(), null); assertEquals("Count attribute setting failed", "testNr", counts.getCount(Id.create(1, Link.class)).getCsLabel()); }
public void testSECounts() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); assertEquals("Counts attribute setting failed", "testName", counts.getName()); assertEquals("Counts attribute setting failed", "testDesc", counts.getDescription()); assertEquals("Counts attribute setting failed", 2000, counts.getYear()); }