View Javadoc

1   /*
2    * @(#)SwitchVirtualBlock.java Jun 20, 2004
3    * 
4    * Copyright (c) 2004 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  
11  package nl.tudelft.simulation.traffic.controlpoint.blocks;
12  
13  import java.util.HashMap;
14  import java.util.Map;
15  
16  /***
17   * Th SwitchVirtualBlock defines the block to be guarded.
18   * <p>
19   * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
20   * University of Technology </a>, the Netherlands. <br>
21   * See for project information <a href="http://www.simulation.tudelft.nl">
22   * www.simulation.tudelft.nl </a> <br>
23   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
24   * License (GPL) </a>, no warranty <br>
25   * 
26   * @version Jun 20, 2004 <br>
27   * @author <a
28   * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
29   * Verbraeck </a>
30   */
31  public class SwitchVirtualBlock extends VirtualBlock
32  {
33      /*** the directions contained in the virtual block * */
34      private Map directions = new HashMap();
35  
36      /***
37       * constucts a new SwitchVirtualBlock
38       * 
39       * @param name the name of the SwitchVirtualBlock
40       */
41      public SwitchVirtualBlock(String name)
42      {
43          super(name);
44      }
45  
46      /***
47       * adds a direction to the block
48       * 
49       * @param trafficLight
50       * @param line
51       * @param complexLink
52       * @param track
53       */
54      public void addSwitchDirection(final SwitchBlockTrafficLight trafficLight,
55              final int line, final String complexLink, final String track)
56      {
57          Record record = new Record(trafficLight, line, complexLink, track);
58          this.directions.put(trafficLight.toString() + "@" + line, record);
59      }
60  
61      /***
62       * An innerclass containing the record.
63       */
64      private static class Record
65      {
66          /*** the traficLight * */
67          private SwitchBlockTrafficLight trafficLight = null;
68  
69          /*** the line */
70          private int line;
71  
72          /*** the complexLine */
73          private String complexLine = null;
74  
75          /*** the track */
76          private String track = null;
77  
78          /***
79           * construct a new Record
80           * 
81           * @param trafficLight the trafficLight
82           * @param line the line
83           * @param complexLine the complexLine
84           * @param track the track
85           */
86          public Record(SwitchBlockTrafficLight trafficLight, int line,
87                  String complexLine, String track)
88          {
89              super();
90              this.trafficLight = trafficLight;
91              this.line = line;
92              this.complexLine = complexLine;
93              this.track = track;
94          }
95  
96          /***
97           * @return Returns the complexLine.
98           */
99          public String getComplexLine()
100         {
101             return this.complexLine;
102         }
103 
104         /***
105          * @return Returns the line.
106          */
107         public int getLine()
108         {
109             return this.line;
110         }
111 
112         /***
113          * @return Returns the track.
114          */
115         public String getTrack()
116         {
117             return this.track;
118         }
119 
120         /***
121          * @return Returns the trafficLight.
122          */
123         public SwitchBlockTrafficLight getTrafficLight()
124         {
125             return this.trafficLight;
126         }
127     }
128 }