if (data[0].getType() == ElementSpec.EndTagType)
int i = 0; if (data[0].getType() == ElementSpec.ContentType)
    protected void insertUpdate(ElementSpec[] data)    {      if (data[0].getType() == ElementSpec.EndTagType)        {          // fracture deepest child here          BranchElement paragraph = (BranchElement) elementStack.peek();          Element curr = paragraph.getParentElement();          int index = curr.getElementIndex(offset);          while (!curr.isLeaf())            {              index = curr.getElementIndex(offset);              curr = curr.getElement(index);            }          Element parent = curr.getParentElement();          Element newEl1 = createLeafElement(parent,                                             curr.getAttributes(),                                             curr.getStartOffset(), offset);          Element grandParent = parent.getParentElement();          BranchElement nextBranch =             (BranchElement) grandParent.getElement              (grandParent.getElementIndex(parent.getEndOffset()));          Element firstLeaf = nextBranch.getElement(0);          while (!firstLeaf.isLeaf())              firstLeaf = firstLeaf.getElement(0);                    BranchElement parent2 = (BranchElement) firstLeaf.getParentElement();          Element newEl2 =             createLeafElement(parent2,                               firstLeaf.getAttributes(),                               offset, firstLeaf.getEndOffset());          parent2.replace(0, 1, new Element[] { newEl2 });                    ((BranchElement) parent).              replace(index, 1, new Element[] { newEl1 });        }            for (int i = 0; i < data.length; i++)        {          BranchElement paragraph = (BranchElement) elementStack.peek();          switch (data[i].getType())            {            case ElementSpec.StartTagType:              switch (data[i].getDirection())                {                case ElementSpec.JoinFractureDirection:                  insertFracture(data[i]);              break;                case ElementSpec.JoinNextDirection:                  int index = paragraph.getElementIndex(offset);                  elementStack.push(paragraph.getElement(index));                  break;                case ElementSpec.OriginateDirection:                  Element current = (Element) elementStack.peek();                  Element newParagraph =                    insertParagraph((BranchElement) current, offset);                  elementStack.push(newParagraph);              break;            default:              break;            }              break;            case ElementSpec.EndTagType:          elementStack.pop();              break;            case ElementSpec.ContentType:              insertContentTag(data[i]);              break;            }        }    }