/* * 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; import scriptbuilder.structures.XMLWriter; /** * 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 { /** * Constructor. */ public TelephoneEvent() { super(ScriptEventType.TELEPHONE_EVENT); } public ArrayList lines = new ArrayList(); public ArrayList roles = new ArrayList(); @Override public String toXML() { String output = XMLWriter.openTag(ELEMENT.TELEPHONE.tag); for (int i = 0; i < lines.size(); i++) { if (roles.get(i).equalsIgnoreCase(ELEMENT.STUDENT.tag)) { output += XMLWriter.simpleTag(lines.get(i), ELEMENT.STUDENT); } else { output += XMLWriter.openTag(ELEMENT.INSTRUCTOR.tag + " Role=\"" + roles.get(i) + "\""); output += lines.get(i); output += XMLWriter.closeTag(ELEMENT.INSTRUCTOR.tag); } } output += XMLWriter.closeTag(ELEMENT.TELEPHONE.tag); return output; } }