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

StringIdItem

public final class StringIdItem extends IndexedItem implements Comparable
Representation of a string inside a Dalvik file.

Fields Summary
public static final int
WRITE_SIZE
size of instances when written out to a file, in bytes
private final com.android.dexgen.rop.cst.CstUtf8
value
{@code non-null;} the string value
private StringDataItem
data
{@code null-ok;} associated string data object, if known
Constructors Summary
public StringIdItem(com.android.dexgen.rop.cst.CstUtf8 value)
Constructs an instance.

param
value {@code non-null;} the string value


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

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

        if (data == null) {
            // The string data hasn't yet been added, so add it.
            MixedItemSection stringData = file.getStringData();
            data = new StringDataItem(value);
            stringData.add(data);
        }
    
public intcompareTo(java.lang.Object other)
{@inheritDoc}

        StringIdItem otherString = (StringIdItem) other;
        return value.compareTo(otherString.value);
    
public booleanequals(java.lang.Object other)
{@inheritDoc}

        if (!(other instanceof StringIdItem)) {
            return false;
        }

        StringIdItem otherString = (StringIdItem) other;
        return value.equals(otherString.value);
    
public StringDataItemgetData()
Gets the associated data object for this instance, if known.

return
{@code null-ok;} the associated data object or {@code null} if not yet known

        return data;
    
public com.android.dexgen.rop.cst.CstUtf8getValue()
Gets the string value.

return
{@code non-null;} the value

        return value;
    
public inthashCode()
{@inheritDoc}

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

        return ItemType.TYPE_STRING_ID_ITEM;
    
public intwriteSize()
{@inheritDoc}

        return WRITE_SIZE;
    
public voidwriteTo(DexFile file, com.android.dexgen.util.AnnotatedOutput out)
{@inheritDoc}

        int dataOff = data.getAbsoluteOffset();

        if (out.annotates()) {
            out.annotate(0, indexString() + ' " + value.toQuoted(100));
            out.annotate(4, "  string_data_off: " + Hex.u4(dataOff));
        }

        out.writeInt(dataOff);