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

UniformItemSection

public abstract class UniformItemSection extends Section
A section of a {@code .dex} file which consists of a sequence of {@link Item} objects. Each of the items must have the same size in the output.

Fields Summary
Constructors Summary
public UniformItemSection(String name, DexFile file, int alignment)
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
param
alignment {@code > 0;} alignment requirement for the final output; must be a power of 2

        super(name, file, alignment);
    
Methods Summary
public abstract IndexedItemget(com.android.dx.rop.cst.Constant cst)
Gets the item corresponding to the given {@link Constant}. This will throw an exception if the constant is not found, including if this instance isn't the sort that maps constants to {@link IndexedItem} instances.

param
cst {@code non-null;} constant to look for
return
{@code non-null;} the corresponding item found in this instance

public final intgetAbsoluteItemOffset(Item item)
{@inheritDoc}

        /*
         * Since all items must be the same size, we can use the size
         * of the one we're given to calculate its offset.
         */
        IndexedItem ii = (IndexedItem) item;
        int relativeOffset = ii.getIndex() * ii.writeSize();

        return getAbsoluteOffset(relativeOffset);
    
protected abstract voidorderItems()
Alters or picks the order for items in this instance if desired, so that subsequent calls to {@link #items} will yield a so-ordered collection. If the items in this instance are indexed, then this method should also assign indices.

protected final voidprepare0()
{@inheritDoc}

        DexFile file = getFile();

        orderItems();

        for (Item one : items()) {
            one.addContents(file);
        }
    
public final intwriteSize()
{@inheritDoc}

        Collection<? extends Item> items = items();
        int sz = items.size();

        if (sz == 0) {
            return 0;
        }

        // Since each item has to be the same size, we can pick any.
        return sz * items.iterator().next().writeSize();
    
protected final voidwriteTo0(com.android.dx.util.AnnotatedOutput out)
{@inheritDoc}

        DexFile file = getFile();
        int alignment = getAlignment();

        for (Item one : items()) {
            one.writeTo(file, out);
            out.alignTo(alignment);
        }