All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.plivo.api.xml.W Maven / Gradle / Ivy

Go to download

A Java SDK to make voice calls & send SMS using Plivo and to generate Plivo XML

There is a newer version: 5.46.0
Show newest version
package com.plivo.api.xml;

import com.plivo.api.exceptions.PlivoXmlException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "w")
public class W extends PlivoXml implements EmphasisNestable,
                                           LangNestable,
                                           PNestable,
                                           ProsodyNestable,
                                           SNestable,
                                           SpeakNestable {

  @XmlMixed
  private List mixedContent = new ArrayList();

  @XmlAttribute
  private String role;

  public W() {
  }

  public W(String content) {
    this.mixedContent.add(content);
  }

  public W(String content, String role) {
    this.mixedContent.add(content);
    this.role = role;
  }

  public String getRole() {
    return this.role;
  }

  public W children(Object... nestables) throws PlivoXmlException {
    for (Object obj : nestables) {
      if (obj instanceof WNestable || obj instanceof String) {
        mixedContent.add(obj);
      } else {
        throw new PlivoXmlException("XML Validation Error: <" + obj.getClass().getSimpleName() + "> can not be nested in ");
      }
    }
    return this;
  }
}