FileDocCategorySizeDatePackage
EncodedArrayItem.javaAPI DocAndroid 1.5 API3802Wed May 06 22:41:02 BST 2009com.android.dx.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.dx.rop.cst.CstArray
array
non-null; the array to represent
private byte[]
encodedForm
null-ok; encoded form, ready for writing to a file; set during {@link #place0}
Constructors Summary
public EncodedArrayItem(com.android.dx.rop.cst.CstArray array)
Constructs an instance.

param
array 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.dx.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);
        }