Java Code Examples for com.android.dx.rop.annotation.Annotation

The following examples show how to use com.android.dx.rop.annotation.Annotation. These examples are extracted from open source projects. 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 Project: Box   Source File: AttributeTranslator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    Annotation sourceDebugExtension = getSourceDebugExtension(attribs);

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

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

    return result;
}
 
Example 2
Source Project: Box   Source File: AttributeTranslator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the {@code EnclosingMethod} attribute out of a given
 * {@link AttributeList}, if any, translating it to an annotation.
 * If the class really has an enclosing method, this returns an
 * {@code EnclosingMethod} annotation; if not, this returns
 * an {@code EnclosingClass} annotation.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code null-ok;} the converted {@code EnclosingMethod} or
 * {@code EnclosingClass} annotation, if there was an
 * attribute to translate
 */
private static Annotation translateEnclosingMethod(AttributeList attribs) {
    AttEnclosingMethod enclosingMethod = (AttEnclosingMethod)
        attribs.findFirst(AttEnclosingMethod.ATTRIBUTE_NAME);

    if (enclosingMethod == null) {
        return null;
    }

    CstType enclosingClass = enclosingMethod.getEnclosingClass();
    CstNat nat = enclosingMethod.getMethod();

    if (nat == null) {
        /*
         * Dalvik doesn't use EnclosingMethod annotations unless
         * there really is an enclosing method. Anonymous classes
         * are unambiguously identified by having an InnerClass
         * annotation with an empty name along with an appropriate
         * EnclosingClass.
         */
        return AnnotationUtils.makeEnclosingClass(enclosingClass);
    }

    return AnnotationUtils.makeEnclosingMethod(
            new CstMethodRef(enclosingClass, nat));
}
 
Example 3
Source Project: buck   Source File: AnnotationLister.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Inspects a class annotation.
 *
 * @param cf {@code non-null;} class file
 * @param ann {@code non-null;} annotation
 */
private void visitClassAnnotation(DirectClassFile cf,
        BaseAnnotations ann) {

    if (!args.eTypes.contains(ElementType.TYPE)) {
        return;
    }

    for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
        String annClassName
                = anAnn.getType().getClassType().getClassName();
        if (args.aclass.equals(annClassName)) {
            printMatch(cf);
        }
    }
}
 
Example 4
Source Project: Box   Source File: AnnotationItem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param annotation {@code non-null;} annotation to represent
 * @param dexFile {@code non-null;} dex output
 */
public AnnotationItem(Annotation annotation, DexFile dexFile) {
    /*
     * The write size isn't known up-front because (the variable-lengthed)
     * leb128 type is used to represent some things.
     */
    super(ALIGNMENT, -1);

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

    this.annotation = annotation;
    this.type = null;
    this.encodedForm = null;
    addContents(dexFile);
}
 
Example 5
Source Project: Box   Source File: AnnotationLister.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Inspects a class annotation.
 *
 * @param cf {@code non-null;} class file
 * @param ann {@code non-null;} annotation
 */
private void visitClassAnnotation(DirectClassFile cf,
        BaseAnnotations ann) {

    if (!args.eTypes.contains(ElementType.TYPE)) {
        return;
    }

    for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
        String annClassName
                = anAnn.getType().getClassType().getClassName();
        if (args.aclass.equals(annClassName)) {
            printMatch(cf);
        }
    }
}
 
Example 6
Source Project: Box   Source File: AttributeTranslator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    Annotation sourceDebugExtension = getSourceDebugExtension(attribs);

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

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

    return result;
}
 
Example 7
Source Project: Box   Source File: AttributeTranslator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the {@code EnclosingMethod} attribute out of a given
 * {@link AttributeList}, if any, translating it to an annotation.
 * If the class really has an enclosing method, this returns an
 * {@code EnclosingMethod} annotation; if not, this returns
 * an {@code EnclosingClass} annotation.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code null-ok;} the converted {@code EnclosingMethod} or
 * {@code EnclosingClass} annotation, if there was an
 * attribute to translate
 */
