All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.spyhunter99.dex.writers.FormattedHtml Maven / Gradle / Ivy

package com.github.spyhunter99.dex.writers;

import com.github.spyhunter99.dex.model.CountData;
import com.github.spyhunter99.dex.model.Metric;
import com.github.spyhunter99.dex.model.Node;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * creates a standalone, self contained .html report contents
 * Created by alex on 10/6/16.
 */
public class FormattedHtml implements IWriter {
    @Override
    public String getReport(CountData data) {
        List r = new ArrayList();
        r.add(data);
        return getReport(r);
    }

    public String getReport(List data) {
        StringBuilder sb = new StringBuilder();

        //table with covers counts for all data elements, followed up individual sections for each file analyzed with anchors
        sb.append("\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "
\n" + "

Field and Method Count (Dex Report)

\n" + "
Designed for use with dex-methods-count plugin.
\n" + "
\n" + "

Summary

\n"); //summary table sb.append( "\n" + "\n" + "\n" + "\n"); //foreach file summary for (int i = 0; i < data.size(); i++) { CountData countData = data.get(i); sb.append( "\n" + "" + "\n" + "\n"); } //end of summary table sb.append( "
FileFieldsMethods
" + countData.fileName + "" + countData.overallMetrics.fieldCount + "" + countData.overallMetrics.methodCount + "
\n" + "
\n"); for (int i = 0; i < data.size(); i++) { CountData countData = data.get(i); Node ptr = countData.packageTree; //foreach file sb.append( "" + "

" + countData.fileName + " - Package Details

\n" + "\n" + "\n" + "\n"); Iterator> iterator = ptr.children.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry next = iterator.next(); printFlat(next.getValue(), next.getKey(), sb); } sb.append("\n"); sb.append( "
PackageFieldsMethods
\n" + "Back to top\n" + "
\n"); } sb.append("\n" + "\n" + "\n"); return sb.toString(); } private void printFlat(Node ptr, String parentPackage, StringBuilder sb) { if (ptr != null) { Metric count = ptr.count; sb.append(""); if ("".equals(parentPackage)) sb.append("(default)"); else sb.append(parentPackage); sb.append("").append(count.fieldCount).append("").append(count.methodCount).append(""); Iterator> iterator = ptr.children.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry next = iterator.next(); if ("".equals(parentPackage)) { printFlat(next.getValue(), next.getKey(), sb); } else { printFlat(next.getValue(), parentPackage + "." + next.getKey(), sb); } } } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy