/**
  * Appends a whole StyledDocument to the end of the current document, by adding all the elements
  * of the latter to the end of the former.
  *
  * @param doc The StyledDocument to add to the end of current document.
  */
 public void append(StyledDocument doc) {
   if (doc != null) {
     for (int i = 0; i < doc.getLength(); i++) {
       elements.add((StyledElement) doc.getStyledElement(i));
     }
   }
 }