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; }
for (final AnnotationDesc annotationDesc : annotations) { final AnnotationDocType annotationDocType = new AnnotationDocType(); final String typeName = annotationDesc.annotationType().qualifiedName(); annotationDocType.setAnnotationTypeName(typeName); for (final ElementValuePair elementValuePair : annotationDesc.elementValues()) {
/** * Return true it there are any members to summarize. * * @return true if there are any members to summarize. */ public boolean hasMembersToDocument() { if (classDoc instanceof AnnotationTypeDoc) { return ((AnnotationTypeDoc) classDoc).elements().length > 0; } for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) { VisibleMemberMap members = visibleMemberMaps[i]; if (!members.noVisibleMembers()) { 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; }
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; }
/** * @param annotationType the annotation type being documented. * @param prevType the previous class that was documented. * @param nextType the next class being documented. */ public AnnotationTypeWriterImpl( AnnotationTypeDoc annotationType, Type prevType, Type nextType ) throws Exception { super( ConfigurationImpl.getInstance(), DirectoryManager.getDirectoryPath( annotationType.containingPackage() ), annotationType.name() + ".html", DirectoryManager.getRelativePath( annotationType.containingPackage().name() ) ); this.annotationType = annotationType; configuration.currentcd = annotationType.asClassDoc(); this.prev = prevType; this.next = nextType; }
/** * 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; }
annotationInstanceNode.setName(annotTypeInfo.name()); annotationInstanceNode.setQualified(annotTypeInfo.qualifiedTypeName()); } catch (ClassCastException castException) { log.error("Unable to obtain type data about an annotation found on: " + programElement);
if (annotationDesc.annotationType().qualifiedName().startsWith("restx.annotations.")) { Optional<Object> value = getAnnotationParamValue(annotationDesc.elementValues(), "value"); trace.trace(classDoc.name() + " > " + methodDoc.qualifiedName() + " > " + annotationDesc.annotationType().name()); trace.trace(asList(annotationDesc.elementValues()).toString()); trace.trace(methodDoc.commentText()); .setHttpMethod(annotationDesc.annotationType().name()) .setPath(String.valueOf(value.get())) .setNotes(methodDoc.commentText());
public void writeClassAnnotiations(ClassDoc classDoc, StringBuilder sb) { AnnotationDesc[] annotations = classDoc.annotations(); for (AnnotationDesc annotation : annotations) { sb.append("\t").append(annotation.annotationType().name()).append(" : \n"); writeAnnotationTable(annotation, sb); } }
/** * {@inheritDoc} */ public void writeHeader( String header ) { String pkgname = (annotationType.containingPackage() != null) ? annotationType.containingPackage().name() : ""; String clname = annotationType.name(); printHtmlHeader( clname, configuration.metakeywords.getMetaKeywords( annotationType ), true ); printTop(); navLinks( true ); println( "<!-- ======== START OF CLASS DATA ======== -->" ); if( pkgname.length() > 0 ) { font( "-1" ); print( pkgname ); fontEnd(); br(); } print( header + getTypeParameterLinks( new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false ) ) ); h2End(); }
Content liNavField = new HtmlTree(HtmlTag.LI); if (writerField != null){ writerField.addNavDetailLink(annotationType.fields().length > 0, liNavField); } else { liNavField.addContent(getResource("doclet.navField")); if (writerOptional != null){ Content liNavOpt = new HtmlTree(HtmlTag.LI); writerOptional.addNavDetailLink(annotationType.elements().length > 0, liNavOpt); ulNav.addContent(liNavOpt); } else if (writerRequired != null){ Content liNavReq = new HtmlTree(HtmlTag.LI); writerRequired.addNavDetailLink(annotationType.elements().length > 0, liNavReq); ulNav.addContent(liNavReq); } else {
/** * @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; }
/** * {@inheritDoc} */ public void writeAnnotationTypeDeprecationInfo() { hr(); Tag[] deprs = annotationType.tags( "deprecated" ); if( Util.isDeprecated( annotationType ) ) { strongText( "doclet.Deprecated" ); if( deprs.length > 0 ) { Tag[] commentTags = deprs[0].inlineTags(); if( commentTags.length > 0 ) { space(); printInlineDeprecatedComment( annotationType, deprs[0] ); } } p(); } }
/** * 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; }
/** * Build the header of the page. */ public void buildAnnotationTypeHeader() { writer.writeHeader( configuration.getText( "doclet.AnnotationType" ) + " " + annotationTypeDoc.name() ); }
/** * {@inheritDoc} */ public Content getHeader(String header) { String pkgname = (annotationType.containingPackage() != null)? annotationType.containingPackage().name(): ""; String clname = annotationType.name(); Content bodyTree = getBody(true, getWindowTitle(clname)); addTop(bodyTree); addNavLinks(true, bodyTree); bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.header); if (pkgname.length() > 0) { Content pkgNameContent = new StringContent(pkgname); Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent); div.addContent(pkgNameDiv); } LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_HEADER, annotationType); Content headerContent = new StringContent(header); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headerContent); heading.addContent(getTypeParameterLinks(linkInfo)); div.addContent(heading); bodyTree.addContent(div); return bodyTree; }
/** * @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; }
/** * {@inheritDoc} */ public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) { Content hr = new HtmlTree(HtmlTag.HR); annotationInfoTree.addContent(hr); Tag[] deprs = annotationType.tags("deprecated"); if (Util.isDeprecated(annotationType)) { Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel); if (deprs.length > 0) { Tag[] commentTags = deprs[0].inlineTags(); if (commentTags.length > 0) { div.addContent(getSpace()); addInlineDeprecatedComment(annotationType, deprs[0], div); } } annotationInfoTree.addContent(div); } }
static boolean hasAnnotation(MethodDoc methodDoc, Class cls) { for (AnnotationDesc annotationDesc : methodDoc.annotations()) { String qName = annotationDesc.annotationType().qualifiedTypeName(); if (qName.equals(cls.getCanonicalName())) { return true; } } return false; }