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

EncodedArrayItem

public final class EncodedArrayItem extends OffsettedItem
Encoded array of constant values.

Fields Summary
private static final int
ALIGNMENT
the required alignment for instances of this class
private final com.android.dexgen.rop.cst.CstArray
array
{@code non-null;} the array to represent
private byte[]
encodedForm
{@code null-ok;} encoded form, ready for writing to a file; set during {@link #place0}
Constructors Summary
public EncodedArrayItem(com.android.dexgen.rop.cst.CstArray array)
Constructs an instance.

param
array {@code non-null;} array to represent


                   
       
        /*
         * The write size isn't known up-front because (the variable-lengthed)
         * leb128 type is used to represent some things.
         */
        super(ALIGNMENT, -1);

        if (array == null) {
            throw new NullPointerException("array == null");
        }

        this.array = array;
        this.encodedForm = null;
    
Methods Summary
public voidaddContents(DexFile file)
{@inheritDoc}

        ValueEncoder.addContents(file, array);
    
protected intcompareTo0(OffsettedItem other)
{@inheritDoc}

        EncodedArrayItem otherArray = (EncodedArrayItem) other;

        return array.compareTo(otherArray.array);
    
public inthashCode()
{@inheritDoc}

        return array.hashCode();
    
public ItemTypeitemType()
{@inheritDoc}

        return ItemType.TYPE_ENCODED_ARRAY_ITEM;
    
protected voidplace0(Section addedTo, int offset)
{@inheritDoc}

        // Encode the data and note the size.

        ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput();
        ValueEncoder encoder = new ValueEncoder(addedTo.getFile(), out);

        encoder.writeArray(array, false);
        encodedForm = out.toByteArray();
        setWriteSize(encodedForm.length);
    
public java.lang.StringtoHuman()
{@inheritDoc}

        return array.toHuman();
    
protected voidwriteTo0(DexFile file, com.android.dexgen.util.AnnotatedOutput out)
{@inheritDoc}

        boolean annotates = out.annotates();

        if (annotates) {
            out.annotate(0, offsetString() + " encoded array");

            /*
             * The output is to be annotated, so redo the work previously
             * done by place0(), except this time annotations will actually
             * get emitted.
             */
            ValueEncoder encoder = new ValueEncoder(file, out);
            encoder.writeArray(array, true);
        } else {
            out.write(encodedForm);
        }