コード例 #1
0
  /** {@inheritDoc} */
  @Override
  protected void writeTo0(DexFile file, AnnotatedOutput out) {
    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);
      }
    }
  }