/**
   * Constructor.
   *
   * @param filename the file to be generated.
   * @throws IOException
   * @throws DocletAbortException
   */
  public PackageUseWriter(
      ConfigurationImpl configuration, ClassUseMapper mapper, DocPath filename, PackageDoc pkgdoc)
      throws IOException {
    super(configuration, DocPath.forPackage(pkgdoc).resolve(filename));
    this.pkgdoc = pkgdoc;

    // by examining all classes in this package, find what packages
    // use these classes - produce a map between using package and
    // used classes.
    ClassDoc[] content = pkgdoc.allClasses();
    for (int i = 0; i < content.length; ++i) {
      ClassDoc usedClass = content[i];
      Set<ClassDoc> usingClasses = mapper.classToClass.get(usedClass.qualifiedName());
      if (usingClasses != null) {
        for (Iterator<ClassDoc> it = usingClasses.iterator(); it.hasNext(); ) {
          ClassDoc usingClass = it.next();
          PackageDoc usingPackage = usingClass.containingPackage();
          Set<ClassDoc> usedClasses = usingPackageToUsedClasses.get(usingPackage.name());
          if (usedClasses == null) {
            usedClasses = new TreeSet<ClassDoc>();
            usingPackageToUsedClasses.put(Util.getPackageName(usingPackage), usedClasses);
          }
          usedClasses.add(usedClass);
        }
      }
    }
  }
Beispiel #2
0
  @SuppressWarnings("deprecation")
  public static Type resolveType(String typeName, ClassDoc klass, JAXDoclet<?> doclet) {
    log("resolving " + typeName + " in " + klass.qualifiedTypeName());
    // first look in inner classes
    for (ClassDoc innerClass : klass.innerClasses(false)) {
      if (innerClass.simpleTypeName().equals(typeName)) return innerClass;
    }
    // then the class itself
    if (klass.typeName().equals(typeName)) return klass;
    try {
      // then go through the named imports
      for (ClassDoc importedClass : klass.importedClasses()) {
        if (importedClass.typeName().equals(typeName)) return importedClass;
      }
      // then the package imports
      for (PackageDoc importedPackage : klass.importedPackages()) {
        for (ClassDoc importedClass : importedPackage.allClasses(false)) {
          if (importedClass.typeName().equals(typeName)) return importedClass;
        }
      }
    } catch (NullPointerException e) {

    }
    // now try FQDN
    Type type = doclet.forName(typeName);
    if (type != null) return type;
    log("resolving failed for " + typeName + " in " + klass.qualifiedTypeName());
    return null;
  }
 /**
  * Convert the Classes in the given Package to an HTML.
  *
  * @param pd the Package to convert.
  * @param outputdir the name of the directory to output to.
  */
 public void convertPackage(PackageDoc pd, DocPath outputdir) {
   if (pd == null) {
     return;
   }
   for (ClassDoc cd : pd.allClasses()) {
     // If -nodeprecated option is set and the class is marked as deprecated,
     // do not convert the package files to HTML. We do not check for
     // containing package deprecation since it is already check in
     // the calling method above.
     if (!(configuration.nodeprecated && utils.isDeprecated(cd))) convertClass(cd, outputdir);
   }
 }
 /**
  * Build the package serialized form for the current package being processed.
  *
  * @param node the XML element that specifies which components to document
  * @param serializedSummariesTree content tree to which the documentation will be added
  */
 public void buildPackageSerializedForm(XMLNode node, Content serializedSummariesTree) {
   Content packageSerializedTree = writer.getPackageSerializedHeader();
   String foo = currentPackage.name();
   ClassDoc[] classes = currentPackage.allClasses(false);
   if (classes == null || classes.length == 0) {
     return;
   }
   if (!serialInclude(currentPackage)) {
     return;
   }
   if (!serialClassFoundToDocument(classes)) {
     return;
   }
   buildChildren(node, packageSerializedTree);
   serializedSummariesTree.addContent(packageSerializedTree);
 }
 /**
  * Build the class serialized form.
  *
  * @param node the XML element that specifies which components to document
  * @param packageSerializedTree content tree to which the documentation will be added
  */
 public void buildClassSerializedForm(XMLNode node, Content packageSerializedTree) {
   Content classSerializedTree = writer.getClassSerializedHeader();
   ClassDoc[] classes = currentPackage.allClasses(false);
   Arrays.sort(classes);
   for (int j = 0; j < classes.length; j++) {
     currentClass = classes[j];
     fieldWriter = writer.getSerialFieldWriter(currentClass);
     methodWriter = writer.getSerialMethodWriter(currentClass);
     if (currentClass.isClass() && currentClass.isSerializable()) {
       if (!serialClassInclude(currentClass)) {
         continue;
       }
       Content classTree = writer.getClassHeader(currentClass);
       buildChildren(node, classTree);
       classSerializedTree.addContent(classTree);
     }
   }
   packageSerializedTree.addContent(classSerializedTree);
 }
 @Override
 protected Map<PLACE_HOLDER, String[]> getDetails(PackageDoc doc) {
   Map<PLACE_HOLDER, String[]> map = new HashMap<>();
   buildDetail(map, PLACE_HOLDER.PACKAGE_NAME, doc.name());
   buildDetail(map, PLACE_HOLDER.COMMENT, DocletUtil.renderComment(doc));
   StringBuffer sb = new StringBuffer();
   ClassDoc[] docs = doc.allClasses(false);
   if (docs != null) {
     for (ClassDoc classDoc : docs) {
       sb.append("<li>");
       sb.append("<a href=\"javascript:void(0);\" onclick=\"navigateTo('")
           .append(classDoc.qualifiedName())
           .append("');\">");
       sb.append(classDoc.qualifiedName()).append("</a>");
       sb.append("</li>");
     }
   }
   buildDetail(map, PLACE_HOLDER.CHILD_CLASSES, sb.toString());
   return map;
 }