/** * Given an annotation, return true if it should be documented and false * otherwise. * * @param annotationDoc the annotation to check. * * @return true return true if it should be documented and false otherwise. */ public static boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) { AnnotationDesc[] annotationDescList = annotationDoc.annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.annotation.Documented.class.getName())){ return true; } } return false; }
/** * Given an annotation, return true if it should be documented and false * otherwise. * * @param annotationDoc the annotation to check. * * @return true return true if it should be documented and false otherwise. */ public static boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) { AnnotationDesc[] annotationDescList = annotationDoc.annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.annotation.Documented.class.getName())){ return true; } } return false; }
/** * Returns true if the {@code annotationDoc} is to be treated * as a declaration annotation, when targeting the * {@code elemType} element type. * * @param annotationDoc the annotationDoc to check * @param elemType the targeted elemType * @return true if annotationDoc is a declaration annotation */ public static boolean isDeclarationAnnotation(AnnotationTypeDoc annotationDoc, boolean isJava5DeclarationLocation) { if (!isJava5DeclarationLocation) return false; AnnotationDesc[] annotationDescList = annotationDoc.annotations(); // Annotations with no target are treated as declaration as well if (annotationDescList.length==0) return true; for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.annotation.Target.class.getName())) { if (isDeclarationTarget(annotationDescList[i])) return true; } } return false; }
/** * Parse an annotation. * * @param annotationTypeDoc * A AnnotationTypeDoc instance * @return the annotation node */ protected Annotation parseAnnotationTypeDoc(AnnotationTypeDoc annotationTypeDoc) { Annotation annotationNode = objectFactory.createAnnotation(); annotationNode.setName(annotationTypeDoc.name()); annotationNode.setQualified(annotationTypeDoc.qualifiedName()); String comment = annotationTypeDoc.commentText(); if (comment.length() > 0) { annotationNode.setComment(comment); } annotationNode.setIncluded(annotationTypeDoc.isIncluded()); annotationNode.setScope(parseScope(annotationTypeDoc)); for (AnnotationTypeElementDoc annotationTypeElementDoc : annotationTypeDoc.elements()) { annotationNode.getElement().add(parseAnnotationTypeElementDoc(annotationTypeElementDoc)); } for (AnnotationDesc annotationDesc : annotationTypeDoc.annotations()) { annotationNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, annotationTypeDoc.qualifiedName())); } for (Tag tag : annotationTypeDoc.tags()) { annotationNode.getTag().add(parseTag(tag)); } return annotationNode; }