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