Source code: jflight/model/RteContainer.java
1 /*
2 Project name: JFlight
3 Hosted at: www.sourceforge.net
4 Homepage: jflight.sourceforge.net
5 Licence: GNU General Public Licence (GPL)
6 */
7
8 package jflight.model;
9
10 import java.util.Vector;
11
12 /**
13 * Class RteContainer holds all Routes
14 * @author Ingo Koerber
15 */
16 public class RteContainer extends DataContainer
17 {
18 private static RteContainer rteContainer = null;
19 private Vector data = null;
20
21
22 private RteContainer()
23 {
24 super();
25 data = new Vector();
26 }
27
28 public void addRoute(Rte curRte)
29 {
30 this.dataHasChanged = true;
31 data.addElement(curRte);
32 }
33
34 public void removeAllRoutes()
35 {
36 this.dataHasChanged = true;
37 data.removeAllElements();
38 }
39
40 public Rte routeAt(int i)
41 {
42
43 return (Rte)data.elementAt(i);
44 }
45
46 public int size()
47 {
48 return data.size();
49 }
50
51 public static RteContainer getInstance() {
52 if(rteContainer == null) {
53 rteContainer = new RteContainer();
54 }
55 return rteContainer;
56 }
57
58 /**
59 * Returns a route.
60 *
61 * @param name Nameof the route in the list
62 * @return route object (Rte)
63 *
64 */
65 public Object getRteFromList(String name)
66 {
67 Rte curRte = null;
68 for(int i=0; i<data.size(); i++ ) {
69 curRte = (Rte) data.elementAt(i);
70 if( name.equals(curRte.getComment()) ){
71 return curRte;
72 }
73 }
74 return null;
75 }
76 }
77