/**
   * 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);
        }
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * Get the name of the package, this class is in.
  *
  * @param cd ClassDoc.
  */
 public String getPkgName(ClassDoc cd) {
   String pkgName = cd.containingPackage().name();
   if (pkgName.length() > 0) {
     pkgName += ".";
     return pkgName;
   }
   return "";
 }
 void generate() {
   if (rootDoc == null || outputdir == null) {
     return;
   }
   for (PackageDoc pd : rootDoc.specifiedPackages()) {
     // If -nodeprecated option is set and the package is marked as deprecated,
     // do not convert the package files to HTML.
     if (!(configuration.nodeprecated && utils.isDeprecated(pd))) convertPackage(pd, outputdir);
   }
   for (ClassDoc cd : rootDoc.specifiedClasses()) {
     // If -nodeprecated option is set and the class is marked as deprecated
     // or the containing package is deprecated, do not convert the
     // package files to HTML.
     if (!(configuration.nodeprecated
         && (utils.isDeprecated(cd) || utils.isDeprecated(cd.containingPackage()))))
       convertClass(cd, outputdir);
   }
 }