/** * This creates an AnnotationParser for a method/field * * @param element The method/field javadoc item * @param options The doclet options */ public AnnotationParser(ProgramElementDoc element, DocletOptions options) { this.annotations = element.annotations(); this.options = options; }
private static boolean hasAnnotation(ProgramElementDoc elementDoc, Class<?> annoClass) { boolean foundAnnotation = false; for (AnnotationDesc annoDesc : elementDoc.annotations()) { if (annoDesc.toString().equals("@" + annoClass.getName()) || annoDesc.toString().equals("@" + annoClass.getSimpleName())) { foundAnnotation = true; break; } } return foundAnnotation; }
/** * Write the annotatation types for the given doc. * * @param doc the doc to write annotations for. */ public void writeAnnotationInfo( ProgramElementDoc doc ) { writeAnnotationInfo( doc, doc.annotations() ); }
/** * Adds the annotatation types for the given doc. * * @param doc the package to write annotations for * @param htmltree the content tree to which the annotation types will be added */ public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) { addAnnotationInfo(doc, doc.annotations(), htmltree); }
public static AnnotationDesc getAnnotationDesc(ProgramElementDoc doc, Class<? extends Annotation> annotationClz) { for (AnnotationDesc annotationDesc : doc.annotations()) { if (annotationDesc.annotationType() .qualifiedTypeName().equals(annotationClz.getName())) { return annotationDesc; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc source, Class annotationType) { String name = annotationType.getName(); for (AnnotationDesc ad : source.annotations()) { if (ad.annotationType().qualifiedTypeName().equals(name)) { return ad; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc source, Class annotationType) { String name = annotationType.getName(); for (AnnotationDesc ad : source.annotations()) { if (ad.annotationType().qualifiedTypeName().equals(name)) { return ad; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc doc, String qualifiedName) { for (AnnotationDesc annotation : doc.annotations()) { if (annotation.annotationType().qualifiedName().equals(qualifiedName)) { return annotation; } } return null; }
/** * @return The annotation with the given <var>annotationType</var>, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationType</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, ClassDoc annotationType) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().equals(annotationType)) return ad; } return null; }
/** * @return The annotation with the given <var>annotationType</var>, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationType</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, ClassDoc annotationType) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().equals(annotationType)) return ad; } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc doc, String qualifiedName) { for (AnnotationDesc annotation : doc.annotations()) { if (annotation.annotationType().qualifiedName().equals(qualifiedName)) { return annotation; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc elementDoc, Class<?> annoClass) { for (AnnotationDesc annoDesc : elementDoc.annotations()) { AnnotationTypeDoc typeDoc = annoDesc.annotationType(); if (typeDoc.typeName().equals(annoClass.getName()) || typeDoc.simpleTypeName().equals(annoClass.getSimpleName())) { return annoDesc; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc doc, String qualifiedName) { for (AnnotationDesc annotation : doc.annotations()) { if (annotation.annotationType().qualifiedName().equals(qualifiedName)) { return annotation; } } return null; }
/** * @return The annotation with the given simple (unqualified) type name, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationTypeSimpleName</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, String annotationTypeSimpleName) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().simpleTypeName().equals(annotationTypeSimpleName)) return ad; } return null; }
/** * @return The annotation with the given simple (unqualified) type name, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationTypeSimpleName</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, String annotationTypeSimpleName) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().simpleTypeName().equals(annotationTypeSimpleName)) return ad; } return null; }
/** * This finds a HTTP method for the given method * * @param method The java method to check * @return The HTTP method or null if there is not HTTP method annotation on the java method */ public static HttpMethod fromMethod(ProgramElementDoc method) { for (AnnotationDesc annotation : method.annotations()) { String qName = annotation.annotationType().qualifiedTypeName(); for (HttpMethod value : HttpMethod.values()) { if (value.useContains && qName.contains(value.className)) { return value; } else if (!value.useContains && qName.equals(value.className)) { return value; } } } return null; }
/** * Return true if the given Doc is deprecated. * * @param doc the Doc to check. * @return true if the given Doc is deprecated. */ public static boolean isDeprecated(ProgramElementDoc doc) { if (doc.tags("deprecated").length > 0) { return true; } AnnotationDesc[] annotationDescList = doc.annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.Deprecated.class.getName())){ return true; } } return false; } }
/** * Return true if the given Doc is deprecated. * * @param doc the Doc to check. * @return true if the given Doc is deprecated. */ public static boolean isDeprecated(Doc doc) { if (doc.tags("deprecated").length > 0) { return true; } AnnotationDesc[] annotationDescList; if (doc instanceof PackageDoc) annotationDescList = ((PackageDoc)doc).annotations(); else annotationDescList = ((ProgramElementDoc)doc).annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.Deprecated.class.getName())){ return true; } } return false; }
/** * Map the AnnotationType to the ProgramElementDocs that use them as * type parameters. * * @param map the map the insert the information into. * @param doc the doc whose type parameters are being checked. * @param holder the holder that owns the type parameters. */ private <T extends ProgramElementDoc> void mapAnnotations(Map<String,List<T>> map, Object doc, T holder) { AnnotationDesc[] annotations; boolean isPackage = false; if (doc instanceof ProgramElementDoc) { annotations = ((ProgramElementDoc) doc).annotations(); } else if (doc instanceof PackageDoc) { annotations = ((PackageDoc) doc).annotations(); isPackage = true; } else if (doc instanceof Parameter) { annotations = ((Parameter) doc).annotations(); } else { throw new DocletAbortException(); } for (int i = 0; i < annotations.length; i++) { AnnotationTypeDoc annotationDoc = annotations[i].annotationType(); if (isPackage) refList(map, annotationDoc).add(holder); else add(map, annotationDoc, holder); } }
/** * Map the AnnotationType to the ProgramElementDocs that use them as * type parameters. * * @param map the map the insert the information into. * @param doc the doc whose type parameters are being checked. * @param holder the holder that owns the type parameters. */ private <T extends ProgramElementDoc> void mapAnnotations(Map<String,List<T>> map, Object doc, T holder) { AnnotationDesc[] annotations; boolean isPackage = false; if (doc instanceof ProgramElementDoc) { annotations = ((ProgramElementDoc) doc).annotations(); } else if (doc instanceof PackageDoc) { annotations = ((PackageDoc) doc).annotations(); isPackage = true; } else if (doc instanceof Parameter) { annotations = ((Parameter) doc).annotations(); } else { throw new DocletAbortException("should not happen"); } for (int i = 0; i < annotations.length; i++) { AnnotationTypeDoc annotationDoc = annotations[i].annotationType(); if (isPackage) refList(map, annotationDoc).add(holder); else add(map, annotationDoc, holder); } }