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

StringIdItem

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

Fields Summary
private final com.android.dx.rop.cst.CstString
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.dx.rop.cst.CstString 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.dx.rop.cst.CstStringgetValue()
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 SizeOf.STRING_ID_ITEM;
    
public voidwriteTo(DexFile file, com.android.dx.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);