Esempio n. 1
0
 public void append(MaryData md) {
   if (md == null) throw new NullPointerException("Received null marydata");
   if (!md.getType().equals(this.getType()))
     throw new IllegalArgumentException(
         "Cannot append mary data of type `"
             + md.getType().name()
             + "' to mary data of type `"
             + this.getType().name()
             + "'");
   if (getType().isXMLType()) {
     NodeList kids = md.getDocument().getDocumentElement().getChildNodes();
     logger.debug("Appending " + kids.getLength() + " nodes to MaryXML structure");
     Element docEl = this.getDocument().getDocumentElement();
     for (int i = 0; i < kids.getLength(); i++) {
       docEl.appendChild(this.getDocument().importNode(kids.item(i), true));
     }
   } else if (getType().isTextType()) {
     // Attention: XML type is a text type!
     if (this.plainText == null) {
       this.plainText = md.getPlainText();
     } else {
       this.plainText = this.plainText + "\n\n" + md.getPlainText();
     }
   } else if (getType().equals(MaryDataType.get("AUDIO"))) {
     appendAudio(md.getAudio());
   } else {
     throw new UnsupportedOperationException(
         "Cannot append two mary data items of type `" + getType() + "'");
   }
 }