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);
int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix));
    protected void insertUpdate(ElementSpec[] data)    {      int i = 0;      if (data[0].getType() == ElementSpec.ContentType)        {          // If the first tag is content we must treat it separately to allow          // for joining properly to previous Elements and to ensure that          // no extra LeafElements are erroneously inserted.          i = 1;          insertFirstContentTag(data);        }      else        createFracture(data);            // Handle each ElementSpec individually.      for (; i < data.length; i++)        {          BranchElement paragraph = (BranchElement) elementStack.peek();          switch (data[i].getType())            {            case ElementSpec.StartTagType:              switch (data[i].getDirection())                {                case ElementSpec.JoinFractureDirection:                  // Fracture the tree and ensure the appropriate element                  // is on top of the stack.                  insertFracture(data[i]);              break;                case ElementSpec.JoinNextDirection:                  // Push the next paragraph element onto the stack so                   // future insertions are added to it.                  int index = paragraph.getElementIndex(offset);                  elementStack.push(paragraph.getElement(index));                  break;                case ElementSpec.OriginateDirection:                  // Create a new paragraph and push it onto the stack.                  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;            }        }    }