Fields Summary |
---|
public static final int | WRITE_SIZEsize of instances when written out to a file, in bytes |
private final com.android.dx.rop.cst.CstType | thisClassnon-null; type constant for this class |
private final int | accessFlagsaccess flags |
private final com.android.dx.rop.cst.CstType | superclassnull-ok; superclass or null if this class is a/the
root class |
private TypeListItem | interfacesnull-ok; list of implemented interfaces |
private final com.android.dx.rop.cst.CstUtf8 | sourceFilenull-ok; source file name or null if unknown |
private final ClassDataItem | classDatanon-null; associated class data object |
private EncodedArrayItem | staticValuesItemnull-ok; item wrapper for the static values, initialized
in {@link #addContents} |
private AnnotationsDirectoryItem | annotationsDirectorynon-null; annotations directory |
Methods Summary |
---|
public void | addContents(DexFile file){@inheritDoc}
TypeIdsSection typeIds = file.getTypeIds();
MixedItemSection byteData = file.getByteData();
MixedItemSection wordData = file.getWordData();
MixedItemSection typeLists = file.getTypeLists();
StringIdsSection stringIds = file.getStringIds();
typeIds.intern(thisClass);
if (!classData.isEmpty()) {
MixedItemSection classDataSection = file.getClassData();
classDataSection.add(classData);
CstArray staticValues = classData.getStaticValuesConstant();
if (staticValues != null) {
staticValuesItem =
byteData.intern(new EncodedArrayItem(staticValues));
}
}
if (superclass != null) {
typeIds.intern(superclass);
}
if (interfaces != null) {
interfaces = typeLists.intern(interfaces);
}
if (sourceFile != null) {
stringIds.intern(sourceFile);
}
if (! annotationsDirectory.isEmpty()) {
if (annotationsDirectory.isInternable()) {
annotationsDirectory = wordData.intern(annotationsDirectory);
} else {
wordData.add(annotationsDirectory);
}
}
|
public void | addDirectMethod(EncodedMethod method)Adds a direct (static and/or private ) method.
classData.addDirectMethod(method);
|
public void | addFieldAnnotations(com.android.dx.rop.cst.CstFieldRef field, com.android.dx.rop.annotation.Annotations annotations)Adds a field annotations item to this class.
annotationsDirectory.addFieldAnnotations(field, annotations);
|
public void | addInstanceField(EncodedField field)Adds an instance field.
classData.addInstanceField(field);
|
public void | addMethodAnnotations(com.android.dx.rop.cst.CstMethodRef method, com.android.dx.rop.annotation.Annotations annotations)Adds a method annotations item to this class.
annotationsDirectory.addMethodAnnotations(method, annotations);
|
public void | addParameterAnnotations(com.android.dx.rop.cst.CstMethodRef method, com.android.dx.rop.annotation.AnnotationsList list)Adds a parameter annotations item to this class.
annotationsDirectory.addParameterAnnotations(method, list);
|
public void | addStaticField(EncodedField field, com.android.dx.rop.cst.Constant value)Adds a static field.
classData.addStaticField(field, value);
|
public void | addVirtualMethod(EncodedMethod method)Adds a virtual method.
classData.addVirtualMethod(method);
|
public void | debugPrint(java.io.Writer out, boolean verbose)Prints out the contents of this instance, in a debugging-friendly
way.
PrintWriter pw = Writers.printWriterFor(out);
pw.println(getClass().getName() + " {");
pw.println(" accessFlags: " + Hex.u2(accessFlags));
pw.println(" superclass: " + superclass);
pw.println(" interfaces: " +
((interfaces == null) ? "<none>" : interfaces));
pw.println(" sourceFile: " +
((sourceFile == null) ? "<none>" : sourceFile.toQuoted()));
classData.debugPrint(out, verbose);
annotationsDirectory.debugPrint(pw);
pw.println("}");
|
public int | getAccessFlags()Gets the access flags.
return accessFlags;
|
public com.android.dx.rop.type.TypeList | getInterfaces()Gets the list of interfaces implemented.
if (interfaces == null) {
return StdTypeList.EMPTY;
}
return interfaces.getList();
|
public com.android.dx.rop.annotation.Annotations | getMethodAnnotations(com.android.dx.rop.cst.CstMethodRef method)Gets the method annotations for a given method, if any. This is
meant for use by debugging / dumping code.
return annotationsDirectory.getMethodAnnotations(method);
|
public java.util.ArrayList | getMethods()Gets all the methods in this class. The returned list is not linked
in any way to the underlying lists contained in this instance, but
the objects contained in the list are shared.
return classData.getMethods();
|
public com.android.dx.rop.annotation.AnnotationsList | getParameterAnnotations(com.android.dx.rop.cst.CstMethodRef method)Gets the parameter annotations for a given method, if any. This is
meant for use by debugging / dumping code.
return annotationsDirectory.getParameterAnnotations(method);
|
public com.android.dx.rop.cst.CstUtf8 | getSourceFile()Gets the source file name.
return sourceFile;
|
public com.android.dx.rop.cst.CstType | getSuperclass()Gets the superclass.
return superclass;
|
public com.android.dx.rop.cst.CstType | getThisClass()Gets the constant corresponding to this class.
return thisClass;
|
public ItemType | itemType(){@inheritDoc}
return ItemType.TYPE_CLASS_DEF_ITEM;
|
public void | setClassAnnotations(com.android.dx.rop.annotation.Annotations annotations)Sets the direct annotations on this class. These are annotations
made on the class, per se, as opposed to on one of its members.
It is only valid to call this method at most once per instance.
annotationsDirectory.setClassAnnotations(annotations);
|
public int | writeSize(){@inheritDoc}
return WRITE_SIZE;
|
public void | writeTo(DexFile file, com.android.dx.util.AnnotatedOutput out){@inheritDoc}
boolean annotates = out.annotates();
TypeIdsSection typeIds = file.getTypeIds();
int classIdx = typeIds.indexOf(thisClass);
int superIdx = (superclass == null) ? -1 :
typeIds.indexOf(superclass);
int interOff = OffsettedItem.getAbsoluteOffsetOr0(interfaces);
int annoOff = annotationsDirectory.isEmpty() ? 0 :
annotationsDirectory.getAbsoluteOffset();
int sourceFileIdx = (sourceFile == null) ? -1 :
file.getStringIds().indexOf(sourceFile);
int dataOff = classData.isEmpty()? 0 : classData.getAbsoluteOffset();
int staticValuesOff =
OffsettedItem.getAbsoluteOffsetOr0(staticValuesItem);
if (annotates) {
out.annotate(0, indexString() + ' " + thisClass.toHuman());
out.annotate(4, " class_idx: " + Hex.u4(classIdx));
out.annotate(4, " access_flags: " +
AccessFlags.classString(accessFlags));
out.annotate(4, " superclass_idx: " + Hex.u4(superIdx) +
" // " + ((superclass == null) ? "<none>" :
superclass.toHuman()));
out.annotate(4, " interfaces_off: " + Hex.u4(interOff));
if (interOff != 0) {
TypeList list = interfaces.getList();
int sz = list.size();
for (int i = 0; i < sz; i++) {
out.annotate(0, " " + list.getType(i).toHuman());
}
}
out.annotate(4, " source_file_idx: " + Hex.u4(sourceFileIdx) +
" // " + ((sourceFile == null) ? "<none>" :
sourceFile.toHuman()));
out.annotate(4, " annotations_off: " + Hex.u4(annoOff));
out.annotate(4, " class_data_off: " + Hex.u4(dataOff));
out.annotate(4, " static_values_off: " +
Hex.u4(staticValuesOff));
}
out.writeInt(classIdx);
out.writeInt(accessFlags);
out.writeInt(superIdx);
out.writeInt(interOff);
out.writeInt(sourceFileIdx);
out.writeInt(annoOff);
out.writeInt(dataOff);
out.writeInt(staticValuesOff);
|