Ejemplo n.º 1
0
  private void viewRawIndexFile() {
    Object object = getSelectedFromMainTree();
    if (object == null) {
      return;
    }
    if (!(object instanceof StackAnalyzedInfo)) {
      return;
    }
    StackAnalyzedInfo analyzedInfo = (StackAnalyzedInfo) object;
    if (analyzedInfo.getExtension().equals(StackParser.UNIQUE_EXT)) {
      return;
    }

    StackFileInfo stackFileInfo = analyzedInfo.getStackFileInfo();

    System.out.println("StackFile:" + stackFileInfo.toString());
    System.out.println("File:" + analyzedInfo.toString());

    String analyzedFilename =
        StackParser.getAnaylzedFilename(stackFileInfo.getFilename(), analyzedInfo.getExtension());
    File file = new File(analyzedFilename);
    if (!file.isFile()) return;

    BufferedReader reader = null;
    boolean isDetail = false;
    boolean isStart = false;
    try {
      reader = new BufferedReader(new FileReader(file));

      String line = null;
      int totalCount = 0;
      HashMap<String, Integer> map = new HashMap<String, Integer>();
      while ((line = reader.readLine()) != null) {
        line = line.trim();
        if (line.length() > 0) {
          isStart = true;
        }
        if (line.length() == 0) {
          if (isStart) {
            isDetail = true;
          }
          continue;
        }
        if (isDetail) {
          totalCount++;
          HtmlUtils.caculCounter(line, map);
        }
      }

      ArrayList<ValueObject> list = HtmlUtils.sortCounter(map);

      StringBuilder buffer = new StringBuilder(102400);
      buffer.append(HtmlUtils.getMainBodyStart());
      buffer.append(HtmlUtils.getCurrentConfigurationBody()).append("<br><br>");
      buffer.append("<b>[ ").append(stackFileInfo.getFilename()).append(" ]</b><BR>");
      buffer
          .append("<b>")
          .append(analyzedInfo.toString())
          .append(" - ")
          .append(analyzedFilename)
          .append("</b><br><br>");

      buffer.append(
          "<table border='1'><tr align='center'><th>Count</th><th>Percent</th><th>Class.method</th></tr>");
      int value;
      for (ValueObject valueObject : list) {
        value = valueObject.getValue();
        buffer
            .append("<tr><td align='right'>")
            .append(value)
            .append("</td><td align='right'>")
            .append((int) ((100 * value) / totalCount))
            .append('%')
            .append("</td>");
        buffer.append("<td align='left'>").append(valueObject.getKey()).append("</td></tr>");
      }
      buffer.append("</table>");
      buffer.append(HtmlUtils.getMainBodyEnd());

      displayContent(buffer.toString());
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    } finally {
      try {
        if (reader != null) reader.close();
      } catch (Exception ex) {
      }
    }
  }