Exemplo n.º 1
1
  @Override
  public void writeXml2ResultFileBody(
      final File file, final List<Defect> allDefectList, final String sourceFileFullPath)
      throws IOException {
    int size = allDefectList.size() * 1024;
    StringBuilder m;
    if (size < Integer.MAX_VALUE) m = new StringBuilder(size);
    else m = new StringBuilder(Integer.MAX_VALUE);

    m.append("\t<error filename=\"").append(sourceFileFullPath).append("\">\n");

    for (Defect defect : allDefectList) {
      m.append("\t\t<defect checker=\"").append(defect.getCheckerCode()).append("\">\n");
      for (Occurence o : defect.getOccurences()) {
        m.append("\t\t\t<occurence startLine=\"")
            .append(o.getStartLine())
            .append("\" ")
            .append("endLine=\"")
            .append(o.getEndLine())
            .append("\" ")
            .append(" message=\"")
            .append(o.getMessage())
            .append("\" />\n");
      }
      m.append("\t\t</defect>\n");
    }

    m.append("\t</error>\n");

    m.trimToSize();
    Files.append(m.toString(), file, Charsets.UTF_8);
  }
Exemplo n.º 2
0
 @Override
 public void writeJsonResultFileBody(final File file, final List<Defect> allDefectList)
     throws IOException {
   for (Defect defect : allDefectList) {
     Files.append(defect.toJson(), file, Charsets.UTF_8);
     Files.append(",\n", file, Charsets.UTF_8);
   }
 }