|
MATSIM
|

Classes | |
| enum | ValidationType |
Public Member Functions | |
| MatsimXmlParser (ValidationType validationType) | |
| abstract void | startTag (String name, Attributes atts, Stack< String > context) |
| abstract void | endTag (String name, String content, Stack< String > context) |
| final void | setValidating (final boolean validateXml) |
| final void | setNamespaceAware (final boolean awareness) |
| final void | setLocalDtdDirectory (final String localDtdDirectory) |
| final void | readFile (final String filename) throws UncheckedIOException |
| final void | readURL (final URL url) throws UncheckedIOException |
| final void | readStream (InputStream stream) throws UncheckedIOException |
| final void | parse (final URL url) throws UncheckedIOException |
| final void | parse (final InputStream stream) throws UncheckedIOException |
| final void | parse (final InputSource input) throws UncheckedIOException |
| final String | getDoctype () |
| final InputSource | resolveEntity (final String publicId, final String systemId) |
| void | characters (final char[] ch, final int start, final int length) throws SAXException |
| final void | startElement (final String uri, final String localName, final String qName, Attributes atts) |
| final void | endElement (final String uri, final String localName, final String qName) throws SAXException |
| final void | error (final SAXParseException ex) throws SAXException |
| final void | fatalError (final SAXParseException ex) throws SAXException |
| final void | warning (final SAXParseException ex) throws SAXException |
Static Public Member Functions | |
| static double | parseDouble (String value) throws NumberFormatException |
Protected Member Functions | |
| void | setDoctype (final String doctype) |
Private Member Functions | |
| InputSource | findDtdInLocalFilesystem (final String shortSystemId) |
| InputSource | findDtdInClasspath (final String shortSystemId) |
| String | getInputSource (final SAXParseException ex) |
Static Private Member Functions | |
| static InputSource | findDtdInRemoteLocation (final String fullSystemId) |
| static InputSource | findDtdInDefaultLocation (final String shortSystemId) |
Private Attributes | |
| final Stack< StringBuffer > | buffers = new Stack<>() |
| final Stack< String > | theContext = new Stack<>() |
| boolean | isValidating = true |
| boolean | isNamespaceAware = true |
| final ValidationType | validationType |
| String | localDtdBase = null |
| final boolean | preferLocalDtds |
| String | doctype = null |
| String | theSource |
Static Private Attributes | |
| static final Logger | log = LogManager.getLogger(MatsimXmlParser.class) |
An abstract XML-Parser which can be easily extended for reading custom XML-formats. This class handles all the low level functionality required to parse xml-files. Extending classes have only to implement startTag and endTag to implement a custom parser.
The parser implements a custom EntityResolver to look for DTDs in the MATSim world.
Notes:
Definition at line 55 of file MatsimXmlParser.java.
| org.matsim.core.utils.io.MatsimXmlParser.MatsimXmlParser | ( | ValidationType | validationType | ) |
Creates a validating XML-parser.
| validationType | hint whether DTD or XSD is expected for validation, helps to optimize the parser for performance. |
Definition at line 86 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.endTag(), org.matsim.utils.FeatureFlags.preferLocalDTDs(), org.matsim.core.utils.io.MatsimXmlParser.startTag(), and org.matsim.core.utils.io.MatsimXmlParser.validationType.

