FileDocCategorySizeDatePackage
Statistics.javaAPI DocAndroid 1.5 API5299Wed May 06 22:41:02 BST 2009com.android.dx.dex.file

Statistics

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

Fields Summary
private final HashMap
dataMap
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 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 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.dx.util.AnnotatedOutput out)
Writes the statistics as an annotation.

param
out 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);
        }