1 package org.opentrafficsim.road.network.factory.xml.old;
2
3 import java.io.Serializable;
4
5 import org.opentrafficsim.core.network.NetworkException;
6 import org.opentrafficsim.road.network.factory.xml.old.CrossSectionElementTag.ElementType;
7 import org.w3c.dom.NamedNodeMap;
8 import org.w3c.dom.Node;
9 import org.xml.sax.SAXException;
10
11
12
13
14
15
16
17
18
19
20 class SinkTag implements Serializable
21 {
22
23 private static final long serialVersionUID = 20150723L;
24
25
26 @SuppressWarnings("checkstyle:visibilitymodifier")
27 String positionStr = null;
28
29
30
31
32
33
34
35
36
37 @SuppressWarnings("checkstyle:needbraces")
38 static void parseSink(final Node node, final XmlNetworkLaneParserOld parser, final LinkTag linkTag)
39 throws SAXException, NetworkException
40 {
41 NamedNodeMap attributes = node.getAttributes();
42 SinkTag sinkTag = new SinkTag();
43
44 if (attributes.getNamedItem("LANE") == null)
45 throw new SAXException("SINK: missing attribute LANE" + " for link " + linkTag.name);
46 String laneName = attributes.getNamedItem("LANE").getNodeValue().trim();
47 if (linkTag.roadLayoutTag == null)
48 throw new NetworkException("SINK: LANE " + laneName + " no ROADTYPE for link " + linkTag.name);
49 CrossSectionElementTag cseTag = linkTag.roadLayoutTag.cseTags.get(laneName);
50 if (cseTag == null)
51 throw new NetworkException("SINK: LANE " + laneName + " not found in elements of link " + linkTag.name
52 + " - roadtype " + linkTag.roadLayoutTag.name);
53 if (cseTag.elementType != ElementType.LANE)
54 throw new NetworkException("SINK: LANE " + laneName + " not a real GTU lane for link " + linkTag.name
55 + " - roadtype " + linkTag.roadLayoutTag.name);
56 if (linkTag.sinkTags.containsKey(laneName))
57 throw new SAXException("SINK for LANE with NAME " + laneName + " defined twice");
58
59 Node position = attributes.getNamedItem("POSITION");
60 if (position == null)
61 throw new NetworkException("SINK: POSITION element not found in elements of link " + linkTag.name + " - roadtype "
62 + linkTag.roadLayoutTag.name);
63 sinkTag.positionStr = position.getNodeValue().trim();
64
65 linkTag.sinkTags.put(laneName, sinkTag);
66 }
67
68
69 @Override
70 public final String toString()
71 {
72 return "SinkTag [positionStr=" + this.positionStr + "]";
73 }
74 }