|
abstract |
Called for each opening xml-tag.
| name | the name of the xml-tag |
| atts | the list of attributes and their values |
| context | a stack containing the path/hierarchy to the current tag |
Referenced by org.matsim.core.utils.io.MatsimXmlParser.MatsimXmlParser(), org.matsim.core.utils.io.MatsimXmlParser.startElement(), org.matsim.matrices.MatsimMatricesReader.startTag(), org.matsim.core.config.ConfigReader.startTag(), org.matsim.core.network.io.MatsimNetworkReader.startTag(), org.matsim.counts.MatsimCountsReader.startTag(), org.matsim.core.population.io.PopulationReader.startTag(), org.matsim.pt.transitSchedule.api.TransitScheduleReader.XmlScheduleReader.startTag(), and org.matsim.facilities.MatsimFacilitiesReader.startTag().
|
abstract |
Called for each closing xml-tag.
| name | the name of the xml-tag. |
| content | the character-content of the tag; any characters between <tag> and </tag>>, excluding other tags and their content. |
| context | a stack containing the path/hierarchy to the current tag |
Referenced by org.matsim.core.utils.io.MatsimXmlParser.endElement(), org.matsim.matrices.MatsimMatricesReader.endTag(), org.matsim.core.config.ConfigReader.endTag(), org.matsim.core.network.io.MatsimNetworkReader.endTag(), org.matsim.vehicles.MatsimVehicleReader.VehicleReader.endTag(), org.matsim.counts.MatsimCountsReader.endTag(), org.matsim.core.population.io.PopulationReader.endTag(), org.matsim.pt.transitSchedule.api.TransitScheduleReader.XmlScheduleReader.endTag(), org.matsim.facilities.MatsimFacilitiesReader.endTag(), and org.matsim.core.utils.io.MatsimXmlParser.MatsimXmlParser().
| final void org.matsim.core.utils.io.MatsimXmlParser.setValidating | ( | final boolean | validateXml | ) |
Sets, if this parser should validate the read XML or not. Not validating is sometimes useful during development or during some tests with format-extensions that are not yet part of the DTD, but it is strongly discouraged not to validate during production use.
| validateXml | Whether the parsed XML should be validated or not. |
Definition at line 117 of file MatsimXmlParser.java.
Referenced by org.matsim.core.events.EventsConverterXML.EventsConverterXML(), and org.matsim.core.events.EventsReaderXMLv1.EventsReaderXMLv1().
| final void org.matsim.core.utils.io.MatsimXmlParser.setNamespaceAware | ( | final boolean | awareness | ) |
Specifies that the parser produced by this code will provide support for XML namespaces. By default the value of this is set to false.
| awareness | true if the parser produced by this code will provide support for XML namespaces; false otherwise. |
Definition at line 128 of file MatsimXmlParser.java.
| final void org.matsim.core.utils.io.MatsimXmlParser.setLocalDtdDirectory | ( | final String | localDtdDirectory | ) |
Sets the directory where to look for DTD and XSD files if they are not found at the location specified in the XML.
| localDtdDirectory |
Definition at line 138 of file MatsimXmlParser.java.
| final void org.matsim.core.utils.io.MatsimXmlParser.readFile | ( | final String | filename | ) | throws UncheckedIOException |
Parses the specified file. The file can be gzip-compressed and is decompressed on-the-fly while parsing. A gzip-compressed file must have the ending ".gz" to be correctly recognized. The passed filename may or may not contain the ending ".gz". If no uncompressed file is found with the specified name, the ending ".gz" will be added to the filename and a compressed file will be searched for and read if found.
| filename | The filename of the file to read, optionally ending with ".gz" to force reading a gzip-compressed file. |
| UncheckedIOException |
Implements org.matsim.core.api.internal.MatsimReader.
Definition at line 152 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.IOUtils.getBufferedReader(), and org.matsim.core.utils.io.MatsimXmlParser.parse().
Referenced by org.matsim.utils.gis.matsim2esri.plans.SelectedPlans2ESRIShape.main(), org.matsim.core.utils.io.OsmNetworkReader.parse(), org.matsim.vehicles.MatsimVehicleReader.readFile(), org.matsim.pt.transitSchedule.api.TransitScheduleReader.readFile(), org.matsim.core.events.MatsimEventsReader.readFile(), org.matsim.core.population.io.StreamingPopulationReader.readFile(), org.matsim.core.network.NetworkUtils.readNetwork(), org.matsim.core.population.PopulationUtils.readPopulation(), org.matsim.core.network.algorithms.intersectionSimplifier.RunIntersectionSimplifier.run(), and org.matsim.run.gui.ScheduleValidatorWindow.run().

| final void org.matsim.core.utils.io.MatsimXmlParser.readURL | ( | final URL | url | ) | throws UncheckedIOException |
Implements org.matsim.core.api.internal.MatsimReader.
Definition at line 159 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.parse().
Referenced by org.matsim.vehicles.MatsimVehicleReader.readURL(), and org.matsim.core.events.MatsimEventsReader.readURL().

| final void org.matsim.core.utils.io.MatsimXmlParser.readStream | ( | InputStream | stream | ) | throws UncheckedIOException |
Definition at line 163 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.parse().

| final void org.matsim.core.utils.io.MatsimXmlParser.parse | ( | final URL | url | ) | throws UncheckedIOException |
Definition at line 167 of file MatsimXmlParser.java.
References org.matsim.core.gbl.Gbl.assertNotNull(), and org.matsim.core.utils.io.IOUtils.getBufferedReader().
Referenced by org.matsim.core.config.ConfigUtils.loadConfig(), org.matsim.core.population.io.StreamingPopulationReader.parse(), org.matsim.core.utils.io.MatsimXmlParser.parse(), org.matsim.core.utils.io.OsmNetworkReader.parse(), org.matsim.core.utils.io.MatsimXmlParser.readFile(), org.matsim.vehicles.MatsimVehicleReader.readStream(), org.matsim.pt.transitSchedule.api.TransitScheduleReader.readStream(), org.matsim.core.events.MatsimEventsReader.readStream(), org.matsim.core.utils.io.MatsimXmlParser.readStream(), org.matsim.pt.transitSchedule.api.TransitScheduleReader.readURL(), org.matsim.core.population.io.StreamingPopulationReader.readURL(), and org.matsim.core.utils.io.MatsimXmlParser.readURL().

