Representation of a text node in the HTML DOM. @author David K. Taylor @author Christian Sell @author Rodney Gitzel @author Ahmed Ashour @author Sudhan Moghe @author Philip Graf @author Ronald Brill
| 35 | * @author Ronald Brill |
| 36 | */ |
| 37 | public class DomText extends DomCharacterData implements Text { |
| 38 | |
| 39 | private SelectionDelegate selectionDelegate_; |
| 40 | private DoTypeProcessor doTypeProcessor_; |
| 41 | |
| 42 | /** The symbolic node name. */ |
| 43 | public static final String NODE_NAME = "#text"; |
| 44 | |
| 45 | /** |
| 46 | * Creates an instance of DomText. |
| 47 | * |
| 48 | * @param page the Page that contains this element |
| 49 | * @param data the string data held by this node |
| 50 | */ |
| 51 | public DomText(final SgmlPage page, final String data) { |
| 52 | super(page, data); |
| 53 | } |
| 54 | |
| 55 | /** |
| 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 |
| 77 | * the derived type of the new text node to match the original node type. |
| 78 | * |
| 79 | * @param offset the character position at which to split the DomText node |
| 80 | * @return the newly created Text node |
| 81 | */ |
| 82 | protected DomText createSplitTextNode(final int offset) { |
| 83 | return new DomText(getPage(), getData().substring(offset)); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * {@inheritDoc} |
| 88 | * Not yet implemented. |
| 89 | */ |
| 90 | @Override |
| 91 | public boolean isElementContentWhitespace() { |
| 92 | throw new UnsupportedOperationException("DomText.isElementContentWhitespace is not yet implemented."); |
| 93 | } |
| 94 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…