1 package org.opentrafficsim.road.network.factory.xml.old;
2
3 import java.io.Serializable;
4
5 import org.opentrafficsim.core.gtu.GTUException;
6 import org.opentrafficsim.core.gtu.GTUType;
7 import org.opentrafficsim.core.network.NetworkException;
8 import org.w3c.dom.NamedNodeMap;
9 import org.w3c.dom.Node;
10 import org.w3c.dom.NodeList;
11 import org.xml.sax.SAXException;
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 class GTUTypeTag implements Serializable
35 {
36
37 private static final long serialVersionUID = 20160925L;
38
39
40 @SuppressWarnings("checkstyle:visibilitymodifier")
41 String name = null;
42
43
44
45
46
47
48
49
50 @SuppressWarnings("checkstyle:needbraces")
51 static void parseGTUTypes(final NodeList nodeList, final XmlNetworkLaneParserOld parser)
52 throws SAXException, NetworkException, GTUException
53 {
54 for (Node node : XMLParser.getNodes(nodeList, "GTUTYPE"))
55 {
56 NamedNodeMap attributes = node.getAttributes();
57 GTUTypeTag gtuTypeTag = new GTUTypeTag();
58
59 Node name = attributes.getNamedItem("NAME");
60 if (name == null)
61 throw new SAXException("GTUTYPE: missing attribute NAME");
62 gtuTypeTag.name = name.getNodeValue().trim();
63 if (parser.gtuTypes.keySet().contains(gtuTypeTag.name))
64 throw new SAXException("GTUTYPE: NAME " + gtuTypeTag.name + " defined twice");
65
66 GTUType gtuType = new GTUType(gtuTypeTag.name, parser.network.getGtuType(GTUType.DEFAULTS.VEHICLE));
67 parser.gtuTypes.put(gtuTypeTag.name, gtuType);
68 }
69 }
70
71
72 @Override
73 public final String toString()
74 {
75 return "GTUTypeTag [name=" + this.name + "]";
76 }
77
78 }