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