Fields Summary |
---|
private static final int | ALIGNMENTthe required alignment for instances of this class |
private static final int | HEADER_SIZEwrite size of this class's header, in bytes |
private static final int | ELEMENT_SIZEwrite size of a list element, in bytes |
private AnnotationSetItem | classAnnotations{@code null-ok;} the class-level annotations, if any |
private ArrayList | fieldAnnotations{@code null-ok;} the annotated fields, if any |
private ArrayList | methodAnnotations{@code null-ok;} the annotated methods, if any |
private ArrayList | parameterAnnotations{@code null-ok;} the annotated parameters, if any |
Methods Summary |
---|
public void | addContents(DexFile file){@inheritDoc}
MixedItemSection wordData = file.getWordData();
if (classAnnotations != null) {
classAnnotations = wordData.intern(classAnnotations);
}
if (fieldAnnotations != null) {
for (FieldAnnotationStruct item : fieldAnnotations) {
item.addContents(file);
}
}
if (methodAnnotations != null) {
for (MethodAnnotationStruct item : methodAnnotations) {
item.addContents(file);
}
}
if (parameterAnnotations != null) {
for (ParameterAnnotationStruct item : parameterAnnotations) {
item.addContents(file);
}
}
|
public void | addFieldAnnotations(com.android.dx.rop.cst.CstFieldRef field, com.android.dx.rop.annotation.Annotations annotations, DexFile dexFile)Adds a field annotations item to this instance.
if (fieldAnnotations == null) {
fieldAnnotations = new ArrayList<FieldAnnotationStruct>();
}
fieldAnnotations.add(new FieldAnnotationStruct(field,
new AnnotationSetItem(annotations, dexFile)));
|
public void | addMethodAnnotations(com.android.dx.rop.cst.CstMethodRef method, com.android.dx.rop.annotation.Annotations annotations, DexFile dexFile)Adds a method annotations item to this instance.
if (methodAnnotations == null) {
methodAnnotations = new ArrayList<MethodAnnotationStruct>();
}
methodAnnotations.add(new MethodAnnotationStruct(method,
new AnnotationSetItem(annotations, dexFile)));
|
public void | addParameterAnnotations(com.android.dx.rop.cst.CstMethodRef method, com.android.dx.rop.annotation.AnnotationsList list, DexFile dexFile)Adds a parameter annotations item to this instance.
if (parameterAnnotations == null) {
parameterAnnotations = new ArrayList<ParameterAnnotationStruct>();
}
parameterAnnotations.add(new ParameterAnnotationStruct(method, list, dexFile));
|
public int | compareTo0(OffsettedItem other){@inheritDoc}
Note:: This throws an exception if this item is not
internable.
if (! isInternable()) {
throw new UnsupportedOperationException("uninternable instance");
}
AnnotationsDirectoryItem otherDirectory =
(AnnotationsDirectoryItem) other;
return classAnnotations.compareTo(otherDirectory.classAnnotations);
|
void | debugPrint(java.io.PrintWriter out)Prints out the contents of this instance, in a debugging-friendly
way. This is meant to be called from {@link ClassDefItem#debugPrint}.
if (classAnnotations != null) {
out.println(" class annotations: " + classAnnotations);
}
if (fieldAnnotations != null) {
out.println(" field annotations:");
for (FieldAnnotationStruct item : fieldAnnotations) {
out.println(" " + item.toHuman());
}
}
if (methodAnnotations != null) {
out.println(" method annotations:");
for (MethodAnnotationStruct item : methodAnnotations) {
out.println(" " + item.toHuman());
}
}
if (parameterAnnotations != null) {
out.println(" parameter annotations:");
for (ParameterAnnotationStruct item : parameterAnnotations) {
out.println(" " + item.toHuman());
}
}
|
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.
if (methodAnnotations == null) {
return null;
}
for (MethodAnnotationStruct item : methodAnnotations) {
if (item.getMethod().equals(method)) {
return item.getAnnotations();
}
}
return null;
|
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.
if (parameterAnnotations == null) {
return null;
}
for (ParameterAnnotationStruct item : parameterAnnotations) {
if (item.getMethod().equals(method)) {
return item.getAnnotationsList();
}
}
return null;
|
public int | hashCode(){@inheritDoc}
if (classAnnotations == null) {
return 0;
}
return classAnnotations.hashCode();
|
public boolean | isEmpty()Returns whether this item is empty (has no contents).
return (classAnnotations == null) &&
(fieldAnnotations == null) &&
(methodAnnotations == null) &&
(parameterAnnotations == null);
|
public boolean | isInternable()Returns whether this item is a candidate for interning. The only
interning candidates are ones that only have a non-null
set of class annotations, with no other lists.
return (classAnnotations != null) &&
(fieldAnnotations == null) &&
(methodAnnotations == null) &&
(parameterAnnotations == null);
|
public ItemType | itemType(){@inheritDoc}
return ItemType.TYPE_ANNOTATIONS_DIRECTORY_ITEM;
|
private static int | listSize(java.util.ArrayList list)Gets the list size of the given list, or {@code 0} if given
{@code null}.
if (list == null) {
return 0;
}
return list.size();
|
protected void | place0(Section addedTo, int offset){@inheritDoc}
// We just need to set the write size here.
int elementCount = listSize(fieldAnnotations)
+ listSize(methodAnnotations) + listSize(parameterAnnotations);
setWriteSize(HEADER_SIZE + (elementCount * ELEMENT_SIZE));
|
public void | setClassAnnotations(com.android.dx.rop.annotation.Annotations annotations, DexFile dexFile)Sets the direct annotations on this instance. 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.
if (annotations == null) {
throw new NullPointerException("annotations == null");
}
if (classAnnotations != null) {
throw new UnsupportedOperationException(
"class annotations already set");
}
classAnnotations = new AnnotationSetItem(annotations, dexFile);
|
public java.lang.String | toHuman(){@inheritDoc}
throw new RuntimeException("unsupported");
|
protected void | writeTo0(DexFile file, com.android.dx.util.AnnotatedOutput out){@inheritDoc}
boolean annotates = out.annotates();
int classOff = OffsettedItem.getAbsoluteOffsetOr0(classAnnotations);
int fieldsSize = listSize(fieldAnnotations);
int methodsSize = listSize(methodAnnotations);
int parametersSize = listSize(parameterAnnotations);
if (annotates) {
out.annotate(0, offsetString() + " annotations directory");
out.annotate(4, " class_annotations_off: " + Hex.u4(classOff));
out.annotate(4, " fields_size: " +
Hex.u4(fieldsSize));
out.annotate(4, " methods_size: " +
Hex.u4(methodsSize));
out.annotate(4, " parameters_size: " +
Hex.u4(parametersSize));
}
out.writeInt(classOff);
out.writeInt(fieldsSize);
out.writeInt(methodsSize);
out.writeInt(parametersSize);
if (fieldsSize != 0) {
Collections.sort(fieldAnnotations);
if (annotates) {
out.annotate(0, " fields:");
}
for (FieldAnnotationStruct item : fieldAnnotations) {
item.writeTo(file, out);
}
}
if (methodsSize != 0) {
Collections.sort(methodAnnotations);
if (annotates) {
out.annotate(0, " methods:");
}
for (MethodAnnotationStruct item : methodAnnotations) {
item.writeTo(file, out);
}
}
if (parametersSize != 0) {
Collections.sort(parameterAnnotations);
if (annotates) {
out.annotate(0, " parameters:");
}
for (ParameterAnnotationStruct item : parameterAnnotations) {
item.writeTo(file, out);
}
}
|