public void finish() {
   while (stack.size() > 0) {
     addMissingEndTag();
   }
   tableFixer.finish();
   tree.finish();
   built = true;
 }
 public void visitTag(HtmlDocument.Tag paramTag) {
   tableFixer.seeTag(paramTag);
   HTML.Element localElement = paramTag.getElement();
   if (localElement.isEmpty()) {
     tree.addSingularTag(paramTag);
     return;
   }
   if (paramTag.isSelfTerminating()) {
     tree.addStartTag(
         HtmlDocument.createTag(
             localElement,
             paramTag.getAttributes(),
             paramTag.getOriginalHtmlBeforeAttributes(),
             paramTag.getOriginalHtmlAfterAttributes()));
     paramTag = HtmlDocument.createEndTag(localElement);
     tableFixer.seeEndTag(paramTag);
     tree.addEndTag(paramTag);
     return;
   }
   tree.addStartTag(paramTag);
   push(localElement);
 }
 public void visitEndTag(HtmlDocument.EndTag paramEndTag) {
   HTML.Element localElement = paramEndTag.getElement();
   int i = findStartTag(localElement);
   if (i >= 0) {
     while (i < stack.size() - 1) {
       addMissingEndTag();
     }
     pop();
     tableFixer.seeEndTag(paramEndTag);
     tree.addEndTag(paramEndTag);
     return;
   }
   logger.finest("Ignoring end tag: " + localElement.getName());
 }
 public void visitText(HtmlDocument.Text paramText) {
   tableFixer.seeText(paramText);
   tree.addText(paramText);
 }
 private void addMissingEndTag() {
   HtmlDocument.EndTag localEndTag = HtmlDocument.createEndTag(pop());
   tableFixer.seeEndTag(localEndTag);
   tree.addEndTag(localEndTag);
 }