/**
   * 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);
        }
      }
    }
  }
 /**
  * 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);
 }
 /**
  * Return all of the classes specified on the command-line that belong to the given package.
  *
  * @param packageDoc the package to return the classes for.
  */
 public ClassDoc[] allClasses(PackageDoc pkgDoc) {
   return pkgDoc.isIncluded()
       ? pkgDoc.allClasses()
       : getArray(allClasses, Util.getPackageName(pkgDoc));
 }