Program: 52456
Project: 52456
Buggy source:
/** 
 * Translate the given HTML fragment into a DRI document. The translation is broken up into two steps, 1) recurse through all elements and either translate them into their DRI equivelents or remove them from the document. The second step, 2) is to iterate over all top level elements and ensure that they only consist of paragraphs. Also at this stage if linkBreaks is true then \n are treated as paragraph breaks.
 * @param parent The Element to translate into DRI.
 */
private void translate(Element parent){
  for (int i=0; i < parent.getContentSize(); i++) {
    Content decedent=parent.getContent(i);
    if (decedent instanceof org.jdom.Text) {
    }
 else     if (decedent instanceof Element) {
      Element element=(Element)decedent;
      String name=element.getName();
      if ("String_Node_Str".equals(name)) {
        if (parent.isRootElement()) {
          moveAttribute(element,"String_Node_Str","String_Node_Str");
          limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
          translate(element);
        }
 else {
          removeContent(element);
        }
      }
 else       if ("String_Node_Str".equals(name) || "String_Node_Str".equals(name) || "String_Node_Str".equals(name)|| "String_Node_Str".equals(name)|| "String_Node_Str".equals(name)) {
        if (parent.isRootElement()) {
          limitAttributes(element);
          element.setName("String_Node_Str");
          element.setAttribute("String_Node_Str","String_Node_Str");
          translate(element);
        }
 else {
          removeContent(element);
        }
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str");
        element.setName("String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
        element.setName("String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element);
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element);
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element);
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str");
        element.setName("String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element,"String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element,"String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
        translate(element);
      }
 else {
        removeContent(decedent);
      }
    }
 else {
      removeContent(decedent);
    }
  }
  if (parent.isRootElement()) {
    List<Content> removed=new ArrayList<Content>();
    for (int i=0; i < parent.getContentSize(); i++) {
      Content current=parent.getContent(i);
      if ((current instanceof Element) && ("String_Node_Str".equals(((Element)current).getName()))) {
        if (paragraphWrap(parent,i,removed)) {
          removed.clear();
          i++;
        }
      }
 else {
        if (this.blankLines && current instanceof Text) {
          String rawText=((Text)current).getText();
          @SuppressWarnings("String_Node_Str") List<String> parts=new ArrayList(Arrays.asList(rawText.split("String_Node_Str")));
          if (parts.size() > 0) {
            Collections.reverse(parts);
            String lastPart=parts.remove(0);
            for (            String part : parts) {
              removed.add(new Text(part));
              if (paragraphWrap(parent,i,removed)) {
                removed.clear();
                i++;
              }
            }
            removed.add(new Text(lastPart));
            parent.removeContent(current);
            i--;
          }
        }
 else {
          removed.add(current);
          parent.removeContent(current);
          i--;
        }
      }
    }
    if (removed.size() > 0) {
      paragraphWrap(parent,-1,removed);
      removed.clear();
    }
  }
}

Fixed version (ground truth):
/** 
 * Translate the given HTML fragment into a DRI document. The translation is broken up into two steps, 1) recurse through all elements and either translate them into their DRI equivelents or remove them from the document. The second step, 2) is to iterate over all top level elements and ensure that they only consist of paragraphs. Also at this stage if linkBreaks is true then \n are treated as paragraph breaks.
 * @param parent The Element to translate into DRI.
 */
private void translate(Element parent){
  for (int i=0; i < parent.getContentSize(); i++) {
    Content decedent=parent.getContent(i);
    if (decedent instanceof org.jdom.Text) {
    }
 else     if (decedent instanceof Element) {
      Element element=(Element)decedent;
      String name=element.getName();
      if ("String_Node_Str".equals(name)) {
        if (parent.isRootElement()) {
          moveAttribute(element,"String_Node_Str","String_Node_Str");
          limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
          translate(element);
        }
 else {
          removeContent(element);
        }
      }
 else       if ("String_Node_Str".equals(name) || "String_Node_Str".equals(name) || "String_Node_Str".equals(name)|| "String_Node_Str".equals(name)|| "String_Node_Str".equals(name)) {
        if (parent.isRootElement()) {
          limitAttributes(element);
          element.setName("String_Node_Str");
          element.setAttribute("String_Node_Str","String_Node_Str");
          translate(element);
        }
 else {
          removeContent(element);
        }
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str");
        element.setName("String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
        element.setName("String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element);
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element);
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element);
        element.setName("String_Node_Str");
        element.setAttribute("String_Node_Str","String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        moveAttribute(element,"String_Node_Str","String_Node_Str");
        limitAttributes(element,"String_Node_Str");
        element.setName("String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element,"String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element,"String_Node_Str");
        translate(element);
      }
 else       if ("String_Node_Str".equals(name)) {
        limitAttributes(element,"String_Node_Str","String_Node_Str","String_Node_Str");
        translate(element);
      }
 else {
        removeContent(decedent);
      }
    }
 else {
      removeContent(decedent);
    }
  }
  if (parent.isRootElement()) {
    List<Content> removed=new ArrayList<Content>();
    for (int i=0; i < parent.getContentSize(); i++) {
      Content current=parent.getContent(i);
      if ((current instanceof Element) && ("String_Node_Str".equals(((Element)current).getName()))) {
        if (paragraphWrap(parent,i,removed)) {
          removed.clear();
          i++;
        }
      }
 else       if ((current instanceof Element) && ("String_Node_Str".equals(((Element)current).getName()))) {
        i++;
      }
 else {
        if (this.blankLines && current instanceof Text) {
          String rawText=((Text)current).getText();
          @SuppressWarnings("String_Node_Str") List<String> parts=new ArrayList(Arrays.asList(rawText.split("String_Node_Str")));
          if (parts.size() > 0) {
            Collections.reverse(parts);
            String lastPart=parts.remove(0);
            for (            String part : parts) {
              removed.add(new Text(part));
              if (paragraphWrap(parent,i,removed)) {
                removed.clear();
                i++;
              }
            }
            removed.add(new Text(lastPart));
            parent.removeContent(current);
            i--;
          }
        }
 else {
          removed.add(current);
          parent.removeContent(current);
          i--;
        }
      }
    }
    if (removed.size() > 0) {
      paragraphWrap(parent,-1,removed);
      removed.clear();
    }
  }
}