Warning: Can't use blame annotator:
svn blame failed on trunk/src/scriptbuilder/structures/CadData.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/CadData.java @ 47

Revision 47, 4.9 KB checked in by bmcguffin, 9 years ago (diff)

Updated toXML behaviors for several classes to bring final adjustments in line with desired output.

RevLine 
1package scriptbuilder.structures;
2
3import java.util.ArrayList;
4
5/**
6 * Aggregation of several information fields relevant to each timeslice.
7 *
8 * @author Bryan McGuffin
9 */
10public class CadData implements I_XML_Writable
11{
12
13    public CadData()
14    {
15        locInfo = new ArrayList<Location_Info>();
16    }
17
18    public TimeSlice tSlice;
19
20    public String Header_Type = "";
21
22    public String Header_Beat = "";
23
24    public String Header_TruncLoc = "";
25
26    public String Header_FullLoc = "";
27
28    public String Master_Inc_Num = "";
29
30    public String P = "";
31
32    public String Info_Type = "";
33
34    public String Info_Type_Code = "";
35
36    public String Agy = "";
37
38    public String General_Title = "";
39
40    public String General_Text = "";
41
42    public String Location_Beat = "";
43
44    public String Location_Address = "";
45
46    public String Location_Loc = "";
47
48    public String Location_City = "";
49
50    public String Location_Area = "";
51
52    public String Location_Fire = "";
53
54    public String Location_Law = "";
55
56    public String Location_Ems = "";
57
58    public ArrayList<Location_Info> locInfo;
59
60    @Override
61    public String toXML()
62    {
63        String output = "";
64
65        if (!Master_Inc_Num.equals(""))
66        {
67            output += XMLWriter.simpleTag(Master_Inc_Num, ELEMENT.MASTER_INC_NUM);
68        }
69
70        if (!P.equals(""))
71        {
72            output += XMLWriter.simpleTag(P, ELEMENT.P);
73        }
74
75        if (hasAdditionalInfo())
76        {
77            output += XMLWriter.openTag(ELEMENT.ADDITIONAL_INFO.tag);
78            output += XMLWriter.simpleTag(Info_Type_Code, ELEMENT.TYPE_CODE);
79            output += XMLWriter.simpleTag(Info_Type, ELEMENT.TYPE);
80            output += XMLWriter.closeTag(ELEMENT.ADDITIONAL_INFO.tag);
81        }
82
83        if (hasLocation())
84        {
85            output += XMLWriter.openTag(ELEMENT.LOCATION.tag);
86            if (!Location_Beat.equals(""))
87            {
88                output += XMLWriter.simpleTag(Location_Beat, ELEMENT.BEAT);
89            }
90
91            if (!Location_Address.equals(""))
92            {
93                output += XMLWriter.simpleTag(Location_Address, ELEMENT.ADDRESS);
94            }
95
96            if (!Location_Loc.equals(""))
97            {
98                output += XMLWriter.simpleTag(Location_Loc, ELEMENT.LOC);
99            }
100
101            if (!Location_City.equals(""))
102            {
103                output += XMLWriter.simpleTag(Location_City, ELEMENT.CITY);
104            }
105
106            if (!Location_Area.equals(""))
107            {
108                output += XMLWriter.simpleTag(Location_Area, ELEMENT.AREA);
109            }
110
111            if (!Location_Fire.equals(""))
112            {
113                output += XMLWriter.simpleTag(Location_Fire, ELEMENT.FIRE);
114            }
115
116            if (!Location_Law.equals(""))
117            {
118                output += XMLWriter.simpleTag(Location_Law, ELEMENT.LAW);
119            }
120
121            if (!Location_Ems.equals(""))
122            {
123                output += XMLWriter.simpleTag(Location_Ems, ELEMENT.EMS);
124            }
125
126            output += XMLWriter.closeTag(ELEMENT.LOCATION.tag);
127        }
128
129        if (!Agy.equals(""))
130        {
131            output += XMLWriter.openTag(ELEMENT.GENERAL.tag);
132            output += XMLWriter.simpleTag(Agy, ELEMENT.AGY);
133            output += XMLWriter.closeTag(ELEMENT.GENERAL.tag);
134        }
135
136        if (hasHeaderInfo())
137        {
138            output += XMLWriter.openTag(ELEMENT.HEADER_INFO.tag);
139
140            output += XMLWriter.simpleTag(Header_Type, ELEMENT.Type);
141
142            output += XMLWriter.simpleTag(Header_Beat, ELEMENT.Beat);
143
144            output += XMLWriter.simpleTag(Header_TruncLoc, ELEMENT.TruncLoc);
145
146            output += XMLWriter.simpleTag(Header_FullLoc, ELEMENT.FullLoc);
147
148            output += XMLWriter.closeTag(ELEMENT.HEADER_INFO.tag);
149        }
150
151        if (locInfo.size() > 0)
152        {
153            for (Location_Info li : locInfo)
154            {
155                output += li.toXML();
156            }
157        }
158
159        return output;
160    }
161
162    public boolean hasHeaderInfo()
163    {
164        return !Header_Type.equals("") || !Header_Beat.equals("")
165                || !Header_FullLoc.equals("") || !Header_TruncLoc.equals("");
166    }
167
168    public boolean hasLocation()
169    {
170        return !Location_Address.equals("") || !Location_Area.equals("")
171                || !Location_Beat.equals("") || !Location_City.equals("")
172                || !Location_Ems.equals("") || !Location_Fire.equals("")
173                || !Location_Law.equals("") || !Location_Loc.equals("");
174    }
175
176    public boolean hasGeneralInfo()
177    {
178        return !General_Text.equals("") || !General_Title.equals("");
179    }
180
181    public boolean hasAdditionalInfo()
182    {
183        return !Info_Type.equals("") || !Info_Type_Code.equals("");
184    }
185
186    public boolean hasCadData()
187    {
188        return hasHeaderInfo() || hasLocation() || hasAdditionalInfo()
189                || !Master_Inc_Num.equals("") || !P.equals("") || !Agy.equals("")
190                || locInfo.size() > 0;
191    }
192}
Note: See TracBrowser for help on using the repository browser.