| 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.XMLBuilder; |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | * Data model for a telephone conversation. A conversation is made up of lines |
|---|
| 16 | * of dialog; each line of dialog in the conversation has some text to be |
|---|
| 17 | * spoken, and a role for the speaker. |
|---|
| 18 | * |
|---|
| 19 | * @author Bryan McGuffin |
|---|
| 20 | */ |
|---|
| 21 | public class TelephoneEvent extends ScriptEvent implements I_XML_Writable |
|---|
| 22 | { |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * Constructor. |
|---|
| 26 | */ |
|---|
| 27 | public TelephoneEvent() |
|---|
| 28 | { |
|---|
| 29 | super(ScriptEventType.TELEPHONE_EVENT); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | public ArrayList<String> lines = new ArrayList<String>(); |
|---|
| 33 | |
|---|
| 34 | public ArrayList<String> roles = new ArrayList<String>(); |
|---|
| 35 | |
|---|
| 36 | @Override |
|---|
| 37 | public String toXML() |
|---|
| 38 | { |
|---|
| 39 | String output = XMLBuilder.openTag(ELEMENT.TELEPHONE.tag); |
|---|
| 40 | for (int i = 0; i < lines.size(); i++) |
|---|
| 41 | { |
|---|
| 42 | if (roles.get(i).equalsIgnoreCase(ELEMENT.STUDENT.tag)) |
|---|
| 43 | { |
|---|
| 44 | output += XMLBuilder.simpleTag(lines.get(i), ELEMENT.STUDENT); |
|---|
| 45 | } |
|---|
| 46 | else |
|---|
| 47 | { |
|---|
| 48 | output += XMLBuilder.openTag(ELEMENT.INSTRUCTOR.tag + " Role=\"" + roles.get(i) + "\""); |
|---|
| 49 | output += lines.get(i); |
|---|
| 50 | output += XMLBuilder.closeTag(ELEMENT.INSTRUCTOR.tag); |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | output += XMLBuilder.closeTag(ELEMENT.TELEPHONE.tag); |
|---|
| 54 | return output; |
|---|
| 55 | } |
|---|
| 56 | } |
|---|