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

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

Revision 42, 2.0 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 an ATMS evaluation event. This is an evaluation event.
15 *
16 * @author Bryan McGuffin
17 */
18public class ATMSEvaluationEvent extends ScriptEvent implements I_EvaluationEvent, I_XML_Writable
19{
20
21    public ATMSEvaluationEvent()
22    {
23        super(ScriptEventType.ATMS_EVAL_EVENT);
24    }
25
26    public ArrayList<String> expectedAction = new ArrayList<String>();
27
28    @Override
29    public ArrayList<String> getExpectedActions()
30    {
31        return expectedAction;
32    }
33
34    @Override
35    public void addAction(String act)
36    {
37        expectedAction.add(act);
38    }
39
40    @Override
41    public void updateAction(int index, String act)
42    {
43        expectedAction.set(index, act);
44    }
45
46    @Override
47    public void removeAction(int index)
48    {
49        expectedAction.remove(index);
50    }
51
52    @Override
53    public String toXML()
54    {
55        String output = openTag(ELEMENT.ATMS_EVALUATION.tag);
56        if (expectedAction != null)
57        {
58            for (String str : expectedAction)
59            {
60                if (str == null)
61                {
62                    str = "";
63                }
64                output += openTag(ELEMENT.EXPECTED_ACTION.tag);
65                output += str;
66                output += closeTag(ELEMENT.EXPECTED_ACTION.tag);
67            }
68        }
69        output += closeTag(ELEMENT.ATMS_EVALUATION.tag);
70
71        return output;
72    }
73
74    @Override
75    public String openTag(String s)
76    {
77        return "<" + s + ">";
78    }
79
80    @Override
81    public String closeTag(String s)
82    {
83        return "</" + s + ">\n";
84    }
85
86    @Override
87    public String emptyTag(String s)
88    {
89        return "<" + s + "/>\n";
90    }
91}
Note: See TracBrowser for help on using the repository browser.