edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); }
edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; fracNotCreated = false;
    public void insert(int offset, int length, ElementSpec[] data,                       DefaultDocumentEvent ev)    {      if (length == 0)        return;      this.offset = offset;      this.length = length;      this.endOffset = offset + length;      documentEvent = ev;      // Push the root and the paragraph at offset onto the element stack.      edits.clear();      elementStack.clear();      Element current = root;      int index;      while (!current.isLeaf())        {          index = current.getElementIndex(offset);          elementStack.push(current);          current = current.getElement(index);        }      insertUpdate(data);            // This for loop applies all the changes that were made and updates the       // DocumentEvent.      int size = edits.size();      for (int i = 0; i < size; i++)        {          Edit curr = (Edit) edits.get(i);          BranchElement e = (BranchElement) curr.e;          Element[] removed = curr.getRemovedElements();          Element[] added = curr.getAddedElements();          e.replace(curr.index, removed.length, added);          addEdit(e, curr.index, removed, added);        }    }