private static Annotation translateEnclosingMethod(AttributeList attribs) {
    AttEnclosingMethod enclosingMethod = (AttEnclosingMethod)
        attribs.findFirst(AttEnclosingMethod.ATTRIBUTE_NAME);

    if (enclosingMethod == null) {
        return null;
    }

    CstType enclosingClass = enclosingMethod.getEnclosingClass();
    CstNat nat = enclosingMethod.getMethod();

    if (nat == null) {
        /*
         * Dalvik doesn't use EnclosingMethod annotations unless
         * there really is an enclosing method. Anonymous classes
         * are unambiguously identified by having an InnerClass
         * annotation with an empty name along with an appropriate
         * EnclosingClass.
         */
        return AnnotationUtils.makeEnclosingClass(enclosingClass);
    }

    return AnnotationUtils.makeEnclosingMethod(
            new CstMethodRef(enclosingClass, nat));
}
 
Example 8
Source Project: buck   Source File: AttributeTranslator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the {@code EnclosingMethod} attribute out of a given
 * {@link AttributeList}, if any, translating it to an annotation.
 * If the class really has an enclosing method, this returns an
 * {@code EnclosingMethod} annotation; if not, this returns
 * an {@code EnclosingClass} annotation.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code null-ok;} the converted {@code EnclosingMethod} or
 * {@code EnclosingClass} annotation, if there was an
 * attribute to translate
 */
private static Annotation translateEnclosingMethod(AttributeList attribs) {
    AttEnclosingMethod enclosingMethod = (AttEnclosingMethod)
        attribs.findFirst(AttEnclosingMethod.ATTRIBUTE_NAME);

    if (enclosingMethod == null) {
        return null;
    }

    CstType enclosingClass = enclosingMethod.getEnclosingClass();
    CstNat nat = enclosingMethod.getMethod();

    if (nat == null) {
        /*
         * Dalvik doesn't use EnclosingMethod annotations unless
         * there really is an enclosing method. Anonymous classes
         * are unambiguously identified by having an InnerClass
         * annotation with an empty name along with an appropriate
         * EnclosingClass.
         */
        return AnnotationUtils.makeEnclosingClass(enclosingClass);
    }

    return AnnotationUtils.makeEnclosingMethod(
            new CstMethodRef(enclosingClass, nat));
}
 
Example 9
Source Project: Box   Source File: AnnotationItem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param annotation {@code non-null;} annotation to represent
 * @param dexFile {@code non-null;} dex output
 */
public AnnotationItem(Annotation annotation, DexFile dexFile) {
    /*
     * The write size isn't known up-front because (the variable-lengthed)
     * leb128 type is used to represent some things.
     */
    super(ALIGNMENT, -1);

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

    this.annotation = annotation;
    this.type = null;
    this.encodedForm = null;
    addContents(dexFile);
}
 
Example 10
Source Project: Box   Source File: AnnotationLister.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Inspects a class annotation.
 *
 * @param cf {@code non-null;} class file
 * @param ann {@code non-null;} annotation
 */
private void visitClassAnnotation(DirectClassFile cf,
        BaseAnnotations ann) {

    if (!args.eTypes.contains(ElementType.TYPE)) {
        return;
    }

    for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
        String annClassName
                = anAnn.getType().getClassType().getClassName();
        if (args.aclass.equals(annClassName)) {
            printMatch(cf);
        }
    }
}
 
Example 11
Source Project: J2ME-Loader   Source File: AttributeTranslator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    Annotation sourceDebugExtension = getSourceDebugExtension(attribs);

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

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

    return result;
}
 
Example 12
Source Project: J2ME-Loader   Source File: AttributeTranslator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the {@code EnclosingMethod} attribute out of a given
 * {@link AttributeList}, if any, translating it to an annotation.
 * If the class really has an enclosing method, this returns an
 * {@code EnclosingMethod} annotation; if not, this returns
 * an {@code EnclosingClass} annotation.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code null-ok;} the converted {@code EnclosingMethod} or
 * {@code EnclosingClass} annotation, if there was an
 * attribute to translate
 */
