FileDocCategorySizeDatePackage
MemberIdsSection.javaAPI DocAndroid 5.1 API3056Thu Mar 12 22:18:30 GMT 2015com.android.dx.dex.file

MemberIdsSection

public abstract class MemberIdsSection extends UniformItemSection
Member (field or method) refs list section of a {@code .dex} file.

Fields Summary
Constructors Summary
public MemberIdsSection(String name, DexFile file)
Constructs an instance. The file offset is initially unknown.

param
name {@code null-ok;} the name of this instance, for annotation purposes
param
file {@code non-null;} file that this instance is part of

        super(name, file, 4);
    
Methods Summary
private java.lang.StringgetTooManyMembersMessage()

        Map<String, AtomicInteger> membersByPackage = new TreeMap<String, AtomicInteger>();
        for (Object member : items()) {
            String packageName = ((MemberIdItem) member).getDefiningClass().getPackageName();
            AtomicInteger count = membersByPackage.get(packageName);
            if (count == null) {
                count = new AtomicInteger();
                membersByPackage.put(packageName, count);
            }
            count.incrementAndGet();
        }

        Formatter formatter = new Formatter();
        try {
            String memberType = this instanceof MethodIdsSection ? "method" : "field";
            formatter.format("Too many %s references: %d; max is %d.%n" +
                    Main.getTooManyIdsErrorMessage() + "%n" +
                    "References by package:",
                    memberType, items().size(), DexFormat.MAX_MEMBER_IDX + 1);
            for (Map.Entry<String, AtomicInteger> entry : membersByPackage.entrySet()) {
                formatter.format("%n%6d %s", entry.getValue().get(), entry.getKey());
            }
            return formatter.toString();
        } finally {
            formatter.close();
        }
    
protected voidorderItems()
{@inheritDoc}

        int idx = 0;

        if (items().size() > DexFormat.MAX_MEMBER_IDX + 1) {
            throw new DexIndexOverflowException(getTooManyMembersMessage());
        }

        for (Object i : items()) {
            ((MemberIdItem) i).setIndex(idx);
            idx++;
        }