FileDocCategorySizeDatePackage
Statistics.javaAPI DocAndroid 5.1 API5393Thu Mar 12 22:18:30 GMT 2015com.android.dexgen.dex.file

Statistics

public final class Statistics extends Object
Statistics about the contents of a file.

Fields Summary
private final HashMap
dataMap
{@code non-null;} data about each type of item
Constructors Summary
public Statistics()
Constructs an instance.

        dataMap = new HashMap<String, Data>(50);
    
Methods Summary
public voidadd(Item item)
Adds the given item to the statistics.

param
item {@code non-null;} the item to add

        String typeName = item.typeName();
        Data data = dataMap.get(typeName);

        if (data == null) {
            dataMap.put(typeName, new Data(item, typeName));
        } else {
            data.add(item);
        }
    
public voidaddAll(Section list)
Adds the given list of items to the statistics.

param
list {@code non-null;} the list of items to add

        Collection<? extends Item> items = list.items();
        for (Item item : items) {
            add(item);
        }
    
public java.lang.StringtoHuman()

        StringBuilder sb = new StringBuilder();

        sb.append("Statistics:\n");

        TreeMap<String, Data> sortedData = new TreeMap<String, Data>();

        for (Data data : dataMap.values()) {
            sortedData.put(data.name, data);
        }

        for (Data data : sortedData.values()) {
            sb.append(data.toHuman());
        }

        return sb.toString();
    
public final voidwriteAnnotation(com.android.dexgen.util.AnnotatedOutput out)
Writes the statistics as an annotation.

param
out {@code non-null;} where to write to

        if (dataMap.size() == 0) {
            return;
        }

        out.annotate(0, "\nstatistics:\n");

        TreeMap<String, Data> sortedData = new TreeMap<String, Data>();

        for (Data data : dataMap.values()) {
            sortedData.put(data.name, data);
        }

        for (Data data : sortedData.values()) {
            data.writeAnnotation(out);
        }