Class XmlNetworkLaneParser

  • All Implemented Interfaces:
    java.io.Serializable

    public final class XmlNetworkLaneParser
    extends java.lang.Object
    implements java.io.Serializable
    Parse an XML file for an OTS network, based on the ots-network.xsd definition.

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Jul 23, 2015

    Author:
    Alexander Verbraeck
    See Also:
    Serialized Form
    • Method Detail

      • build

        public static OTSRoadNetwork build​(java.lang.String filename,
                                           OTSRoadNetwork otsNetwork,
                                           boolean buildConflicts)
                                    throws javax.xml.bind.JAXBException,
                                           java.net.URISyntaxException,
                                           NetworkException,
                                           OTSGeometryException,
                                           XmlParserException,
                                           org.xml.sax.SAXException,
                                           javax.xml.parsers.ParserConfigurationException,
                                           SimRuntimeException,
                                           GTUException,
                                           java.net.MalformedURLException,
                                           java.io.IOException,
                                           TrafficControlException
        Parse the XML file and build the network.
        Parameters:
        filename - String; the name of the file to parse
        otsNetwork - OTSRoadNetwork; the network to insert the parsed objects in
        buildConflicts - boolean; whether to build conflicts or not
        Returns:
        the network that contains the parsed objects
        Throws:
        javax.xml.bind.JAXBException - when the parsing fails
        java.net.URISyntaxException - when the filename is not valid
        NetworkException - when the objects cannot be inserted into the network due to inconsistencies
        OTSGeometryException - when the design line of a link is invalid
        XmlParserException - when the stripe type cannot be recognized
        javax.xml.parsers.ParserConfigurationException - on error with parser configuration
        org.xml.sax.SAXException - on error creating SAX parser
        SimRuntimeException - in case of simulation problems building the car generator
        GTUException - when construction of the Strategical Planner failed
        TrafficControlException - when construction of a traffic controller fails
        java.io.IOException - when construction of a traffic controller fails
        java.net.MalformedURLException - when construction of a traffic controller fails
      • build

        public static Experiment.TimeDoubleUnit<OTSSimulatorInterface> build​(java.io.InputStream xmlStream,
                                                                             OTSRoadNetwork otsNetwork,
                                                                             boolean buildConflicts)
                                                                      throws javax.xml.bind.JAXBException,
                                                                             java.net.URISyntaxException,
                                                                             NetworkException,
                                                                             OTSGeometryException,
                                                                             XmlParserException,
                                                                             org.xml.sax.SAXException,
                                                                             javax.xml.parsers.ParserConfigurationException,
                                                                             SimRuntimeException,
                                                                             GTUException,
                                                                             java.net.MalformedURLException,
                                                                             java.io.IOException,
                                                                             TrafficControlException
        Parse the XML input stream and build the network.
        Parameters:
        xmlStream - InputStream; the xml input stream
        otsNetwork - OTSRoadNetwork; the network to insert the parsed objects in
        buildConflicts - boolean; whether to build conflicts or not
        Returns:
        the experiment based on the information in the RUN tag
        Throws:
        javax.xml.bind.JAXBException - when the parsing fails
        java.net.URISyntaxException - when the filename is not valid
        NetworkException - when the objects cannot be inserted into the network due to inconsistencies
        OTSGeometryException - when the design line of a link is invalid
        XmlParserException - when the stripe type cannot be recognized
        javax.xml.parsers.ParserConfigurationException - on error with parser configuration
        org.xml.sax.SAXException - on error creating SAX parser
        SimRuntimeException - in case of simulation problems building the car generator
        GTUException - when construction of the Strategical Planner failed
        TrafficControlException - when construction of a traffic controller fails
        java.io.IOException - when construction of a traffic controller fails
        java.net.MalformedURLException - when construction of a traffic controller fails
      • parseXML

        public static OTS parseXML​(java.net.URL xmlURL)
                            throws javax.xml.bind.JAXBException,
                                   org.xml.sax.SAXException,
                                   javax.xml.parsers.ParserConfigurationException
        Parse an OTS XML input stream and build an OTS object.
        Parameters:
        xmlURL - URL; the URL for the xml file or stream
        Returns:
        OTS; the constructed OTS object
        Throws:
        javax.xml.bind.JAXBException - when the parsing fails
        javax.xml.parsers.ParserConfigurationException - on error with parser configuration
        org.xml.sax.SAXException - on error creating SAX parser
      • parseXML

        public static OTS parseXML​(java.io.InputStream xmlStream)
                            throws javax.xml.bind.JAXBException,
                                   org.xml.sax.SAXException,
                                   javax.xml.parsers.ParserConfigurationException
        Parse an OTS XML input stream and build an OTS object.
        Parameters:
        xmlStream - inputStream; the xml stream
        Returns:
        OTS; the constructed OTS object
        Throws:
        javax.xml.bind.JAXBException - when the parsing fails
        javax.xml.parsers.ParserConfigurationException - on error with parser configuration
        org.xml.sax.SAXException - on error creating SAX parser
      • build

        public static Experiment.TimeDoubleUnit<OTSSimulatorInterface> build​(java.net.URL xmlURL,
                                                                             OTSRoadNetwork otsNetwork,
                                                                             boolean buildConflicts)
                                                                      throws javax.xml.bind.JAXBException,
                                                                             java.net.URISyntaxException,
                                                                             NetworkException,
                                                                             OTSGeometryException,
                                                                             XmlParserException,
                                                                             org.xml.sax.SAXException,
                                                                             javax.xml.parsers.ParserConfigurationException,
                                                                             SimRuntimeException,
                                                                             GTUException,
                                                                             java.net.MalformedURLException,
                                                                             java.io.IOException,
                                                                             TrafficControlException
        Parse the XML file and build the network.
        Parameters:
        xmlURL - URL; the URL for the xml input file
        otsNetwork - OTSRoadNetwork; the network to insert the parsed objects in
        buildConflicts - boolean; whether to build conflicts or not
        Returns:
        the experiment based on the information in the RUN tag
        Throws:
        javax.xml.bind.JAXBException - when the parsing fails
        java.net.URISyntaxException - when the filename is not valid
        NetworkException - when the objects cannot be inserted into the network due to inconsistencies
        OTSGeometryException - when the design line of a link is invalid
        XmlParserException - when the stripe type cannot be recognized
        javax.xml.parsers.ParserConfigurationException - on error with parser configuration
        org.xml.sax.SAXException - on error creating SAX parser
        SimRuntimeException - in case of simulation problems building the car generator
        GTUException - when construction of the Strategical Planner failed
        TrafficControlException - when construction of a traffic controller fails
        java.io.IOException - when construction of a traffic controller fails
        java.net.MalformedURLException - when construction of a traffic controller fails
      • build

        public static Experiment.TimeDoubleUnit<OTSSimulatorInterface> build​(OTS ots,
                                                                             OTSRoadNetwork otsNetwork,
                                                                             boolean buildConflicts)
                                                                      throws javax.xml.bind.JAXBException,
                                                                             java.net.URISyntaxException,
                                                                             NetworkException,
                                                                             OTSGeometryException,
                                                                             XmlParserException,
                                                                             org.xml.sax.SAXException,
                                                                             javax.xml.parsers.ParserConfigurationException,
                                                                             SimRuntimeException,
                                                                             GTUException,
                                                                             java.net.MalformedURLException,
                                                                             java.io.IOException,
                                                                             TrafficControlException
        Build the network from an OTS object (probably constructed by parsing an OTS XML file; e.g. the parseXML method).
        Parameters:
        ots - OTS; the OTS object
        otsNetwork - OTSRoadNetwork; the network to insert the parsed objects in
        buildConflicts - boolean; whether to build conflicts or not
        Returns:
        the experiment based on the information in the RUN tag
        Throws:
        javax.xml.bind.JAXBException - when the parsing fails
        java.net.URISyntaxException - when the filename is not valid
        NetworkException - when the objects cannot be inserted into the network due to inconsistencies
        OTSGeometryException - when the design line of a link is invalid
        XmlParserException - when the stripe type cannot be recognized
        javax.xml.parsers.ParserConfigurationException - on error with parser configuration
        org.xml.sax.SAXException - on error creating SAX parser
        SimRuntimeException - in case of simulation problems building the car generator
        GTUException - when construction of the Strategical Planner failed
        TrafficControlException - when construction of a traffic controller fails
        java.io.IOException - when construction of a traffic controller fails
        java.net.MalformedURLException - when construction of a traffic controller fails
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Parameters:
        args - String[]; not used
        Throws:
        java.lang.Exception - on parsing error