当前位置: 首页>>代码示例>>Java>>正文


Java Annotations.add方法代码示例

本文整理汇总了Java中com.android.dx.rop.annotation.Annotations.add方法的典型用法代码示例。如果您正苦于以下问题:Java Annotations.add方法的具体用法?Java Annotations.add怎么用?Java Annotations.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.dx.rop.annotation.Annotations的用法示例。


在下文中一共展示了Annotations.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAnnotations

import com.android.dx.rop.annotation.Annotations; //导入方法依赖的package包/类
/**
 * Parses an annotation list.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the list of annotations read from the attribute
 * data
 */
private Annotations parseAnnotations(AnnotationVisibility visibility)
        throws IOException {
    int count = input.readUnsignedShort();

    if (observer != null) {
        parsed(2, "num_annotations: " + Hex.u2(count));
    }

    Annotations annotations = new Annotations();

    for (int i = 0; i < count; i++) {
        if (observer != null) {
            parsed(0, "annotations[" + i + "]:");
            changeIndent(1);
        }

        Annotation annotation = parseAnnotation(visibility);
        annotations.add(annotation);

        if (observer != null) {
            observer.changeIndent(-1);
        }
    }

    annotations.setImmutable();
    return annotations;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:35,代码来源:AnnotationParser.java

示例2: addToMethod

import com.android.dx.rop.annotation.Annotations; //导入方法依赖的package包/类
/**
 * Add this annotation to a method.
 *
 * @param dexMaker DexMaker instance.
 * @param method Method to be added to.
 */
public void addToMethod(DexMaker dexMaker, MethodId<?, ?> method) {
    if (annotatedElement != ElementType.METHOD) {
        throw new IllegalStateException("This annotation is not for method");
    }

    if (method.declaringType != declaringType) {
        throw new IllegalArgumentException("Method" + method + "'s declaring type is inconsistent with" + this);
    }

    ClassDefItem classDefItem = dexMaker.getTypeDeclaration(declaringType).toClassDefItem();

    if (classDefItem == null) {
        throw new NullPointerException("No class defined item is found");
    } else {
        CstMethodRef cstMethodRef = method.constant;

        if (cstMethodRef == null) {
            throw new NullPointerException("Method reference is NULL");
        } else {
            // Generate CstType
            CstType cstType = CstType.intern(type.ropType);

            // Generate Annotation
            Annotation annotation = new Annotation(cstType, AnnotationVisibility.RUNTIME);

            // Add generated annotation
            Annotations annotations = new Annotations();
            for (NameValuePair nvp : elements.values()) {
                annotation.add(nvp);
            }
            annotations.add(annotation);
            classDefItem.addMethodAnnotations(cstMethodRef, annotations, dexMaker.getDexFile());
        }
    }
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:42,代码来源:AnnotationId.java


注:本文中的com.android.dx.rop.annotation.Annotations.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。