/** * 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); }
private String[][] loadInstanceFields(ClassDataItem classDataItem) { EncodedField[] encodedFields = classDataItem.getInstanceFields(); if (encodedFields != null && encodedFields.length > 0) { String[][] instanceFields = new String[encodedFields.length][2]; for (int i=0; i<encodedFields.length; i++) { EncodedField encodedField = encodedFields[i]; instanceFields[i][0] = encodedField.field.getFieldName().getStringValue(); instanceFields[i][1] = encodedField.field.getFieldType().getTypeDescriptor(); } return instanceFields; } return null; } }
public DexFileClassMap(DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { definedClasses.put(classDefItem.getClassType().getTypeDescriptor(), classDefItem); } }
public int compare(AnnotationItem annotationItem, AnnotationItem annotationItem2) { int annotationItemIndex = annotationItem.getEncodedAnnotation().annotationType.getIndex(); int annotationItemIndex2 = annotationItem2.getEncodedAnnotation().annotationType.getIndex(); if (annotationItemIndex < annotationItemIndex2) { return -1; } else if (annotationItemIndex == annotationItemIndex2) { return 0; } return 1; } });
public int compare(ClassDefItem a, ClassDefItem b) { return a.getClassType().compareTo(b.getClassType()); } });
/** * Returns an <code>EncodedArrayItem</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 encodedArray The encoded array value * @return an <code>EncodedArrayItem</code> for the given values, and that has been interned into the given */ public static EncodedArrayItem internEncodedArrayItem(DexFile dexFile, ArrayEncodedSubValue encodedArray) { EncodedArrayItem encodedArrayItem = new EncodedArrayItem(dexFile, encodedArray); return dexFile.EncodedArraysSection.intern(encodedArrayItem); }
/** * 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); }
/** {@inheritDoc} */ public int compareTo(AnnotationDirectoryItem o) { if (!isInternable()) { if (!o.isInternable()) { return parent.compareTo(o.parent); } return -1; } if (!o.isInternable()) { return 1; } return classAnnotations.compareTo(o.classAnnotations); }
/** * Looks up the <code>ProtoIdItem</code> from the given <code>DexFile</code> for the given * values * @param dexFile the <code>Dexfile</code> to find the type in * @param returnType the return type * @param parameters a <code>TypeListItem</code> containing a list of the parameter types * @return a <code>ProtoIdItem</code> from the given <code>DexFile</code> for the given * values, or null if it doesn't exist */ public static ProtoIdItem lookupProtoIdItem(DexFile dexFile, TypeIdItem returnType, TypeListItem parameters) { ProtoIdItem protoIdItem = new ProtoIdItem(dexFile, returnType, parameters); return dexFile.ProtoIdsSection.getInternedItem(protoIdItem); }
/** * Returns a <code>TypeIdItem</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 typeDescriptor The <code>StringIdItem</code> containing the type descriptor that * this <code>TypeIdItem</code> represents * @return a <code>TypeIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static TypeIdItem internTypeIdItem(DexFile dexFile, StringIdItem typeDescriptor) { TypeIdItem typeIdItem = new TypeIdItem(dexFile, typeDescriptor); return dexFile.TypeIdsSection.intern(typeIdItem); }
/** * Returns a <code>ProtoIdItem</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 returnType the return type * @param parameters a <code>TypeListItem</code> containing a list of the parameter types * @return a <code>ProtoIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static ProtoIdItem internProtoIdItem(DexFile dexFile, TypeIdItem returnType, TypeListItem parameters) { ProtoIdItem protoIdItem = new ProtoIdItem(dexFile, returnType, parameters); return dexFile.ProtoIdsSection.intern(protoIdItem); }
private String[] loadVirtualMethods(ClassDataItem classDataItem) { EncodedMethod[] encodedMethods = classDataItem.getVirtualMethods(); if (encodedMethods != null && encodedMethods.length > 0) { String[] virtualMethods = new String[encodedMethods.length]; for (int i=0; i<encodedMethods.length; i++) { virtualMethods[i] = encodedMethods[i].method.getVirtualMethodString(); } return virtualMethods; } return null; }
@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; }
/** * calculate and cache the hashcode */ private void calcHashCode() { int hashCode = 1; for (TypeIdItem typeIdItem: typeList) { hashCode = 31 * hashCode + typeIdItem.hashCode(); } this.hashCode = hashCode; }