}
// There's only one possibility to test - so quit after this.
pointBias = 50;
boundaryPoint = point;
} else {
Node nodeBefore, nodeAfter, parent;
if (point.isInTextNode()) {
if (point.getTextOffset() == 0) {
nodeAfter = point.getContainer();
nodeBefore = doc.getPreviousSibling(nodeAfter);
} else {
nodeBefore = point.getContainer();
nodeAfter = doc.getNextSibling(nodeBefore);
}
parent = point.getContainer().getParentElement();
} else {
nodeAfter = point.getNodeAfter();
parent = point.getContainer();
if (nodeAfter == null) {
nodeBefore = point.getContainer().getLastChild();
} else {
nodeBefore = nodeAfter.getPreviousSibling();
}
}
Text textNodeBefore = doc.asText(nodeBefore);
Text textNodeAfter = doc.asText(nodeAfter);
switch (pointBias) {
case 0:
if (textNodeBefore != null) {
boundaryPoint = Point.<Node>inText(textNodeBefore, textNodeBefore.getLength());
}
break;
case 1:
if (textNodeAfter != null) {
boundaryPoint = Point.<Node>inText(textNodeAfter, 0);
}
break;
case 2:
boundaryPoint = Point.inElement(parent, nodeAfter);
break;
}
}
if (boundaryPoint != null) {
if (returnNextNode) {
Node n = DocHelper.ensureNodeBoundaryReturnNextNode(boundaryPoint, doc, doc);
if (nextNodeLocation >= 0) {
assertEquals(nextNodeLocation, doc.getLocation(n));
} else {
assertNull(n);
}