edits.clear(); elementStack.clear();
    private void finishEdit(DefaultDocumentEvent ev)    {      // This for loop applies all the changes that were made and updates the       // DocumentEvent.      for (Iterator i = edits.iterator(); i.hasNext();)        {          Edit edits = (Edit) i.next();          Element[] removed = new Element[edits.removed.size()];          removed = (Element[]) edits.removed.toArray(removed);          Element[] added = new Element[edits.added.size()];          added = (Element[]) edits.added.toArray(added);          int index = edits.index;          BranchElement parent = (BranchElement) edits.e;          parent.replace(index, removed.length, added);          ElementEdit ee = new ElementEdit(parent, index, removed, added);          ev.addEdit(ee);        }    }