/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package scriptbuilder.structures.events; import java.util.ArrayList; import scriptbuilder.structures.ELEMENT; import scriptbuilder.structures.I_XML_Writable; import scriptbuilder.structures.ScriptEvent; /** * Data model for a telephone conversation. A conversation is made up of lines * of dialog; each line of dialog in the conversation has some text to be * spoken, and a role for the speaker. * * @author Bryan McGuffin */ public class TelephoneEvent extends ScriptEvent implements I_XML_Writable { public TelephoneEvent() { super(ScriptEventType.TELEPHONE_EVENT); } public ArrayList lines = new ArrayList(); public ArrayList roles = new ArrayList(); @Override public String toXML() { String output = openTag(ELEMENT.TELEPHONE.tag); for (int i = 0; i < lines.size(); i++) { if (roles.get(i).equalsIgnoreCase(ELEMENT.STUDENT.tag)) { output += openTag(ELEMENT.STUDENT.tag); output += lines.get(i); output += closeTag(ELEMENT.STUDENT.tag); } else { output += openTag(ELEMENT.INSTRUCTOR.tag + " Role=\"" + roles.get(i) + "\""); output += lines.get(i); output += closeTag(ELEMENT.INSTRUCTOR.tag); } } output += closeTag(ELEMENT.TELEPHONE.tag); return output; } @Override public String openTag(String s) { return "<" + s + ">\n"; } @Override public String closeTag(String s) { return "\n"; } @Override public String emptyTag(String s) { return "<" + s + "/>\n"; } }