if (el instanceof AbstractElement) { AbstractElement ael = (AbstractElement) el; int startOffset = ael.getStartOffset(); int endOffset = ael.getEndOffset(); int len = endOffset - startOffset; if (startOffset != offset && endOffset != offset) { Element paragraph = ael.getParentElement(); if (paragraph instanceof BranchElement) { BranchElement par = (BranchElement) paragraph; Element child1 = createLeafElement(par, ael, startOffset, offset); Element child2 = createLeafElement(par, ael, offset, endOffset); int index = par.getElementIndex(startOffset); Element[] add = new Element[]{ child1, child2 }; par.replace(index, 1, add); documentEvent.addEdit(new ElementEdit(par, index, new Element[]{ el }, add));
if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2];    Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded;  int count = el.getElementCount(); if (!(result[1] == null)) {  if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{};
    void split(Element el, int offset)    {      if (el instanceof AbstractElement)	{	  AbstractElement ael = (AbstractElement) el;	  int startOffset = ael.getStartOffset();	  int endOffset = ael.getEndOffset();	  int len = endOffset - startOffset;	  if (startOffset != offset && endOffset != offset)	    {	      Element paragraph = ael.getParentElement();	      if (paragraph instanceof BranchElement)		{		  BranchElement par = (BranchElement) paragraph;		  Element child1 = createLeafElement(par, ael, startOffset,						     offset);		  Element child2 = createLeafElement(par, ael, offset,						     endOffset);		  int index = par.getElementIndex(startOffset);          Element[] add = new Element[]{ child1, child2 };		  par.replace(index, 1, add);          documentEvent.addEdit(new ElementEdit(par, index,                                                new Element[]{ el },                                                add));		}              else                throw new AssertionError("paragraph elements are expected to "                                         + "be instances of "			  + "javax.swing.text.AbstractDocument.BranchElement");	    }	}      else	throw new AssertionError("content elements are expected to be "				 + "instances of "			+ "javax.swing.text.AbstractDocument.AbstractElement");    }