/**
   * Parses an annotation type definition
   *
   * @param docClass
   * @return
   */
  protected static Annotation ParseAnnotation(ClassDoc docClass) {
    AnnotationTypeDoc docAnnotation = (AnnotationTypeDoc) docClass;

    assert (docAnnotation != null);

    Annotation xmlAnnotation = new Annotation();

    xmlAnnotation.name = docClass.name();
    xmlAnnotation.qualifiedName = docClass.qualifiedName();
    xmlAnnotation.comment = docClass.commentText();
    xmlAnnotation.isIncluded = docClass.isIncluded();
    xmlAnnotation.scope = DetermineScope(docClass);

    AnnotationTypeElementDoc[] elements = docAnnotation.elements();

    if (elements != null && elements.length > 0) {
      ArrayList<AnnotationElement> elementList = new ArrayList<AnnotationElement>();

      for (AnnotationTypeElementDoc element : elements) {
        elementList.add(ParseAnnotationElement(element));
      }

      xmlAnnotation.elements = elementList.toArray(new AnnotationElement[] {});
    } else {
      log.debug("No elements in annotation: " + docClass.name());
    }

    xmlAnnotation.annotationInstances =
        ParseAnnotationInstances(docClass.annotations(), docClass.qualifiedName());
    return xmlAnnotation;
  }
 /** {@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;
 }
示例#3
0
 public static AnnotationDesc findAnnotation(
     final AnnotationDesc[] annotations, final String... soughtAnnotations) {
   for (final AnnotationDesc annotation : annotations) {
     final AnnotationTypeDoc annotationType = annotation.annotationType();
     for (final String soughtAnnotation : soughtAnnotations) {
       if (annotationType.qualifiedTypeName().equals(soughtAnnotation)) {
         return annotation;
       }
     }
   }
   return null;
 }
示例#4
0
 public static List<AnnotationDesc> findAnnotations(
     final AnnotationDesc[] annotations, final Class<?>... soughtAnnotations) {
   List<AnnotationDesc> ret = new LinkedList<AnnotationDesc>();
   for (final AnnotationDesc annotation : annotations) {
     final AnnotationTypeDoc annotationType = annotation.annotationType();
     for (final Class<?> soughtAnnotation : soughtAnnotations) {
       if (annotationType.qualifiedTypeName().equals(soughtAnnotation.getName())) {
         ret.add(annotation);
       }
     }
   }
   return ret;
 }
 /** {@inheritDoc} */
 public void addAnnotationTypeDescription(Content annotationInfoTree) {
   if (!configuration.nocomment) {
     if (annotationType.inlineTags().length > 0) {
       addInlineComment(annotationType, annotationInfoTree);
     }
   }
 }
 /** Copy the doc files for the current ClassDoc if necessary. */
 private void copyDocFiles() {
   PackageDoc containingPackage = annotationTypeDoc.containingPackage();
   if ((configuration.packages == null
           || Arrays.binarySearch(configuration.packages, containingPackage) < 0)
       && !containingPackagesSeen.contains(containingPackage.name())) {
     // Only copy doc files dir if the containing package is not
     // documented AND if we have not documented a class from the same
     // package already. Otherwise, we are making duplicate copies.
     Util.copyDocFiles(
         configuration,
         Util.getPackageSourcePath(configuration, annotationTypeDoc.containingPackage())
             + DirectoryManager.getDirectoryPath(annotationTypeDoc.containingPackage())
             + File.separator,
         DocletConstants.DOC_FILES_DIR_NAME,
         true);
     containingPackagesSeen.add(containingPackage.name());
   }
 }
示例#7
0
 /**
  * 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 annotation type documentation.
  *
  * @param node the XML element that specifies which components to document
  * @param contentTree the content tree to which the documentation will be added
  */
 public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception {
   contentTree =
       writer.getHeader(
           configuration.getText("doclet.AnnotationType") + " " + annotationTypeDoc.name());
   Content annotationContentTree = writer.getAnnotationContentHeader();
   buildChildren(node, annotationContentTree);
   contentTree.addContent(annotationContentTree);
   writer.addFooter(contentTree);
   writer.printDocument(contentTree);
   writer.close();
   copyDocFiles();
 }
 /**
  * @param annotationType the annotation type being documented.
  * @param prevType the previous class that was documented.
  * @param nextType the next class being documented.
  */
 public AnnotationTypeWriterImpl(
     ConfigurationImpl configuration,
     AnnotationTypeDoc annotationType,
     Type prevType,
     Type nextType)
     throws Exception {
   super(configuration, DocPath.forClass(annotationType));
   this.annotationType = annotationType;
   configuration.currentcd = annotationType.asClassDoc();
   this.prev = prevType;
   this.next = nextType;
 }
 /**
  * Get detail links for the navigation bar.
  *
  * @return the content tree for the detail links
  */
 protected Content getNavDetailLinks() throws Exception {
   Content li = HtmlTree.LI(detailLabel);
   li.addContent(getSpace());
   Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
   MemberSummaryBuilder memberSummaryBuilder =
       (MemberSummaryBuilder) configuration.getBuilderFactory().getMemberSummaryBuilder(this);
   AbstractMemberWriter writerField =
       ((AbstractMemberWriter)
           memberSummaryBuilder.getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_FIELDS));
   AbstractMemberWriter writerOptional =
       ((AbstractMemberWriter)
           memberSummaryBuilder.getMemberSummaryWriter(
               VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL));
   AbstractMemberWriter writerRequired =
       ((AbstractMemberWriter)
           memberSummaryBuilder.getMemberSummaryWriter(
               VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED));
   Content liNavField = new HtmlTree(HtmlTag.LI);
   if (writerField != null) {
     writerField.addNavDetailLink(annotationType.fields().length > 0, liNavField);
   } else {
     liNavField.addContent(getResource("doclet.navField"));
   }
   addNavGap(liNavField);
   ulNav.addContent(liNavField);
   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 {
     Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
     ulNav.addContent(liNav);
   }
   return ulNav;
 }
 /** {@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);
   }
 }
 /** {@inheritDoc} */
 public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
   annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
   Content pre = new HtmlTree(HtmlTag.PRE);
   addAnnotationInfo(annotationType, pre);
   pre.addContent(modifiers);
   LinkInfoImpl linkInfo =
       new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
   Content annotationName = new StringContent(annotationType.name());
   Content parameterLinks = getTypeParameterLinks(linkInfo);
   if (configuration.linksource) {
     addSrcLink(annotationType, annotationName, pre);
     pre.addContent(parameterLinks);
   } else {
     Content span = HtmlTree.SPAN(HtmlStyle.memberNameLabel, annotationName);
     span.addContent(parameterLinks);
     pre.addContent(span);
   }
   annotationInfoTree.addContent(pre);
 }
 /**
  * Build the signature of the current annotation type.
  *
  * @param node the XML element that specifies which components to document
  * @param annotationInfoTree the content tree to which the documentation will be added
  */
 public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) {
   StringBuffer modifiers = new StringBuffer(annotationTypeDoc.modifiers() + " ");
   writer.addAnnotationTypeSignature(
       Util.replaceText(modifiers.toString(), "interface", "@interface"), annotationInfoTree);
 }
 boolean isBusinessMeaningful(final AnnotationTypeDoc annotationType) {
   return annotationType.qualifiedTypeName().contains("livingdocs");
 }