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

source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/events/CMSEvaluationEvent.java @ 42

Revision 42, 2.5 KB checked in by bmcguffin, 9 years ago (diff)

Fixed a bug which caused null evaluation events to be improperly translated to text.

RevLine 
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.events;
7
8import java.util.ArrayList;
9import scriptbuilder.structures.ELEMENT;
10import scriptbuilder.structures.I_XML_Writable;
11import scriptbuilder.structures.ScriptEvent;
12
13/**
14 * Data model for a CMS evaluatiion event. A CMS event has a location, a set of
15 * messages, an ID, and a type. It also is an evaluation event.
16 *
17 * @author Bryan McGuffin
18 */
19public class CMSEvaluationEvent extends ScriptEvent implements I_EvaluationEvent, I_XML_Writable
20{
21
22    public CMSEvaluationEvent()
23    {
24        super(ScriptEventType.CMS_EVAL_EVENT);
25    }
26
27    public String location = "";
28
29    public ArrayList<String> message = new ArrayList<String>();
30
31    public String cmsID = "";
32
33    public String cmsType = "";
34
35    public ArrayList<String> expectedAction = new ArrayList<String>();
36
37    @Override
38    public ArrayList<String> getExpectedActions()
39    {
40        return expectedAction;
41    }
42
43    @Override
44    public void addAction(String act)
45    {
46        expectedAction.add(act);
47    }
48
49    @Override
50    public void updateAction(int index, String act)
51    {
52        expectedAction.set(index, act);
53    }
54
55    @Override
56    public void removeAction(int index)
57    {
58        expectedAction.remove(index);
59    }
60
61    @Override
62    public String toXML()
63    {
64        String output = openTag(ELEMENT.CMS_EVALUATION.tag + " cmsID=\"" + cmsID + "\" type=\"" + cmsType + "\"");
65        output += openTag(ELEMENT.LOCATION.tag);
66        output += location;
67        output += closeTag(ELEMENT.LOCATION.tag);
68
69        if (message.size() > 0)
70        {
71            output += openTag(ELEMENT.SAMPLE_MESSAGE.tag);
72            for (String str : message)
73            {
74                if (str == null)
75                {
76                    str = "";
77                }
78                output += openTag(ELEMENT.CMS_LINE.tag);
79                output += str;
80                output += closeTag(ELEMENT.CMS_LINE.tag);
81            }
82            output += closeTag(ELEMENT.SAMPLE_MESSAGE.tag);
83        }
84
85        output += closeTag(ELEMENT.CMS_EVALUATION.tag);
86
87        return output;
88    }
89
90    @Override
91    public String openTag(String s)
92    {
93        return "<" + s + ">";
94    }
95
96    @Override
97    public String closeTag(String s)
98    {
99        return "</" + s + ">\n";
100    }
101
102    @Override
103    public String emptyTag(String s)
104    {
105        return "<" + s + "/>\n";
106    }
107}
Note: See TracBrowser for help on using the repository browser.