• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Annotations类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Annotations类属于com.android.dx.rop.annotation包,在下文中一共展示了Annotations类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAnnotations0

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Helper method for {@link #getAnnotations} which just gets the
 * existing annotations, per se.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code non-null;} the set of annotations, which may be empty
 */
private static Annotations getAnnotations0(AttributeList attribs) {
    AttRuntimeVisibleAnnotations visible =
        (AttRuntimeVisibleAnnotations)
        attribs.findFirst(AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME);
    AttRuntimeInvisibleAnnotations invisible =
        (AttRuntimeInvisibleAnnotations)
        attribs.findFirst(AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME);

    if (visible == null) {
        if (invisible == null) {
            return Annotations.EMPTY;
        }
        return invisible.getAnnotations();
    }

    if (invisible == null) {
        return visible.getAnnotations();
    }

    // Both are non-null, so combine them.

    return Annotations.combine(visible.getAnnotations(),
            invisible.getAnnotations());
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:32,代码来源:AttributeTranslator.java


示例2: BaseAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param attributeName {@code non-null;} the name of the attribute
 * @param annotations {@code non-null;} the list of annotations
 * @param byteLength {@code >= 0;} attribute data length in the original
 * classfile (not including the attribute header)
 */
public BaseAnnotations(String attributeName, Annotations annotations,
        int byteLength) {
    super(attributeName);

    try {
        if (annotations.isMutable()) {
            throw new MutabilityException("annotations.isMutable()");
        }
    } catch (NullPointerException ex) {
        // Translate the exception.
        throw new NullPointerException("annotations == null");
    }

    this.annotations = annotations;
    this.byteLength = byteLength;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:25,代码来源:BaseAnnotations.java


示例3: parseAnnotationAttribute

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Parses an annotation attribute, per se.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the list of annotations read from the attribute
 * data
 */
public Annotations parseAnnotationAttribute(
        AnnotationVisibility visibility) {
    Annotations result;

    try {
        result = parseAnnotations(visibility);

        if (input.available() != 0) {
            throw new ParseException("extra data in attribute");
        }
    } catch (IOException ex) {
        // ByteArray.MyDataInputStream should never throw.
        throw new RuntimeException("shouldn't happen", ex);
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:25,代码来源:AnnotationParser.java


示例4: getAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Gets the annotations out of a given {@link AttributeList}. This
 * combines both visible and invisible annotations into a single
 * result set and also adds in a system annotation for the
 * {@code Signature} attribute if present.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code non-null;} the set of annotations, which may be empty
 */
public static Annotations getAnnotations(AttributeList attribs) {
    Annotations result = getAnnotations0(attribs);
    Annotation signature = getSignature(attribs);

    if (signature != null) {
        result = Annotations.combine(result, signature);
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:20,代码来源:AttributeTranslator.java


示例5: getClassAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Gets the annotations out of a given class, similar to {@link
 * #getAnnotations}, also including annotations for translations
 * of class-level attributes {@code EnclosingMethod} and
 * {@code InnerClasses}, if present. Additionally, if the
 * class is an annotation class, then this also includes a
 * representation of all the {@code AnnotationDefault}
 * values.
 *
 * @param cf {@code non-null;} the class in question
 * @param args {@code non-null;} the high-level options
 * @return {@code non-null;} the set of annotations, which may be empty
 */
public static Annotations getClassAnnotations(DirectClassFile cf,
        CfOptions args) {
    CstType thisClass = cf.getThisClass();
    AttributeList attribs = cf.getAttributes();
    Annotations result = getAnnotations(attribs);
    Annotation enclosingMethod = translateEnclosingMethod(attribs);

    try {
        Annotations innerClassAnnotations =
            translateInnerClasses(thisClass, attribs,
                    enclosingMethod == null);
        if (innerClassAnnotations != null) {
            result = Annotations.combine(result, innerClassAnnotations);
        }
    } catch (Warning warn) {
        args.warn.println("warning: " + warn.getMessage());
    }

    if (enclosingMethod != null) {
        result = Annotations.combine(result, enclosingMethod);
    }

    if (AccessFlags.isAnnotation(cf.getAccessFlags())) {
        Annotation annotationDefault =
            translateAnnotationDefaults(cf);
        if (annotationDefault != null) {
            result = Annotations.combine(result, annotationDefault);
        }
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:46,代码来源:AttributeTranslator.java


示例6: getMethodAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Gets the annotations out of a given method, similar to {@link
 * #getAnnotations}, also including an annotation for the translation
 * of the method-specific attribute {@code Exceptions}.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the set of annotations, which may be empty
 */
public static Annotations getMethodAnnotations(Method method) {
    Annotations result = getAnnotations(method.getAttributes());
    TypeList exceptions = getExceptions(method);

    if (exceptions.size() != 0) {
        Annotation throwsAnnotation =
            AnnotationUtils.makeThrows(exceptions);
        result = Annotations.combine(result, throwsAnnotation);
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:21,代码来源:AttributeTranslator.java


示例7: AnnotationSetItem

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param annotations {@code non-null;} set of annotations
 * @param dexFile {@code non-null;} dex output
 */
public AnnotationSetItem(Annotations annotations, DexFile dexFile) {
    super(ALIGNMENT, writeSize(annotations));

    this.annotations = annotations;
    this.items = new AnnotationItem[annotations.size()];

    int at = 0;
    for (Annotation a : annotations.getAnnotations()) {
        items[at] = new AnnotationItem(a, dexFile);
        at++;
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:AnnotationSetItem.java


示例8: writeSize

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Gets the write size for the given set.
 *
 * @param annotations {@code non-null;} the set
 * @return {@code > 0;} the write size
 */
private static int writeSize(Annotations annotations) {
    // This includes an int size at the start of the list.

    try {
        return (annotations.size() * ENTRY_WRITE_SIZE) + 4;
    } catch (NullPointerException ex) {
        // Elucidate the exception.
        throw new NullPointerException("list == null");
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:17,代码来源:AnnotationSetItem.java


示例9: setClassAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * 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.
 *
 * @param annotations {@code non-null;} annotations to set for this class
 * @param dexFile {@code non-null;} dex output
 */
public void setClassAnnotations(Annotations annotations, DexFile dexFile) {
    if (annotations == null) {
        throw new NullPointerException("annotations == null");
    }

    if (classAnnotations != null) {
        throw new UnsupportedOperationException(
                "class annotations already set");
    }

    classAnnotations = new AnnotationSetItem(annotations, dexFile);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:21,代码来源:AnnotationsDirectoryItem.java


示例10: addFieldAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Adds a field annotations item to this instance.
 *
 * @param field {@code non-null;} field in question
 * @param annotations {@code non-null;} associated annotations to add
 * @param dexFile {@code non-null;} dex output
 */
public void addFieldAnnotations(CstFieldRef field,
        Annotations annotations, DexFile dexFile) {
    if (fieldAnnotations == null) {
        fieldAnnotations = new ArrayList<FieldAnnotationStruct>();
    }

    fieldAnnotations.add(new FieldAnnotationStruct(field,
                    new AnnotationSetItem(annotations, dexFile)));
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:17,代码来源:AnnotationsDirectoryItem.java


示例11: addMethodAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Adds a method annotations item to this instance.
 *
 * @param method {@code non-null;} method in question
 * @param annotations {@code non-null;} associated annotations to add
 * @param dexFile {@code non-null;} dex output
 */
public void addMethodAnnotations(CstMethodRef method,
        Annotations annotations, DexFile dexFile) {
    if (methodAnnotations == null) {
        methodAnnotations = new ArrayList<MethodAnnotationStruct>();
    }

    methodAnnotations.add(new MethodAnnotationStruct(method,
                    new AnnotationSetItem(annotations, dexFile)));
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:17,代码来源:AnnotationsDirectoryItem.java


示例12: getMethodAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Gets the method annotations for a given method, if any. This is
 * meant for use by debugging / dumping code.
 *
 * @param method {@code non-null;} the method
 * @return {@code null-ok;} the method annotations, if any
 */
public Annotations getMethodAnnotations(CstMethodRef method) {
    if (methodAnnotations == null) {
        return null;
    }

    for (MethodAnnotationStruct item : methodAnnotations) {
        if (item.getMethod().equals(method)) {
            return item.getAnnotations();
        }
    }

    return null;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:21,代码来源:AnnotationsDirectoryItem.java


示例13: ParameterAnnotationStruct

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} the method in question
 * @param annotationsList {@code non-null;} the associated annotations list
 * @param dexFile {@code non-null;} dex output
 */
public ParameterAnnotationStruct(CstMethodRef method,
        AnnotationsList annotationsList, DexFile dexFile) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    if (annotationsList == null) {
        throw new NullPointerException("annotationsList == null");
    }

    this.method = method;
    this.annotationsList = annotationsList;

    /*
     * Construct an item for the annotations list. TODO: This
     * requires way too much copying; fix it.
     */

    int size = annotationsList.size();
    ArrayList<AnnotationSetRefItem> arrayList = new
        ArrayList<AnnotationSetRefItem>(size);

    for (int i = 0; i < size; i++) {
        Annotations annotations = annotationsList.get(i);
        AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile);
        arrayList.add(new AnnotationSetRefItem(item));
    }

    this.annotationsItem = new UniformListItem<AnnotationSetRefItem>(
            ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:39,代码来源:ParameterAnnotationStruct.java


示例14: parseAnnotationsList

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

    if (observer != null) {
        parsed(1, "num_parameters: " + Hex.u1(count));
    }

    AnnotationsList outerList = new AnnotationsList(count);

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

        Annotations annotations = parseAnnotations(visibility);
        outerList.set(i, annotations);

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

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


示例15: 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


示例16: runtimeInvisibleAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Parses a {@code RuntimeInvisibleAnnotations} attribute.
 */
private Attribute runtimeInvisibleAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    Annotations annotations =
        ap.parseAnnotationAttribute(AnnotationVisibility.BUILD);

    return new AttRuntimeInvisibleAnnotations(annotations, length);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:17,代码来源:StdAttributeFactory.java


示例17: runtimeVisibleAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Parses a {@code RuntimeVisibleAnnotations} attribute.
 */
private Attribute runtimeVisibleAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    Annotations annotations =
        ap.parseAnnotationAttribute(AnnotationVisibility.RUNTIME);

    return new AttRuntimeVisibleAnnotations(annotations, length);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:17,代码来源:StdAttributeFactory.java


示例18: translate0

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Performs the main act of translation. This method is separated
 * from {@link #translate} just to keep things a bit simpler in
 * terms of exception handling.
 *
 * @param filePath {@code non-null;} the file path for the class,
 * excluding any base directory specification
 * @param bytes {@code non-null;} contents of the file
 * @param cfOptions options for class translation
 * @param dexOptions options for dex output
 * @return {@code non-null;} the translated class
 */
private static ClassDefItem translate0(String filePath, byte[] bytes,
        CfOptions cfOptions, DexOptions dexOptions) {
    DirectClassFile cf =
        new DirectClassFile(bytes, filePath, cfOptions.strictNameCheck);

    cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    cf.getMagic();

    OptimizerOptions.loadOptimizeLists(cfOptions.optimizeListFile,
            cfOptions.dontOptimizeListFile);

    // Build up a class to output.

    CstType thisClass = cf.getThisClass();
    int classAccessFlags = cf.getAccessFlags() & ~AccessFlags.ACC_SUPER;
    CstString sourceFile = (cfOptions.positionInfo == PositionList.NONE) ? null :
        cf.getSourceFile();
    ClassDefItem out =
        new ClassDefItem(thisClass, classAccessFlags,
                cf.getSuperclass(), cf.getInterfaces(), sourceFile);

    Annotations classAnnotations =
        AttributeTranslator.getClassAnnotations(cf, cfOptions);
    if (classAnnotations.size() != 0) {
        out.setClassAnnotations(classAnnotations);
    }

    processFields(cf, out);
    processMethods(cf, cfOptions, dexOptions, out);

    return out;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:45,代码来源:CfTranslator.java


示例19: AnnotationSetItem

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param annotations {@code non-null;} set of annotations
 */
public AnnotationSetItem(Annotations annotations) {
    super(ALIGNMENT, writeSize(annotations));

    this.annotations = annotations;
    this.items = new AnnotationItem[annotations.size()];

    int at = 0;
    for (Annotation a : annotations.getAnnotations()) {
        items[at] = new AnnotationItem(a);
        at++;
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:18,代码来源:AnnotationSetItem.java


示例20: setClassAnnotations

import com.android.dx.rop.annotation.Annotations; //导入依赖的package包/类
/**
 * 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.
 *
 * @param annotations {@code non-null;} annotations to set for this class
 */
public void setClassAnnotations(Annotations annotations) {
    if (annotations == null) {
        throw new NullPointerException("annotations == null");
    }

    if (classAnnotations != null) {
        throw new UnsupportedOperationException(
                "class annotations already set");
    }

    classAnnotations = new AnnotationSetItem(annotations);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:20,代码来源:AnnotationsDirectoryItem.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Kind类代码示例发布时间:2022-05-22
下一篇:
Java LongPoint类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap