source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/units/Unit.java @ 145

Revision 145, 4.3 KB checked in by sdanthin, 6 years ago (diff)

Move from Git to Svn (LARGE COMMIT)

Line 
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package scriptbuilder.structures.units;
7
8import scriptbuilder.structures.ELEMENT;
9import scriptbuilder.structures.I_XML_Writable;
10import scriptbuilder.structures.XMLWriter;
11
12/**
13 * Placeholder until I add some functionality. Represents an officer in a
14 * vehicle on the map. Has a name, ID, position, and status, as well as several
15 * other identifying factors.
16 *
17 * @author Bryan McGuffin
18 */
19public class Unit implements I_XML_Writable
20{
21
22    public String UnitNum;
23
24    public String ID;
25
26    public String Status;
27
28    public String Master_Inc_Num;
29
30    public String Primary;
31
32    public String OOS;
33
34    public String Type;
35
36    public String Curr_Loc;
37
38    public String Destination;
39
40    public String Misc_Info;
41
42    public String Stack;
43
44    public String Area;
45
46    public String Officer;
47
48    public String Badge_Num;
49
50    public String Timer;
51
52    public String Office;
53
54    public String P;
55
56    public String Agy;
57
58    public String Alias;
59
60    public String Unit_Status;
61
62    public Unit()
63    {
64        UnitNum = "";
65
66        ID = "";
67
68        Status = "";
69
70        Master_Inc_Num = "";
71
72        Primary = "";
73
74        OOS = "";
75
76        Type = "";
77
78        Curr_Loc = "";
79
80        Destination = "";
81
82        Misc_Info = "";
83
84        Stack = "";
85
86        Area = "";
87
88        Officer = "";
89
90        Badge_Num = "";
91
92        Timer = "";
93
94        Office = "";
95
96        P = "";
97
98        Agy = "";
99
100        Alias = "";
101
102        Unit_Status = "";
103    }
104   
105    public boolean equals(Unit u){
106        return UnitNum.equals(u.UnitNum);
107    }
108    public boolean equals(String num){
109        return UnitNum.equals(num);
110    }
111
112    @Override
113    public String toXML()
114    {
115        String output = XMLWriter.openTag(ELEMENT.NEW_UNIT.tag + " UnitNum=\"" + UnitNum + "\"");
116
117        if (!ID.equals(""))
118        {
119            output += XMLWriter.simpleTag(ID, ELEMENT.ID);
120        }
121
122        if (!Status.equals(""))
123        {
124            output += XMLWriter.simpleTag(Status, ELEMENT.STATUS);
125        }
126
127        if (!Master_Inc_Num.equals(""))
128        {
129            output += XMLWriter.simpleTag(Master_Inc_Num, ELEMENT.MASTER_INC_NUM);
130        }
131
132        if (!Primary.equals(""))
133        {
134            output += XMLWriter.simpleTag(Primary, ELEMENT.PRIMARY);
135        }
136
137        if (!OOS.equals(""))
138        {
139            output += XMLWriter.simpleTag(OOS, ELEMENT.OOS);
140        }
141
142        if (!Type.equals(""))
143        {
144            output += XMLWriter.simpleTag(Type, ELEMENT.TYPE);
145        }
146
147        //All units have a current location field, even if it's blank
148        output += XMLWriter.simpleTag(Curr_Loc, ELEMENT.CURR_LOC);
149
150        //All units have a destination field, even if it's blank
151        output += XMLWriter.simpleTag(Destination, ELEMENT.DESTINATION);
152
153        if (!Misc_Info.equals(""))
154        {
155            output += XMLWriter.simpleTag(Misc_Info, ELEMENT.MISC_INFO);
156        }
157
158        if (!Stack.equals(""))
159        {
160            output += XMLWriter.simpleTag(Stack, ELEMENT.STACK);
161        }
162
163        if (!Area.equals(""))
164        {
165            output += XMLWriter.simpleTag(Area, ELEMENT.AREA);
166        }
167
168        if (!Badge_Num.equals(""))
169        {
170            output += XMLWriter.simpleTag(Badge_Num, ELEMENT.BADGE_NUM);
171        }
172
173        if (!Officer.equals(""))
174        {
175            output += XMLWriter.simpleTag(Officer, ELEMENT.OFFICER);
176        }
177
178        if (!Office.equals(""))
179        {
180            output += XMLWriter.simpleTag(Office, ELEMENT.OFFICE);
181        }
182
183        if (!Timer.equals(""))
184        {
185            output += XMLWriter.simpleTag(Timer, ELEMENT.TIMER);
186        }
187
188        if (!P.equals(""))
189        {
190            output += XMLWriter.simpleTag(P, ELEMENT.P);
191        }
192
193        if (!Agy.equals(""))
194        {
195            output += XMLWriter.simpleTag(Agy, ELEMENT.AGY);
196        }
197
198        if (!Alias.equals(""))
199        {
200            output += XMLWriter.simpleTag(Alias, ELEMENT.ALIAS);
201        }
202
203        if (!Unit_Status.equals(""))
204        {
205            output += XMLWriter.simpleTag(Unit_Status, ELEMENT.UNIT_STATUS);
206        }
207
208        output += XMLWriter.closeTag(ELEMENT.NEW_UNIT.tag);
209        return output;
210    }
211}
Note: See TracBrowser for help on using the repository browser.