MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / splitText

Method splitText

src/main/java/org/htmlunit/html/DomText.java:58–73  ·  view source on GitHub ↗

{@inheritDoc}

(final int offset)

Source from the content-addressed store, hash-verified

56 * {@inheritDoc}
57 */
58 @Override
59 public DomText splitText(final int offset) {
60 if (offset < 0 || offset > getLength()) {
61 throw new IllegalArgumentException("offset: " + offset + " data.length: " + getLength());
62 }
63
64 // split text into two separate nodes
65 final DomText newText = createSplitTextNode(offset);
66 setData(getData().substring(0, offset));
67
68 // insert new text node
69 if (getParentNode() != null) {
70 getParentNode().insertBefore(newText, getNextSibling());
71 }
72 return newText;
73 }
74
75 /**
76 * Creates a new text node split from another text node. This method allows

Callers 3

splitTextMethod · 0.95
splitLastDomTextMethod · 0.95
splitTextMethod · 0.95

Calls 8

createSplitTextNodeMethod · 0.95
substringMethod · 0.80
getLengthMethod · 0.45
setDataMethod · 0.45
getDataMethod · 0.45
getParentNodeMethod · 0.45
insertBeforeMethod · 0.45
getNextSiblingMethod · 0.45

Tested by 2

splitTextMethod · 0.76
splitLastDomTextMethod · 0.76