| 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.StringTokenizer; |
|---|
| 9 | import scriptbuilder.structures.ELEMENT; |
|---|
| 10 | import scriptbuilder.structures.I_XML_Writable; |
|---|
| 11 | import scriptbuilder.structures.ScriptEvent; |
|---|
| 12 | import scriptbuilder.structures.XMLBuilder; |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | * Data model for a CAD incident event. CAD events have a string description of |
|---|
| 16 | * what is occurring at that time, and may or may not have sub-events. |
|---|
| 17 | * |
|---|
| 18 | * @author Bryan McGuffin |
|---|
| 19 | */ |
|---|
| 20 | public class CADEvent extends ScriptEvent implements I_XML_Writable |
|---|
| 21 | { |
|---|
| 22 | |
|---|
| 23 | /** |
|---|
| 24 | * Constructor. |
|---|
| 25 | */ |
|---|
| 26 | public CADEvent() |
|---|
| 27 | { |
|---|
| 28 | super(ScriptEventType.CAD_EVENT); |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | /** |
|---|
| 32 | * True if this CAD event has sub-events. |
|---|
| 33 | */ |
|---|
| 34 | public boolean hasSubEvents = false; |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * Description of this event. |
|---|
| 38 | */ |
|---|
| 39 | public String detail = ""; |
|---|
| 40 | |
|---|
| 41 | @Override |
|---|
| 42 | public String toXML() |
|---|
| 43 | { |
|---|
| 44 | StringTokenizer tok = new StringTokenizer(detail, "\n"); |
|---|
| 45 | String output = ""; |
|---|
| 46 | while (tok.hasMoreTokens()) |
|---|
| 47 | { |
|---|
| 48 | output += XMLBuilder.simpleTag(tok.nextToken(), ELEMENT.DETAIL); |
|---|
| 49 | } |
|---|
| 50 | return output; |
|---|
| 51 | } |
|---|
| 52 | /** |
|---|
| 53 | * @return a string representation of this event. Used for example in |
|---|
| 54 | * Script Events Panel of Incident Editor window. |
|---|
| 55 | */ |
|---|
| 56 | @Override |
|---|
| 57 | public String toString() |
|---|
| 58 | { |
|---|
| 59 | return getScriptEventType().toString() + " " + detail; |
|---|
| 60 | } |
|---|
| 61 | } |
|---|