/**
   * 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);
        }
      }
    }
  }
 /**
  * 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);
   }
 }