private static Annotation translateEnclosingMethod(AttributeList attribs) {
    AttEnclosingMethod enclosingMethod = (AttEnclosingMethod)
        attribs.findFirst(AttEnclosingMethod.ATTRIBUTE_NAME);

    if (enclosingMethod == null) {
        return null;
    }

    CstType enclosingClass = enclosingMethod.getEnclosingClass();
    CstNat nat = enclosingMethod.getMethod();

    if (nat == null) {
        /*
         * Dalvik doesn't use EnclosingMethod annotations unless
         * there really is an enclosing method. Anonymous classes
         * are unambiguously identified by having an InnerClass
         * annotation with an empty name along with an appropriate
         * EnclosingClass.
         */
        return AnnotationUtils.makeEnclosingClass(enclosingClass);
    }

    return AnnotationUtils.makeEnclosingMethod(
            new CstMethodRef(enclosingClass, nat));
}
 
Example 13
Source Project: buck   Source File: AnnotationItem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param annotation {@code non-null;} annotation to represent
 * @param dexFile {@code non-null;} dex output
 */
public AnnotationItem(Annotation annotation, DexFile dexFile) {
    /*
     * The write size isn't known up-front because (the variable-lengthed)
     * leb128 type is used to represent some things.
     */
    super(ALIGNMENT, -1);

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

    this.annotation = annotation;
    this.type = null;
    this.encodedForm = null;
    addContents(dexFile);
}
 
Example 14
Source Project: buck   Source File: AnnotationLister.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Inspects a package annotation
 *
 * @param cf {@code non-null;} class file of "package-info" pseudo-class
 * @param ann {@code non-null;} annotation
 */
private void visitPackageAnnotation(
        DirectClassFile cf, BaseAnnotations ann) {

    if (!args.eTypes.contains(ElementType.PACKAGE)) {
        return;
    }

    String packageName = cf.getThisClass().getClassType().getClassName();

    int slashIndex = packageName.lastIndexOf('/');

    if (slashIndex == -1) {
        packageName = "";
    } else {
        packageName
                = packageName.substring(0, slashIndex);
    }


    for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
        String annClassName
                = anAnn.getType().getClassType().getClassName();
        if (args.aclass.equals(annClassName)) {
            printMatchPackage(packageName);
        }
    }
}
 
Example 15
Source Project: Box   Source File: AttributeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source Project: Box   Source File: AttributeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the {@code Signature} attribute out of a given
 * {@link AttributeList}, if any, translating it to an annotation.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code null-ok;} the converted {@code Signature} annotation,
 * if there was an attribute to translate
 */
private static Annotation getSignature(AttributeList attribs) {
    AttSignature signature = (AttSignature)
        attribs.findFirst(AttSignature.ATTRIBUTE_NAME);

    if (signature == null) {
        return null;
    }

    return AnnotationUtils.makeSignature(signature.getSignature());
}
 
Example 17
Source Project: Box   Source File: AttributeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
private static Annotation getSourceDebugExtension(AttributeList attribs) {
    AttSourceDebugExtension extension = (AttSourceDebugExtension)
        attribs.findFirst(AttSourceDebugExtension.ATTRIBUTE_NAME);

    if (extension == null) {
        return null;
    }

    return AnnotationUtils.makeSourceDebugExtension(extension.getSmapString());
}
 
Example 18
Source Project: Box   Source File: AttributeTranslator.java    License: 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 19
Source Project: Box   Source File: AnnotationSetItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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++;
    }
}
 
Example 20
Source Project: Box   Source File: AnnotationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a standard {@code AnnotationDefault} annotation.
 *
 * @param defaults {@code non-null;} the defaults, itself as an annotation
 * @return {@code non-null;} the constructed annotation
 */
public static Annotation makeAnnotationDefault(Annotation defaults) {
    Annotation result = new Annotation(ANNOTATION_DEFAULT_TYPE, SYSTEM);

    result.put(new NameValuePair(VALUE_STRING, new CstAnnotation(defaults)));
    result.setImmutable();
    return result;
}
 
Example 21
Source Project: Box   Source File: AnnotationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a standard {@code EnclosingClass} annotation.
 *
 * @param clazz {@code non-null;} the enclosing class
 * @return {@code non-null;} the annotation
 */
public static Annotation makeEnclosingClass(CstType clazz) {
    Annotation result = new Annotation(ENCLOSING_CLASS_TYPE, SYSTEM);

    result.put(new NameValuePair(VALUE_STRING, clazz));
    result.setImmutable();
    return result;
}
 
