source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/events/CADEvaluationEvent.java @ 46

Revision 46, 1.7 KB checked in by bmcguffin, 9 years ago (diff)

Added file: XMLWriter, in package Scriptbuilder.structures. It holds static methods which ither classes that implement I_XML_Writable may find useful. Also restructured the toXML method of many classes to utilize this new class.

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.events;
7
8import java.util.ArrayList;
9import scriptbuilder.structures.ELEMENT;
10import scriptbuilder.structures.I_XML_Writable;
11import scriptbuilder.structures.ScriptEvent;
12import scriptbuilder.structures.XMLWriter;
13
14/**
15 * Data model for a CAD evaluation event. This is an evaluation event.
16 *
17 * @author Bryan McGuffin
18 */
19public class CADEvaluationEvent extends ScriptEvent implements I_EvaluationEvent, I_XML_Writable
20{
21
22    public CADEvaluationEvent()
23    {
24        super(ScriptEventType.CAD_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 = XMLWriter.openTag(ELEMENT.CAD_EVALUATION.tag);
57        if (expectedAction != null)
58        {
59            for (String str : expectedAction)
60            {
61                if (str == null)
62                {
63                    str = "";
64                }
65                output += XMLWriter.simpleTag(str, ELEMENT.EXPECTED_ACTION);
66            }
67        }
68        output += XMLWriter.closeTag(ELEMENT.CAD_EVALUATION.tag);
69
70        return output;
71    }
72}
Note: See TracBrowser for help on using the repository browser.