| 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 | package scriptbuilder.structures.events; |
|---|
| 7 | |
|---|
| 8 | import java.util.ArrayList; |
|---|
| 9 | import scriptbuilder.structures.ELEMENT; |
|---|
| 10 | import scriptbuilder.structures.I_XML_Writable; |
|---|
| 11 | import 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 | */ |
|---|
| 19 | public 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 | output += openTag(ELEMENT.CMS_LINE.tag); |
|---|
| 75 | output += str; |
|---|
| 76 | output += closeTag(ELEMENT.CMS_LINE.tag); |
|---|
| 77 | } |
|---|
| 78 | output += closeTag(ELEMENT.SAMPLE_MESSAGE.tag); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | output += closeTag(ELEMENT.CMS_EVALUATION.tag); |
|---|
| 82 | |
|---|
| 83 | return output; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | @Override |
|---|
| 87 | public String openTag(String s) |
|---|
| 88 | { |
|---|
| 89 | return "<" + s + ">\n"; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | @Override |
|---|
| 93 | public String closeTag(String s) |
|---|
| 94 | { |
|---|
| 95 | return "</" + s + ">\n"; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | @Override |
|---|
| 99 | public String emptyTag(String s) |
|---|
| 100 | { |
|---|
| 101 | return "<" + s + "/>\n"; |
|---|
| 102 | } |
|---|
| 103 | } |
|---|