/** * Returns a <code>StringDataItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> * @param dexFile The <code>DexFile</code> that this item belongs to * @param value The string value that this item represents * @return a <code>StringDataItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static StringDataItem internStringDataItem(DexFile dexFile, String value) { StringDataItem StringDataItem = new StringDataItem(dexFile, value); return dexFile.StringDataSection.intern(StringDataItem); }
@Override public int hashCode() { //there's a small possibility that the actual hash code will be 0. If so, we'll //just end up recalculating it each time if (hashCode == 0) calcHashCode(); return hashCode; }
/** {@inheritDoc} */ protected void writeItem(AnnotatedOutput out) { if (out.annotates()) { out.annotate(4, stringDataItem.getConciseIdentity()); } out.writeInt(stringDataItem.getOffset()); }
/** * Get the <code>String</code> value that this <code>StringIdItem</code> represents * @return the <code>String</code> value that this <code>StringIdItem</code> represents */ public String getStringValue() { return stringDataItem.getStringValue(); }
@Override public int hashCode() { return stringDataItem.hashCode(); }
/** * Returns a <code>StringIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> * @param dexFile The <code>DexFile</code> that this item will belong to * @param stringValue The string value that this item represents * @return a <code>StringIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static StringIdItem internStringIdItem(DexFile dexFile, String stringValue) { StringDataItem stringDataItem = StringDataItem.internStringDataItem(dexFile, stringValue); if (stringDataItem == null) { return null; } StringIdItem stringIdItem = new StringIdItem(dexFile, stringDataItem); return dexFile.StringIdsSection.intern(stringIdItem); }
/** * Looks up the <code>StringIdItem</code> from the given <code>DexFile</code> for the given * string value * @param dexFile the <code>Dexfile</code> to find the string value in * @param stringValue The string value to look up * @return a <code>StringIdItem</code> from the given <code>DexFile</code> for the given * string value, or null if it doesn't exist */ public static StringIdItem lookupStringIdItem(DexFile dexFile, String stringValue) { StringDataItem stringDataItem = StringDataItem.lookupStringDataItem(dexFile, stringValue); if (stringDataItem == null) { return null; } StringIdItem stringIdItem = new StringIdItem(dexFile, stringDataItem); return dexFile.StringIdsSection.getInternedItem(stringIdItem); }
/** {@inheritDoc} */ public int compareTo(StringDataItem o) { return getStringValue().compareTo(o.getStringValue()); }
@Override public int hashCode() { return stringDataItem.hashCode(); }
/** * Returns a <code>StringIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> * @param dexFile The <code>DexFile</code> that this item will belong to * @param stringValue The string value that this item represents * @return a <code>StringIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static StringIdItem internStringIdItem(DexFile dexFile, String stringValue) { StringDataItem stringDataItem = StringDataItem.internStringDataItem(dexFile, stringValue); if (stringDataItem == null) { return null; } StringIdItem stringIdItem = new StringIdItem(dexFile, stringDataItem); return dexFile.StringIdsSection.intern(stringIdItem); }
/** * Looks up the <code>StringIdItem</code> from the given <code>DexFile</code> for the given * string value * @param dexFile the <code>Dexfile</code> to find the string value in * @param stringValue The string value to look up * @return a <code>StringIdItem</code> from the given <code>DexFile</code> for the given * string value, or null if it doesn't exist */ public static StringIdItem lookupStringIdItem(DexFile dexFile, String stringValue) { StringDataItem stringDataItem = StringDataItem.lookupStringDataItem(dexFile, stringValue); if (stringDataItem == null) { return null; } StringIdItem stringIdItem = new StringIdItem(dexFile, stringDataItem); return dexFile.StringIdsSection.getInternedItem(stringIdItem); }
/** * calculate and cache the hashcode */ private void calcHashCode() { hashCode = getStringValue().hashCode(); }
/** {@inheritDoc} */ protected void writeItem(AnnotatedOutput out) { if (out.annotates()) { out.annotate(4, stringDataItem.getConciseIdentity()); } out.writeInt(stringDataItem.getOffset()); }
/** * Looks up the <code>StringDataItem</code> from the given <code>DexFile</code> for the given * string value * @param dexFile the <code>Dexfile</code> to find the string value in * @param value The string value to look up * @return a <code>StringDataItem</code> from the given <code>DexFile</code> for the given * string value, or null if it doesn't exist **/ public static StringDataItem lookupStringDataItem(DexFile dexFile, String value) { StringDataItem StringDataItem = new StringDataItem(dexFile, value); return dexFile.StringDataSection.getInternedItem(StringDataItem); }
@Override public int hashCode() { //there's a small possibility that the actual hash code will be 0. If so, we'll //just end up recalculating it each time if (hashCode == 0) calcHashCode(); return hashCode; }
@Override public boolean equals(Object o) { if (this==o) { return true; } if (o==null || !this.getClass().equals(o.getClass())) { return false; } //This assumes that the referenced items have been interned in both objects. //This is a valid assumption because all outside code must use the static //"getInterned..." style methods to make new items, and any item created //internally is guaranteed to be interned StringDataItem other = (StringDataItem)o; return getStringValue().equals(other.getStringValue()); } }
return new CodeItem(dexFile); case TYPE_STRING_DATA_ITEM: return new StringDataItem(dexFile); case TYPE_DEBUG_INFO_ITEM: return new DebugInfoItem(dexFile);
/** {@inheritDoc} */ public String getConciseIdentity() { return "string_data_item: \"" + Utf8Utils.escapeString(getStringValue()) + "\""; }
/** * Looks up the <code>StringDataItem</code> from the given <code>DexFile</code> for the given * string value * @param dexFile the <code>Dexfile</code> to find the string value in * @param value The string value to look up * @return a <code>StringDataItem</code> from the given <code>DexFile</code> for the given * string value, or null if it doesn't exist **/ public static StringDataItem lookupStringDataItem(DexFile dexFile, String value) { StringDataItem StringDataItem = new StringDataItem(dexFile, value); return dexFile.StringDataSection.getInternedItem(StringDataItem); }
/** * Get the <code>String</code> value that this <code>StringIdItem</code> represents * @return the <code>String</code> value that this <code>StringIdItem</code> represents */ public String getStringValue() { return stringDataItem.getStringValue(); }