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

Revision 76, 2.2 KB checked in by bmcguffin, 9 years ago (diff)

Added javadoc for several files.

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