com.android.dx.cf.attrib.AttAnnotationDefault Java Examples

The following examples show how to use com.android.dx.cf.attrib.AttAnnotationDefault. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AttributeTranslator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the {@code AnnotationDefault} attributes out of a
 * given class, if any, reforming them as an
 * {@code AnnotationDefault} annotation.
 *
 * @param cf {@code non-null;} the class in question
 * @return {@code null-ok;} an appropriately-constructed
 * {@code AnnotationDefault} annotation, if there were any
 * annotation defaults in the class, or {@code null} if not
 */
private static Annotation translateAnnotationDefaults(DirectClassFile cf) {
    CstType thisClass = cf.getThisClass();
    MethodList methods = cf.getMethods();
    int sz = methods.size();
    Annotation result =
        new Annotation(thisClass, AnnotationVisibility.EMBEDDED);
    boolean any = false;

    for (int i = 0; i < sz; i++) {
        Method one = methods.get(i);
        AttributeList attribs = one.getAttributes();
        AttAnnotationDefault oneDefault = (AttAnnotationDefault)
            attribs.findFirst(AttAnnotationDefault.ATTRIBUTE_NAME);

        if (oneDefault != null) {
            NameValuePair pair = new NameValuePair(
                    one.getNat().getName(),
                    oneDefault.getValue());
            result.add(pair);
            any = true;
        }
    }

    if (! any) {
        return null;
    }

    result.setImmutable();
    return AnnotationUtils.makeAnnotationDefault(result);
}
 
Example #2
Source File: StdAttributeFactory.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Parses an {@code AnnotationDefault} attribute.
 */
private Attribute annotationDefault(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    Constant cst = ap.parseValueAttribute();

    return new AttAnnotationDefault(cst, length);
}
 
Example #3
Source File: AttributeTranslator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the {@code AnnotationDefault} attributes out of a
 * given class, if any, reforming them as an
 * {@code AnnotationDefault} annotation.
 *
 * @param cf {@code non-null;} the class in question
 * @return {@code null-ok;} an appropriately-constructed
 * {@code AnnotationDefault} annotation, if there were any
 * annotation defaults in the class, or {@code null} if not
 */
private static Annotation translateAnnotationDefaults(DirectClassFile cf) {
    CstType thisClass = cf.getThisClass();
    MethodList methods = cf.getMethods();
    int sz = methods.size();
    Annotation result =
        new Annotation(thisClass, AnnotationVisibility.EMBEDDED);
    boolean any = false;

    for (int i = 0; i < sz; i++) {
        Method one = methods.get(i);
        AttributeList attribs = one.getAttributes();
        AttAnnotationDefault oneDefault = (AttAnnotationDefault)
            attribs.findFirst(AttAnnotationDefault.ATTRIBUTE_NAME);

        if (oneDefault != null) {
            NameValuePair pair = new NameValuePair(
                    one.getNat().getName(),
                    oneDefault.getValue());
            result.add(pair);
            any = true;
        }
    }

    if (! any) {
        return null;
    }

    result.setImmutable();
    return AnnotationUtils.makeAnnotationDefault(result);
}
 
Example #4
Source File: StdAttributeFactory.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Parses an {@code AnnotationDefault} attribute.
 */
private Attribute annotationDefault(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    Constant cst = ap.parseValueAttribute();

    return new AttAnnotationDefault(cst, length);
}
 
Example #5
Source File: AttributeTranslator.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the {@code AnnotationDefault} attributes out of a
 * given class, if any, reforming them as an
 * {@code AnnotationDefault} annotation.
 *
 * @param cf {@code non-null;} the class in question
 * @return {@code null-ok;} an appropriately-constructed
 * {@code AnnotationDefault} annotation, if there were any
 * annotation defaults in the class, or {@code null} if not
 */
private static Annotation translateAnnotationDefaults(DirectClassFile cf) {
    CstType thisClass = cf.getThisClass();
    MethodList methods = cf.getMethods();
    int sz = methods.size();
    Annotation result =
        new Annotation(thisClass, AnnotationVisibility.EMBEDDED);
    boolean any = false;

    for (int i = 0; i < sz; i++) {
        Method one = methods.get(i);
        AttributeList attribs = one.getAttributes();
        AttAnnotationDefault oneDefault = (AttAnnotationDefault)
            attribs.findFirst(AttAnnotationDefault.ATTRIBUTE_NAME);

        if (oneDefault != null) {
            NameValuePair pair = new NameValuePair(
                    one.getNat().getName(),
                    oneDefault.getValue());
            result.add(pair);
            any = true;
        }
    }

    if (! any) {
        return null;
    }

    result.setImmutable();
    return AnnotationUtils.makeAnnotationDefault(result);
}
 
Example #6
Source File: StdAttributeFactory.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Parses an {@code AnnotationDefault} attribute.
 */
private Attribute annotationDefault(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    Constant cst = ap.parseValueAttribute();

    return new AttAnnotationDefault(cst, length);
}
 
Example #7
Source File: AttributeTranslator.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the {@code AnnotationDefault} attributes out of a
 * given class, if any, reforming them as an
 * {@code AnnotationDefault} annotation.
 *
 * @param cf {@code non-null;} the class in question
 * @return {@code null-ok;} an appropriately-constructed
 * {@code AnnotationDefault} annotation, if there were any
 * annotation defaults in the class, or {@code null} if not
 */
private static Annotation translateAnnotationDefaults(DirectClassFile cf) {
    CstType thisClass = cf.getThisClass();
    MethodList methods = cf.getMethods();
    int sz = methods.size();
    Annotation result =
        new Annotation(thisClass, AnnotationVisibility.EMBEDDED);
    boolean any = false;

    for (int i = 0; i < sz; i++) {
        Method one = methods.get(i);
        AttributeList attribs = one.getAttributes();
        AttAnnotationDefault oneDefault = (AttAnnotationDefault)
            attribs.findFirst(AttAnnotationDefault.ATTRIBUTE_NAME);

        if (oneDefault != null) {
            NameValuePair pair = new NameValuePair(
                    one.getNat().getName(),
                    oneDefault.getValue());
            result.add(pair);
            any = true;
        }
    }

    if (! any) {
        return null;
    }

    result.setImmutable();
    return AnnotationUtils.makeAnnotationDefault(result);
}
 
Example #8
Source File: StdAttributeFactory.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Parses an {@code AnnotationDefault} attribute.
 */
private Attribute annotationDefault(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    Constant cst = ap.parseValueAttribute();

    return new AttAnnotationDefault(cst, length);
}