| 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 | import scriptbuilder.structures.XMLWriter; |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | * Data model for a CAD evaluation event. This is an evaluation event. |
|---|
| 16 | * |
|---|
| 17 | * @author Bryan McGuffin |
|---|
| 18 | */ |
|---|
| 19 | public class CADEvaluationEvent extends ScriptEvent implements I_EvaluationEvent, I_XML_Writable |
|---|
| 20 | { |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | * Constructor. |
|---|
| 24 | */ |
|---|
| 25 | public CADEvaluationEvent() |
|---|
| 26 | { |
|---|
| 27 | super(ScriptEventType.CAD_EVAL_EVENT); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | * A list of the expected actions held by this evaluation event. |
|---|
| 32 | */ |
|---|
| 33 | public ArrayList<String> expectedAction = new ArrayList<String>(); |
|---|
| 34 | |
|---|
| 35 | @Override |
|---|
| 36 | public ArrayList<String> getExpectedActions() |
|---|
| 37 | { |
|---|
| 38 | return expectedAction; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | @Override |
|---|
| 42 | public void addAction(String act) |
|---|
| 43 | { |
|---|
| 44 | expectedAction.add(act); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | @Override |
|---|
| 48 | public void updateAction(int index, String act) |
|---|
| 49 | { |
|---|
| 50 | expectedAction.set(index, act); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | @Override |
|---|
| 54 | public void removeAction(int index) |
|---|
| 55 | { |
|---|
| 56 | expectedAction.remove(index); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | @Override |
|---|
| 60 | public String toXML() |
|---|
| 61 | { |
|---|
| 62 | String output = XMLWriter.openTag(ELEMENT.CAD_EVALUATION.tag); |
|---|
| 63 | if (expectedAction != null) |
|---|
| 64 | { |
|---|
| 65 | for (String str : expectedAction) |
|---|
| 66 | { |
|---|
| 67 | if (str == null) |
|---|
| 68 | { |
|---|
| 69 | str = ""; |
|---|
| 70 | } |
|---|
| 71 | output += XMLWriter.simpleTag(str, ELEMENT.EXPECTED_ACTION); |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | output += XMLWriter.closeTag(ELEMENT.CAD_EVALUATION.tag); |
|---|
| 75 | |
|---|
| 76 | return output; |
|---|
| 77 | } |
|---|
| 78 | } |
|---|