/** * write out the header of the report's content * * @param bw the writer to use * @throws IOException if an error occurs */ protected void writeHtmlBodyHeader(BufferedWriter bw) throws IOException { bw.write("<body>" + Dump.newLine()); bw.write(Dump.newLine()); bw.write("<h1>" + NAME + "</h1>" + Dump.newLine()); bw.write("<a href=\"../index.html\">Main</a>" + Dump.newLine()); bw.write("<p>" + Dump.newLine()); }
/** * write out the report's content * * @param bw the writer to use * @throws IOException if an error occurs */ protected void writeHtmlBodyContent(BufferedWriter bw) throws IOException { bw.write("<table>" + Dump.newLine()); bw.write(" <tr>" + Dump.newLine()); bw.write(" <th>Class</th>" + Dump.newLine()); bw.write(" <th>Depends On</th>" + Dump.newLine()); bw.write(" </tr>" + Dump.newLine()); SortedMap<String, SortedSet<String>> result = new TreeMap<String, SortedSet<String>>(); boolean odd = true; for (Archive archive : archives) { if (archive.getType() == ArchiveTypes.JAR) { SortedMap<String, SortedSet<String>> classDependencies = archive.getClassDependencies(); Iterator<Map.Entry<String, SortedSet<String>>> dit = classDependencies.entrySet().iterator(); while (dit.hasNext()) { Map.Entry<String, SortedSet<String>> entry = dit.next(); String clz = entry.getKey(); SortedSet<String> deps = entry.getValue(); SortedSet<String> newDeps = new TreeSet<String>(); for (String dep : deps) { if (!dep.equals(clz)) { newDeps.add(dep); } } result.put(clz, newDeps); } } } Iterator<Map.Entry<String, SortedSet<String>>> rit = result.entrySet().iterator(); while (rit.hasNext()) { Map.Entry<String, SortedSet<String>> entry = rit.next(); String clz = entry.getKey(); SortedSet<String> deps = entry.getValue(); if (odd) { bw.write(" <tr class=\"rowodd\">" + Dump.newLine()); } else { bw.write(" <tr class=\"roweven\">" + Dump.newLine()); } bw.write(" <td>" + clz + "</a></td>" + Dump.newLine()); bw.write(" <td>"); Iterator<String> sit = deps.iterator(); while (sit.hasNext()) { String dep = sit.next(); bw.write(dep); if (sit.hasNext()) { bw.write(", "); } } bw.write("</td>" + Dump.newLine()); bw.write(" </tr>" + Dump.newLine()); odd = !odd; } bw.write("</table>" + Dump.newLine()); }