private void computeCoverages(
      String packageFilter,
      List<Map.Entry<String, ClassCoverage>> clsEntries,
      Coverage cls,
      Coverage mth,
      Coverage branch,
      Coverage block,
      Coverage line,
      Coverage insn) {
    for (Map.Entry<String, ClassCoverage> e : clsEntries) {
      if (e.getKey().startsWith(packageFilter)) {
        ClassCoverage cc = e.getValue();

        if (cc.isInterface()) {
          continue; // no code
        }

        cls.total++;

        if (cc.covered) {
          cls.covered++;
        }

        insn.add(cc.getCoveredInsn());
        line.add(cc.getCoveredLines());
        block.add(cc.getCoveredBasicBlocks());
        branch.add(cc.getCoveredBranches());
        mth.add(cc.getCoveredMethods());
      }
    }
  }
    void printClassCoverages() {
      Coverage clsCoverage = new Coverage(0, 0);
      Coverage mthCoverage = new Coverage(0, 0);
      Coverage bbCoverage = new Coverage(0, 0);
      Coverage lineCoverage = new Coverage(0, 0);
      Coverage insnCoverage = new Coverage(0, 0);
      Coverage branchCoverage = new Coverage(0, 0);
      String lastClass = "";
      BitSet executable;
      BitSet covered;

      computeCoverages(
          "",
          clsEntries,
          clsCoverage,
          mthCoverage,
          branchCoverage,
          bbCoverage,
          lineCoverage,
          insnCoverage);

      pw.println("      <p><b>Coverage</b></p>");

      pw.println("      <style type=\"text/css\">");
      pw.println("         tr.treeNodeOpened { font-weight: bold; background-color: #A0D0FF; }");
      pw.println("         tr.treeNodeClosed { font-weight: bold; background-color: #A0D0FF; }");
      pw.println("         td                { border: 1px solid #808080; padding: 0px 5px; }");
      pw.println("         th                { border: 1px solid #000000; padding: 5px 5px; }");
      pw.println("         td.firstCol       { border-top-style: hidden; }");
      pw.println("         td.covered        { text-align: right; }");
      pw.println(
          "         td.slash          { text-align: center; border-left: hidden; border-right: hidden; }");
      pw.println("         td.total          { text-align: right; padding-right: 10px; }");
      pw.println("      </style>");

      HTMLPublisher.writeTableTreeBegin(pw);

      // Write header rows
      pw.println("         <thead>");
      pw.println("            <tr>");
      pw.println(
          "               <th rowspan=\"2\" valign=\"bottom\">Package / Class / Method</th>");
      pw.println("               <th colspan=\"24\">Coverage</th>");
      pw.println("            </tr>");
      pw.println("            <tr>");
      pw.println("               <th colspan=\"4\">Instructions</th>");
      pw.println("               <th colspan=\"4\">Lines</th>");
      pw.println("               <th colspan=\"4\">Basic Block</th>");
      pw.println("               <th colspan=\"4\">Branch</th>");
      pw.println("               <th colspan=\"4\">Methods</th>");
      pw.println("               <th colspan=\"4\">Classes</th>");
      pw.println("            </tr>");
      pw.println("         </thead>");
      pw.println("         <tbody>");

      // TODO - Make the Coverage portion of the table scrollable - Resize the Coverage portion of
      // the table when the frame resizes.

      // Write total row
      HTMLPublisher.writeTableTreeNodeBegin(pw, "cc", "style=\"background-color: #60A0FF\"");

      pw.println("            <td>All</td>");

      pw.print("            ");
      printCoverage(insnCoverage);

      pw.print("            ");
      printCoverage(lineCoverage);

      pw.print("            ");
      printCoverage(bbCoverage);

      pw.print("            ");
      printCoverage(branchCoverage);

      pw.print("            ");
      printCoverage(mthCoverage);

      pw.print("            ");
      printCoverage(clsCoverage);

      HTMLPublisher.writeTableTreeNodeEnd(pw);

      // Write Body
      for (Map.Entry<String, ClassCoverage> e : clsEntries) {
        ClassCoverage cc = e.getValue();
        Coverage cov;

        printPackageCoverages(lastClass, e.getKey());
        lastClass = e.getKey();

        HTMLPublisher.writeTableTreeNodeBegin(pw, "cc-" + lastClass.replace('.', '-'));
        pw.print("            <td class=\"firstCol\">");
        pw.print(lastClass.substring(lastClass.lastIndexOf('.') + 1));
        pw.println("</td>");

        pw.print("            ");

        printCoverage(cc.getCoveredInsn());
        printCoverage(cc.getCoveredLines());
        printCoverage(cc.getCoveredBasicBlocks());
        printCoverage(cc.getCoveredBranches());
        printCoverage(cc.getCoveredMethods());

        pw.println();
        HTMLPublisher.writeTableTreeNodeEnd(pw);

        if (showMethods) {

          executable = new BitSet();
          covered = new BitSet();
          if (cc.getCoveredLines(executable, covered)) {
            ((HTMLPublisher) publisher)
                .setSourceCoverage(cc.ci.getSourceFileName(), executable, covered);
          }

          printMethodCoverages(cc);
        }
      }

      pw.println("         </tbody>");
      HTMLPublisher.writeTableTreeEnd(pw);

      // Expand classes that have methods without 100% coverage.
      pw.println("      <script type=\"text/javascript\">");
      pw.println("         addEvent(window, \"load\", openClasses);");
      pw.println();
      pw.println("         function openClasses()");
      pw.println("         {");

      for (Map.Entry<String, ClassCoverage> e : clsEntries) {
        ClassCoverage cc = e.getValue();

        if (!cc.getCoveredInsn().isFullyCovered()) {
          pw.print("            treeNodeShowPath(\"");
          pw.print("cc-" + e.getKey().replace('.', '-'));
          pw.println("\");");
        }
      }

      pw.println("         }");
      pw.println("      </script>");
    }
    void printClassCoverages() {
      String space = "  ";
      Coverage clsCoverage = new Coverage(0, 0);
      Coverage mthCoverage = new Coverage(0, 0);
      Coverage bbCoverage = new Coverage(0, 0);
      Coverage lineCoverage = new Coverage(0, 0);
      Coverage insnCoverage = new Coverage(0, 0);
      Coverage branchCoverage = new Coverage(0, 0);

      computeCoverages(
          "",
          clsEntries,
          clsCoverage,
          mthCoverage,
          branchCoverage,
          bbCoverage,
          lineCoverage,
          insnCoverage);

      pw.println();
      pw.println(
          "-------------------------------------------- class coverage ------------------------------------------------");
      pw.println(
          "bytecode            line                basic-block         branch              methods             location");
      pw.println(
          "------------------------------------------------------------------------------------------------------------");

      // Write Body
      for (Map.Entry<String, ClassCoverage> e : clsEntries) {
        ClassCoverage cc = e.getValue();

        printCoverage(cc.getCoveredInsn());
        pw.print(space);

        printCoverage(cc.getCoveredLines());
        pw.print(space);

        printCoverage(cc.getCoveredBasicBlocks());
        pw.print(space);

        printCoverage(cc.getCoveredBranches());
        pw.print(space);

        printCoverage(cc.getCoveredMethods());
        pw.print(space);

        pw.println(e.getKey());

        if (showMethods) {
          printMethodCoverages(cc);
        }
      }

      pw.println();
      pw.println(
          "------------------------------------------------------------------------------------------------------------");

      printCoverage(insnCoverage);
      pw.print(space);
      printCoverage(lineCoverage);
      pw.print(space);
      printCoverage(bbCoverage);
      pw.print(space);
      printCoverage(branchCoverage);
      pw.print(space);
      printCoverage(mthCoverage);
      pw.print(space);
      printCoverage(clsCoverage);
      pw.println(" total");
    }