source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/events/TelephoneEvent.java @ 46

Revision 46, 1.6 KB checked in by bmcguffin, 9 years ago (diff)

Added file: XMLWriter, in package Scriptbuilder.structures. It holds static methods which ither classes that implement I_XML_Writable may find useful. Also restructured the toXML method of many classes to utilize this new class.

Line 
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 */
6package scriptbuilder.structures.events;
7
8import java.util.ArrayList;
9import scriptbuilder.structures.ELEMENT;
10import scriptbuilder.structures.I_XML_Writable;
11import scriptbuilder.structures.ScriptEvent;
12import scriptbuilder.structures.XMLWriter;
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 */
21public class TelephoneEvent extends ScriptEvent implements I_XML_Writable
22{
23
24    public TelephoneEvent()
25    {
26        super(ScriptEventType.TELEPHONE_EVENT);
27    }
28
29    public ArrayList<String> lines = new ArrayList<String>();
30
31    public ArrayList<String> roles = new ArrayList<String>();
32
33    @Override
34    public String toXML()
35    {
36        String output = XMLWriter.openTag(ELEMENT.TELEPHONE.tag);
37        for (int i = 0; i < lines.size(); i++)
38        {
39            if (roles.get(i).equalsIgnoreCase(ELEMENT.STUDENT.tag))
40            {
41                output += XMLWriter.simpleTag(lines.get(i), ELEMENT.STUDENT);
42            }
43            else
44            {
45                output += XMLWriter.openTag(ELEMENT.INSTRUCTOR.tag + " Role=\"" + roles.get(i) + "\"");
46                output += lines.get(i);
47                output += XMLWriter.closeTag(ELEMENT.INSTRUCTOR.tag);
48            }
49        }
50        output += XMLWriter.closeTag(ELEMENT.TELEPHONE.tag);
51        return output;
52    }
53}
Note: See TracBrowser for help on using the repository browser.