| 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 CHP radio event. A CHP radio transmission has a |
|---|
| 15 | * conversation, with dialog between a field unit and a dispatch center. It also |
|---|
| 16 | * has an audio file which has that conversation acted out. |
|---|
| 17 | * |
|---|
| 18 | * @author Bryan McGuffin |
|---|
| 19 | */ |
|---|
| 20 | public class CHPRadioEvent extends ScriptEvent implements I_XML_Writable |
|---|
| 21 | { |
|---|
| 22 | |
|---|
| 23 | public CHPRadioEvent() |
|---|
| 24 | { |
|---|
| 25 | super(ScriptEventType.CHP_RADIO_EVENT); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | public ArrayList<String> lines = new ArrayList<String>(); |
|---|
| 29 | |
|---|
| 30 | public ArrayList<String> roles = new ArrayList<String>(); |
|---|
| 31 | |
|---|
| 32 | public String radioFile = ""; |
|---|
| 33 | |
|---|
| 34 | @Override |
|---|
| 35 | public String toXML() |
|---|
| 36 | { |
|---|
| 37 | String output = openTag(ELEMENT.CHP_RADIO.tag + " RadioFile=\"" + radioFile + "\""); |
|---|
| 38 | output += openTag(ELEMENT.DIALOG.tag); |
|---|
| 39 | |
|---|
| 40 | for (int i = 0; i < lines.size(); i++) |
|---|
| 41 | { |
|---|
| 42 | output += openTag(ELEMENT.LINE.tag + " Role=\"" + roles.get(i) + "\""); |
|---|
| 43 | output += lines.get(i); |
|---|
| 44 | output += closeTag(ELEMENT.LINE.tag); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | output += closeTag(ELEMENT.DIALOG.tag); |
|---|
| 48 | output += closeTag(ELEMENT.CHP_RADIO.tag); |
|---|
| 49 | |
|---|
| 50 | return output; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | @Override |
|---|
| 54 | public String openTag(String s) |
|---|
| 55 | { |
|---|
| 56 | return "<" + s + ">"; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | @Override |
|---|
| 60 | public String closeTag(String s) |
|---|
| 61 | { |
|---|
| 62 | return "</" + s + ">\n"; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | @Override |
|---|
| 66 | public String emptyTag(String s) |
|---|
| 67 | { |
|---|
| 68 | return "<" + s + "/>\n"; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | } |
|---|