*
* @param container
* @return true if healthy, false otherwise
*/
public static boolean containerIsHealthyStrong(ContentElement container) {
ContentNode firstChild = container.getFirstChild();
Line line = Line.getFirstLineOfContainer(container);
if (line == null) {
errorLogAndThrow("Empty container - must have at least one child");
if (firstChild != null) {
return false;
} else {
return true;
}
}
if (line.previous() != null) {
errorLogAndThrow("First line must have no previous sibling");
return false;
}
if (!isLineElement(firstChild)) {
errorLogAndThrow("First child not a line element");
return false;
}
ContentElement element = firstChild.asElement();
boolean first = true;
while (true) {
if (line.getParagraph().getPreviousSibling() != line.getLineElement()) {
errorLogAndThrow("Junk between line token and its paragraph");
return false;
}
ContentNode node;
for (node = line.getParagraph().getFirstChild(); node != null; node = node.getNextSibling()) {
ContentElement e = node.asElement();
if (e != null) {
if (isLineElement(e)) {
errorLogAndThrow("Line element stuck inside rendering paragraph: " + e);
return false;
}
}
}
node = line.getParagraph().getNextSibling();
if (node == null) {
if (line.next() != null) {
errorLogAndThrow("Supposed to have another line, but no more nodes");
return false;
} else {
return true;
}
}
if (line.getParagraph().getImplNodelet() != null) {
// Only check this when rendered.
if (line.getParagraph().getImplNodelet().getNextSibling() !=
line.next().getParagraph().getImplNodelet()) {
errorLogAndThrow("Junk in html between paragraph nodelets");
return false;
}
}
if (!isLineElement(node)) {
errorLogAndThrow("Junk after rendering paragraph "
+ line.getParagraph() + ", junk: " + node);
return false;
}
element = node.asElement();
Line nextLine = Line.fromLineElement(element);
if (line.next() != nextLine) {
errorLogAndThrow("Next line doesn't correspond to next line element");
return false;
}