1 package org.opentrafficsim.road.network.factory.opendrive;
2
3 import java.io.Serializable;
4
5 import org.opentrafficsim.core.network.NetworkException;
6 import org.w3c.dom.NamedNodeMap;
7 import org.w3c.dom.Node;
8 import org.xml.sax.SAXException;
9
10
11
12
13
14
15
16
17
18
19 class ControllerTag implements Serializable
20 {
21
22
23 private static final long serialVersionUID = 20150723L;
24
25
26 @SuppressWarnings("checkstyle:visibilitymodifier")
27 String id = null;
28
29
30 @SuppressWarnings("checkstyle:visibilitymodifier")
31 String type = null;
32
33
34 @SuppressWarnings("checkstyle:visibilitymodifier")
35 String name = null;
36
37
38 @SuppressWarnings("checkstyle:visibilitymodifier")
39 Integer sequence = null;
40
41
42 @SuppressWarnings("checkstyle:visibilitymodifier")
43 String controlSignalID = null;
44
45
46 @SuppressWarnings("checkstyle:visibilitymodifier")
47 String controlType = null;
48
49
50
51
52
53
54
55
56
57 @SuppressWarnings("checkstyle:needbraces")
58 static ControllerTag parseController(final Node node, final OpenDriveNetworkLaneParser parser)
59 throws SAXException, NetworkException
60 {
61 NamedNodeMap attributes = node.getAttributes();
62 ControllerTag controllerTag = new ControllerTag();
63
64 Node id = attributes.getNamedItem("id");
65 if (id == null)
66 throw new SAXException("LANE: missing attribute id");
67 controllerTag.id = id.getNodeValue().trim();
68
69 Node type = attributes.getNamedItem("type");
70 if (type != null)
71 controllerTag.type = type.getNodeValue().trim();
72
73 Node name = attributes.getNamedItem("name");
74 if (name != null)
75 controllerTag.name = name.getNodeValue().trim();
76
77 Node sequence = attributes.getNamedItem("sequence");
78 if (sequence == null)
79 throw new SAXException("LANE: missing attribute sequence");
80 controllerTag.sequence = Integer.parseInt(sequence.getNodeValue().trim());
81
82 for (Node control : XMLParser.getNodes(node.getChildNodes(), "control"))
83 {
84 NamedNodeMap attributes1 = control.getAttributes();
85
86 Node signalId = attributes1.getNamedItem("signalId");
87 controllerTag.controlSignalID = signalId.getNodeValue().trim();
88
89 Node controlType = attributes1.getNamedItem("type");
90 controllerTag.controlType = controlType.getNodeValue().trim();
91 }
92
93 return controllerTag;
94 }
95
96
97 @Override
98 public final String toString()
99 {
100 return "ControllerTag [id=" + this.id + ", type=" + this.type + ", name=" + this.name + ", sequence=" + this.sequence
101 + ", controlSignalID=" + this.controlSignalID + ", controlType=" + this.controlType + "]";
102 }
103 }