source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/events/RadioEvaluationEvent.java @ 36

Revision 36, 1.8 KB checked in by bmcguffin, 9 years ago (diff)

Added toXML implementation for all remaining event classes.

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 */
6
7package scriptbuilder.structures.events;
8
9import java.util.ArrayList;
10import scriptbuilder.structures.ELEMENT;
11import scriptbuilder.structures.I_XML_Writable;
12import scriptbuilder.structures.ScriptEvent;
13
14/**
15 * Data model for a radio evaluation event. This is an evaluation event.
16 *
17 * @author Bryan McGuffin
18 */
19public class RadioEvaluationEvent extends ScriptEvent implements I_EvaluationEvent, I_XML_Writable
20{
21
22    public RadioEvaluationEvent()
23    {
24        super(ScriptEventType.RADIO_EVAL_EVENT);
25    }
26   
27    public ArrayList<String> expectedAction = new ArrayList<String>();
28   
29    @Override
30    public ArrayList<String> getExpectedActions()
31    {
32        return expectedAction;
33    }
34   
35    @Override
36    public void addAction(String act)
37    {
38        expectedAction.add(act);
39    }
40
41    @Override
42    public void updateAction(int index, String act)
43    {
44        expectedAction.set(index, act);
45    }
46   
47    @Override
48    public void removeAction(int index)
49    {
50        expectedAction.remove(index);
51    }
52
53    @Override
54    public String toXML()
55    {
56        String output = openTag(ELEMENT.RADIO_EVALUATION.tag);
57        output += openTag(ELEMENT.EXPECTED_ACTION.tag);
58        output += expectedAction;
59        output += closeTag(ELEMENT.EXPECTED_ACTION.tag);
60        output += closeTag(ELEMENT.RADIO_EVALUATION.tag);
61       
62        return output;
63    }
64
65    @Override
66    public String openTag(String s)
67    {
68        return "<" + s + ">\n";
69    }
70
71    @Override
72    public String closeTag(String s)
73    {
74        return "</" + s + ">\n";
75    }
76
77    @Override
78    public String emptyTag(String s)
79    {
80        return "<" + s + "/>\n";
81    }
82}
Note: See TracBrowser for help on using the repository browser.