Example 22
Source Project: buck   Source File: AnnotationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a standard {@code MemberClasses} annotation.
 *
 * @param types {@code non-null;} the list of (the types of) the member classes
 * @return {@code non-null;} the annotation
 */
public static Annotation makeMemberClasses(TypeList types) {
    CstArray array = makeCstArray(types);
    Annotation result = new Annotation(MEMBER_CLASSES_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, array));
    result.setImmutable();
    return result;
}
 
Example 23
Source Project: Box   Source File: AnnotationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a standard {@code MemberClasses} annotation.
 *
 * @param types {@code non-null;} the list of (the types of) the member classes
 * @return {@code non-null;} the annotation
 */
public static Annotation makeMemberClasses(TypeList types) {
    CstArray array = makeCstArray(types);
    Annotation result = new Annotation(MEMBER_CLASSES_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, array));
    result.setImmutable();
    return result;
}
 
Example 24
Source Project: Box   Source File: AnnotationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a standard {@code SourceDebugExtension} annotation.
 *
 * @param smapString {@code non-null;} the SMAP string associated with
 * @return {@code non-null;} the annotation
 */
public static Annotation makeSourceDebugExtension(CstString smapString) {
    Annotation result = new Annotation(SOURCE_DEBUG_EXTENSION_TYPE, SYSTEM);

    result.put(new NameValuePair(VALUE_STRING, smapString));
    result.setImmutable();
    return result;
}
 
Example 25
Source Project: buck   Source File: AnnotationSetItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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++;
    }
}
 
Example 26
Source Project: Box   Source File: ValueEncoder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@code addContents()} methods, which adds
 * contents for a particular {@link Annotation}, calling itself
 * recursively should it encounter a nested annotation.
 *
 * @param file {@code non-null;} the file to add to
 * @param annotation {@code non-null;} the annotation to add contents for
 */
public static void addContents(DexFile file, Annotation annotation) {
    TypeIdsSection typeIds = file.getTypeIds();
    StringIdsSection stringIds = file.getStringIds();

    typeIds.intern(annotation.getType());

    for (NameValuePair pair : annotation.getNameValuePairs()) {
        stringIds.intern(pair.getName());
        addContents(file, pair.getValue());
    }
}
 
Example 27
Source Project: Box   Source File: AnnotationParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 28
Source Project: Box   Source File: AnnotationParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Parses a single annotation.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotation
 * @return {@code non-null;} the parsed annotation
 */
private Annotation parseAnnotation(AnnotationVisibility visibility)
        throws IOException {
    requireLength(4);

    int typeIndex = input.readUnsignedShort();
    int numElements = input.readUnsignedShort();
    CstString typeString = (CstString) pool.get(typeIndex);
    CstType type = new CstType(Type.intern(typeString.getString()));

    if (observer != null) {
        parsed(2, "type: " + type.toHuman());
        parsed(2, "num_elements: " + numElements);
    }

    Annotation annotation = new Annotation(type, visibility);

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

        NameValuePair element = parseElement();
        annotation.add(element);

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

    annotation.setImmutable();
    return annotation;
}
 
Example 29
Source Project: Box   Source File: AnnotationLister.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Inspects a package annotation
 *
 * @param cf {@code non-null;} class file of "package-info" pseudo-class
 * @param ann {@code non-null;} annotation
 */
private void visitPackageAnnotation(
        DirectClassFile cf, BaseAnnotations ann) {

    if (!args.eTypes.contains(ElementType.PACKAGE)) {
        return;
    }

    String packageName = cf.getThisClass().getClassType().getClassName();

    int slashIndex = packageName.lastIndexOf('/');

    if (slashIndex == -1) {
        packageName = "";
    } else {
        packageName
                = packageName.substring(0, slashIndex);
    }


    for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
        String annClassName
                = anAnn.getType().getClassType().getClassName();
        if (args.aclass.equals(annClassName)) {
            printMatchPackage(packageName);
        }
    }
}
 
Example 30
Source Project: Box   Source File: CstAnnotation.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param annotation {@code non-null;} the annotation to hold
 */
public CstAnnotation(Annotation annotation) {
    if (annotation == null) {
        throw new NullPointerException("annotation == null");
    }

    annotation.throwIfMutable();

    this.annotation = annotation;
}