001package com.plivo.api.xml;
002
003import com.plivo.api.exceptions.PlivoXmlException;
004import java.util.ArrayList;
005import java.util.List;
006import javax.xml.bind.annotation.XmlAttribute;
007import javax.xml.bind.annotation.XmlMixed;
008import javax.xml.bind.annotation.XmlRootElement;
009
010@XmlRootElement(name = "w")
011public class W extends PlivoXml implements EmphasisNestable,
012                                           LangNestable,
013                                           PNestable,
014                                           ProsodyNestable,
015                                           SNestable,
016                                           SpeakNestable {
017
018  @XmlMixed
019  private List<Object> mixedContent = new ArrayList<Object>();
020
021  @XmlAttribute
022  private String role;
023
024  public W() {
025  }
026
027  public W(String content) {
028    this.mixedContent.add(content);
029  }
030
031  public W(String content, String role) {
032    this.mixedContent.add(content);
033    this.role = role;
034  }
035
036  public String getRole() {
037    return this.role;
038  }
039
040  public W children(Object... nestables) throws PlivoXmlException {
041    for (Object obj : nestables) {
042      if (obj instanceof WNestable || obj instanceof String) {
043        mixedContent.add(obj);
044      } else {
045        throw new PlivoXmlException("XML Validation Error: <" + obj.getClass().getSimpleName() + "> can not be nested in <w>");
046      }
047    }
048    return this;
049  }
050}