Java Code Examples for com.gargoylesoftware.htmlunit.html.DomNodeList#getLength()
The following examples show how to use
com.gargoylesoftware.htmlunit.html.DomNodeList#getLength() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleRange.java From htmlunit with Apache License 2.0 | 6 votes |
private static void deleteBefore(final DomNode node, int offset) { if (isOffsetChars(node)) { String text = getText(node); if (offset > -1 && offset < text.length()) { text = text.substring(offset); } else { text = ""; } setText(node, text); } else { final DomNodeList<DomNode> children = node.getChildNodes(); for (int i = 0; i < offset && i < children.getLength(); i++) { final DomNode child = children.get(i); child.remove(); i--; offset--; } } }
Example 2
Source File: SimpleRange.java From htmlunit with Apache License 2.0 | 6 votes |
private static void deleteAfter(final DomNode node, final int offset) { if (isOffsetChars(node)) { String text = getText(node); if (offset > -1 && offset < text.length()) { text = text.substring(0, offset); setText(node, text); } } else { final DomNodeList<DomNode> children = node.getChildNodes(); for (int i = offset; i < children.getLength(); i++) { final DomNode child = children.get(i); child.remove(); i--; } } }
Example 3
Source File: SimpleRange.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
private static void deleteBefore(final DomNode node, int offset) { if (isOffsetChars(node)) { String text = getText(node); if (offset > -1 && offset < text.length()) { text = text.substring(offset); } else { text = ""; } setText(node, text); } else { final DomNodeList<DomNode> children = node.getChildNodes(); for (int i = 0; i < offset && i < children.getLength(); i++) { final DomNode child = children.get(i); child.remove(); i--; offset--; } } }
Example 4
Source File: SimpleRange.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
private static void deleteAfter(final DomNode node, final int offset) { if (isOffsetChars(node)) { String text = getText(node); if (offset > -1 && offset < text.length()) { text = text.substring(0, offset); setText(node, text); } } else { final DomNodeList<DomNode> children = node.getChildNodes(); for (int i = offset; i < children.getLength(); i++) { final DomNode child = children.get(i); child.remove(); i--; } } }
Example 5
Source File: SgmlPageTest.java From htmlunit with Apache License 2.0 | 5 votes |
private <E extends DomNode> void validateDomNodeList(final DomNodeList<E> nodes) { assertEquals(nodes.getLength(), nodes.size()); final Iterator<E> nodesIterator = nodes.iterator(); for (int i = 0; i < nodes.getLength(); i++) { assertEquals(nodes.item(i), nodes.get(i)); assertEquals(nodes.item(i), nodesIterator.next()); assertEquals(i, nodes.indexOf(nodes.item(i))); } assertEquals(false, nodesIterator.hasNext()); final ListIterator<E> nodesListIterator = nodes.listIterator(); assertEquals(nodes.item(0), nodesListIterator.next()); assertEquals(nodes.item(1), nodesListIterator.next()); assertEquals(nodes.item(1), nodesListIterator.previous()); }