| final void org.matsim.core.utils.io.MatsimXmlParser.parse | ( | final InputStream | stream | ) | throws UncheckedIOException |
Definition at line 175 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.parse().

| final void org.matsim.core.utils.io.MatsimXmlParser.parse | ( | final InputSource | input | ) | throws UncheckedIOException |
Definition at line 180 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.ValidationType.DTD_ONLY, and org.matsim.core.utils.io.MatsimXmlParser.ValidationType.NO_VALIDATION.
| final String org.matsim.core.utils.io.MatsimXmlParser.getDoctype | ( | ) |
Definition at line 235 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.doctype.
|
protected |
Definition at line 239 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.doctype.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.resolveEntity().
| final InputSource org.matsim.core.utils.io.MatsimXmlParser.resolveEntity | ( | final String | publicId, |
| final String | systemId | ||
| ) |
Definition at line 248 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.findDtdInClasspath(), org.matsim.core.utils.io.MatsimXmlParser.findDtdInDefaultLocation(), org.matsim.core.utils.io.MatsimXmlParser.findDtdInLocalFilesystem(), org.matsim.core.utils.io.MatsimXmlParser.findDtdInRemoteLocation(), and org.matsim.core.utils.io.MatsimXmlParser.setDoctype().

|
staticprivate |
Definition at line 295 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.resolveEntity().
|
private |
Definition at line 316 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.resolveEntity().
|
private |
Definition at line 329 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.resolveEntity().
|
staticprivate |
Definition at line 339 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.resolveEntity().
| void org.matsim.core.utils.io.MatsimXmlParser.characters | ( | final char [] | ch, |
| final int | start, | ||
| final int | length | ||
| ) | throws SAXException |
Definition at line 352 of file MatsimXmlParser.java.
| final void org.matsim.core.utils.io.MatsimXmlParser.startElement | ( | final String | uri, |
| final String | localName, | ||
| final String | qName, | ||
| Attributes | atts | ||
| ) |
Definition at line 362 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.startTag().

| final void org.matsim.core.utils.io.MatsimXmlParser.endElement | ( | final String | uri, |
| final String | localName, | ||
| final String | qName | ||
| ) | throws SAXException |
Definition at line 372 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.endTag(), and org.matsim.core.utils.io.MatsimXmlParser.theContext.

| final void org.matsim.core.utils.io.MatsimXmlParser.error | ( | final SAXParseException | ex | ) | throws SAXException |
Definition at line 384 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.getInputSource().

| final void org.matsim.core.utils.io.MatsimXmlParser.fatalError | ( | final SAXParseException | ex | ) | throws SAXException |
Definition at line 394 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.getInputSource().

| final void org.matsim.core.utils.io.MatsimXmlParser.warning | ( | final SAXParseException | ex | ) | throws SAXException |
Definition at line 401 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.getInputSource().

|
private |
Definition at line 406 of file MatsimXmlParser.java.
References org.matsim.core.utils.io.MatsimXmlParser.theSource.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.error(), org.matsim.core.utils.io.MatsimXmlParser.fatalError(), and org.matsim.core.utils.io.MatsimXmlParser.warning().
|
static |
Parses a String into a double, taking into account the special encoding for Infinity according to the xsd-specifications for the xs:double data type
Definition at line 426 of file MatsimXmlParser.java.
|
staticprivate |
Definition at line 59 of file MatsimXmlParser.java.
|
private |
Definition at line 61 of file MatsimXmlParser.java.
|
private |
Definition at line 62 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.endElement().
|
private |
Definition at line 64 of file MatsimXmlParser.java.
|
private |
Definition at line 65 of file MatsimXmlParser.java.
|
private |
Definition at line 66 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.MatsimXmlParser().
|
private |
Definition at line 68 of file MatsimXmlParser.java.
|
private |
Definition at line 72 of file MatsimXmlParser.java.
|
private |
Definition at line 74 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.getDoctype(), and org.matsim.core.utils.io.MatsimXmlParser.setDoctype().
|
private |
As the mechanism implemented in InputSource is not really working for error handling the source to be parsed is stored here for error handling.
Definition at line 79 of file MatsimXmlParser.java.
Referenced by org.matsim.core.utils.io.MatsimXmlParser.getInputSource().
1.8.13