/** * To determine whether the position is at the edge of a node. TODO: temp func for later * combination * * @param nodePos * @param position * @param left * @return true if linked */ boolean isLinked(IDOMPosition nodePos, IDOMPosition position, boolean left) { int index = getIndexedRegionLocation(position); if (left) { int pos = getIndexedRegionLocation(nodePos); return pos == index; } Node node = null; int end; if (nodePos.isText()) { node = nodePos.getContainerNode(); end = ((IndexedRegion) node).getEndOffset(); } else { node = nodePos.getNextSiblingNode(); Assert.isTrue(node != null); end = ((IndexedRegion) node).getEndOffset(); } return end == index; }
/** * Get next sibling node to position's container node. * * @param position * @return the node */ Node getNextSibling(IDOMPosition position) { if (position.isText()) { return position.getContainerNode().getNextSibling(); } return position.getNextSiblingNode(); }