/**
  * Build the summaries for the methods that belong to the given class.
  *
  * @param node the XML element that specifies which components to document
  * @param classContentTree content tree to which the documentation will be added
  */
 public void buildSerializableMethods(XMLNode node, Content classContentTree) {
   Content serializableMethodTree = methodWriter.getSerializableMethodsHeader();
   MemberDoc[] members = currentClass.serializationMethods();
   int membersLength = members.length;
   if (membersLength > 0) {
     for (int i = 0; i < membersLength; i++) {
       currentMember = members[i];
       Content methodsContentTree = methodWriter.getMethodsContentHeader((i == membersLength - 1));
       buildChildren(node, methodsContentTree);
       serializableMethodTree.addContent(methodsContentTree);
     }
   }
   if (currentClass.serializationMethods().length > 0) {
     classContentTree.addContent(
         methodWriter.getSerializableMethods(
             configuration.getText("doclet.Serialized_Form_methods"), serializableMethodTree));
     if (currentClass.isSerializable() && !currentClass.isExternalizable()) {
       if (currentClass.serializationMethods().length == 0) {
         Content noCustomizationMsg =
             methodWriter.getNoCustomizationMsg(
                 configuration.getText("doclet.Serializable_no_customization"));
         classContentTree.addContent(
             methodWriter.getSerializableMethods(
                 configuration.getText("doclet.Serialized_Form_methods"), noCustomizationMsg));
       }
     }
   }
 }
  /**
   * 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);
        }
      }
    }
  }
 protected void write(OutputStream o, ClassDoc clazz) throws ClassNotFoundException {
   String cname = mangleClassName(clazz.qualifiedName());
   PrintWriter pw = wrapWriter(o);
   fields = clazz.fields();
   methods = clazz.methods();
   generateDeclsForClass(pw, clazz, cname);
 }
Example #4
0
 private static void addAllInterfaceTypes(
     Map<ClassDoc, Type> results,
     Type type,
     Type[] interfaceTypes,
     boolean raw,
     Configuration configuration) {
   for (int i = 0; i < interfaceTypes.length; i++) {
     Type interfaceType = interfaceTypes[i];
     ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
     if (!(interfaceClassDoc.isPublic()
         || (configuration != null && isLinkable(interfaceClassDoc, configuration)))) {
       continue;
     }
     if (raw) interfaceType = interfaceType.asClassDoc();
     results.put(interfaceClassDoc, interfaceType);
     List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration);
     for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
       Type superInterface = iter.next();
       results.put(superInterface.asClassDoc(), superInterface);
     }
   }
   if (type instanceof ParameterizedType)
     findAllInterfaceTypes(results, (ParameterizedType) type, configuration);
   else if (((ClassDoc) type).typeParameters().length == 0)
     findAllInterfaceTypes(results, (ClassDoc) type, raw, configuration);
   else findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
 }
 /**
  * Add use information to the documentation tree.
  *
  * @param mems list of program elements for which the use information will be added
  * @param heading the section heading
  * @param tableSummary the summary for the use table
  * @param contentTree the content tree to which the use information will be added
  */
 protected void addUseInfo(
     List<? extends ProgramElementDoc> mems,
     Content heading,
     String tableSummary,
     Content contentTree) {
   if (mems == null) {
     return;
   }
   List<? extends ProgramElementDoc> members = mems;
   boolean printedUseTableHeader = false;
   if (members.size() > 0) {
     Content caption = writer.getTableCaption(heading);
     Content table =
         (configuration.isOutputHtml5())
             ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
             : HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption);
     Content tbody = new HtmlTree(HtmlTag.TBODY);
     Iterator<? extends ProgramElementDoc> it = members.iterator();
     for (int i = 0; it.hasNext(); i++) {
       ProgramElementDoc pgmdoc = it.next();
       ClassDoc cd = pgmdoc.containingClass();
       if (!printedUseTableHeader) {
         table.addContent(writer.getSummaryTableHeader(this.getSummaryTableHeader(pgmdoc), "col"));
         printedUseTableHeader = true;
       }
       HtmlTree tr = new HtmlTree(HtmlTag.TR);
       if (i % 2 == 0) {
         tr.addStyle(HtmlStyle.altColor);
       } else {
         tr.addStyle(HtmlStyle.rowColor);
       }
       HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
       tdFirst.addStyle(HtmlStyle.colFirst);
       writer.addSummaryType(this, pgmdoc, tdFirst);
       tr.addContent(tdFirst);
       HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
       tdLast.addStyle(HtmlStyle.colLast);
       if (cd != null && !(pgmdoc instanceof ConstructorDoc) && !(pgmdoc instanceof ClassDoc)) {
         HtmlTree name = new HtmlTree(HtmlTag.SPAN);
         name.addStyle(HtmlStyle.typeNameLabel);
         name.addContent(cd.name() + ".");
         tdLast.addContent(name);
       }
       addSummaryLink(
           pgmdoc instanceof ClassDoc ? LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER,
           cd,
           pgmdoc,
           tdLast);
       writer.addSummaryLinkComment(this, pgmdoc, tdLast);
       tr.addContent(tdLast);
       tbody.addContent(tr);
     }
     table.addContent(tbody);
     contentTree.addContent(table);
   }
 }
Example #6
0
 /**
  * Return the sub-class/interface list for the class/interface passed.
  *
  * @param cd class/interface whose sub-class/interface list is required.
  * @param isEnum true if the subclasses should be forced to come from the enum tree.
  */
 public List subs(ClassDoc cd, boolean isEnum) {
   if (isEnum) {
     return get(subEnums, cd);
   } else if (cd.isAnnotationType()) {
     return get(subAnnotationTypes, cd);
   } else if (cd.isInterface()) {
     return get(subinterfaces, cd);
   } else if (cd.isClass()) {
     return get(subclasses, cd);
   } else {
     return null;
   }
 }
 protected void process(ClassDoc clss) {
   writer.println("");
   writer.println("## *" + clss.simpleTypeName() + "*");
   writer.println(clss.commentText());
   writer.println("");
   if (clss.isEnum()) {
     for (FieldDoc field : clss.enumConstants()) {
       printEnumConstant(field);
     }
     writer.println("");
     for (MethodDoc method : clss.methods(false)) {
       printMethod(method);
     }
   } else if (clss.isInterface()) {
     /*
     for (ClassDoc subClass : getDerivedClassessubclasses( clss ))
     {
         printSubClass(subClass);
     }
     */
   } else {
     for (FieldDoc field : clss.fields(false)) {
       printField(field);
     }
     for (MethodDoc method : clss.methods(false)) {
       printMethod(method);
     }
   }
 }
 /**
  * Build the field information.
  *
  * @param node the XML element that specifies which components to document
  * @param fieldsContentTree content tree to which the documentation will be added
  */
 public void buildFieldInfo(XMLNode node, Content fieldsContentTree) {
   if (configuration.nocomment) {
     return;
   }
   FieldDoc field = (FieldDoc) currentMember;
   ClassDoc cd = field.containingClass();
   // Process default Serializable field.
   if ((field.tags("serial").length == 0) && !field.isSynthetic() && configuration.serialwarn) {
     configuration.message.warning(
         field.position(), "doclet.MissingSerialTag", cd.qualifiedName(), field.name());
   }
   fieldWriter.addMemberDescription(field, fieldsContentTree);
   fieldWriter.addMemberTags(field, fieldsContentTree);
 }
Example #9
0
 /**
  * Given an array of <code>ParamTag</code>s,return its string representation.
  *
  * @param holder the member that holds the param tags.
  * @param writer the TagletWriter that will write this tag.
  * @return the TagletOutput representation of these <code>ParamTag</code>s.
  */
 public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
   if (holder instanceof ExecutableMemberDoc) {
     ExecutableMemberDoc member = (ExecutableMemberDoc) holder;
     TagletOutput output =
         getTagletOutput(false, member, writer, member.typeParameters(), member.typeParamTags());
     output.appendOutput(
         getTagletOutput(true, member, writer, member.parameters(), member.paramTags()));
     return output;
   } else {
     ClassDoc classDoc = (ClassDoc) holder;
     return getTagletOutput(
         false, classDoc, writer, classDoc.typeParameters(), classDoc.typeParamTags());
   }
 }
Example #10
0
 /**
  * Given a class, return the closest visible super class.
  *
  * @param classDoc the class we are searching the parent for.
  * @param configuration the current configuration of the doclet.
  * @return the closest visible super class. Return null if it cannot be found (i.e. classDoc is
  *     java.lang.Object).
  */
 public static ClassDoc getFirstVisibleSuperClassCD(
     ClassDoc classDoc, Configuration configuration) {
   if (classDoc == null) {
     return null;
   }
   ClassDoc supClassDoc = classDoc.superclass();
   while (supClassDoc != null
       && (!(supClassDoc.isPublic() || isLinkable(supClassDoc, configuration)))) {
     supClassDoc = supClassDoc.superclass();
   }
   if (classDoc.equals(supClassDoc)) {
     return null;
   }
   return supClassDoc;
 }
Example #11
0
 /** The documentation for values() and valueOf() in Enums are set by the doclet. */
 public static void setEnumDocumentation(Configuration configuration, ClassDoc classDoc) {
   MethodDoc[] methods = classDoc.methods();
   for (int j = 0; j < methods.length; j++) {
     MethodDoc currentMethod = methods[j];
     if (currentMethod.name().equals("values") && currentMethod.parameters().length == 0) {
       currentMethod.setRawCommentText(
           configuration.getText("doclet.enum_values_doc", classDoc.name()));
     } else if (currentMethod.name().equals("valueOf") && currentMethod.parameters().length == 1) {
       Type paramType = currentMethod.parameters()[0].type();
       if (paramType != null && paramType.qualifiedTypeName().equals(String.class.getName())) {
         currentMethod.setRawCommentText(configuration.getText("doclet.enum_valueof_doc"));
       }
     }
   }
 }
Example #12
0
  protected void generateDeclsForClass(PrintWriter pw, ClassDoc clazz, String cname)
      throws ClassNotFoundException {
    doneHandleTypes = new Hashtable();
    /* The following handle types are predefined in "typedefs.h". Suppress
    inclusion in the output by generating them "into the blue" here. */
    genHandleType(null, "java.lang.Class");
    genHandleType(null, "java.lang.ClassLoader");
    genHandleType(null, "java.lang.Object");
    genHandleType(null, "java.lang.String");
    genHandleType(null, "java.lang.Thread");
    genHandleType(null, "java.lang.ThreadGroup");
    genHandleType(null, "java.lang.Throwable");

    pw.println("/* LLNI Header for class " + clazz.qualifiedName() + " */" + lineSep);
    pw.println("#ifndef _Included_" + cname);
    pw.println("#define _Included_" + cname);
    pw.println("#include \"typedefs.h\"");
    pw.println("#include \"llni.h\"");
    pw.println("#include \"jni.h\"" + lineSep);

    forwardDecls(pw, clazz);
    structSectionForClass(pw, clazz, cname);
    methodSectionForClass(pw, clazz, cname);
    pw.println("#endif");
  }
Example #13
0
 FieldDefsRes(ClassDoc clazz, FieldDefsRes parent, boolean bottomMost) {
   this.className = clazz.qualifiedName();
   this.parent = parent;
   this.bottomMost = bottomMost;
   int byteSize = 0;
   if (parent == null) this.s = "";
   else this.s = parent.s;
 }
 /**
  * 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 "";
 }
Example #15
0
  /**
   * For the class return all implemented interfaces including the superinterfaces of the
   * implementing interfaces, also iterate over for all the superclasses. For interface return all
   * the extended interfaces as well as superinterfaces for those extended interfaces.
   *
   * @param type type whose implemented or super interfaces are sought.
   * @param configuration the current configuration of the doclet.
   * @param sort if true, return list of interfaces sorted alphabetically.
   * @return List of all the required interfaces.
   */
  public static List<Type> getAllInterfaces(Type type, Configuration configuration, boolean sort) {
    Map<ClassDoc, Type> results =
        sort ? new TreeMap<ClassDoc, Type>() : new LinkedHashMap<ClassDoc, Type>();
    Type[] interfaceTypes = null;
    Type superType = null;
    if (type instanceof ParameterizedType) {
      interfaceTypes = ((ParameterizedType) type).interfaceTypes();
      superType = ((ParameterizedType) type).superclassType();
    } else if (type instanceof ClassDoc) {
      interfaceTypes = ((ClassDoc) type).interfaceTypes();
      superType = ((ClassDoc) type).superclassType();
    } else {
      interfaceTypes = type.asClassDoc().interfaceTypes();
      superType = type.asClassDoc().superclassType();
    }

    for (int i = 0; i < interfaceTypes.length; i++) {
      Type interfaceType = interfaceTypes[i];
      ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
      if (!(interfaceClassDoc.isPublic()
          || (configuration == null || isLinkable(interfaceClassDoc, configuration)))) {
        continue;
      }
      results.put(interfaceClassDoc, interfaceType);
      List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration, sort);
      for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
        Type t = iter.next();
        results.put(t.asClassDoc(), t);
      }
    }
    if (superType == null) return new ArrayList<Type>(results.values());
    // Try walking the tree.
    addAllInterfaceTypes(
        results,
        superType,
        superType instanceof ClassDoc
            ? ((ClassDoc) superType).interfaceTypes()
            : ((ParameterizedType) superType).interfaceTypes(),
        false,
        configuration);
    List<Type> resultsList = new ArrayList<Type>(results.values());
    if (sort) {
      Collections.sort(resultsList, new TypeComparator());
    }
    return resultsList;
  }
 /**
  * Get the tree link.
  *
  * @return a content tree for the tree link
  */
 protected Content getNavLinkTree() {
   Content linkContent =
       classdoc.containingPackage().isIncluded()
           ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel)
           : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel);
   Content li = HtmlTree.LI(linkContent);
   return li;
 }
 /**
  * Add the navigation summary link.
  *
  * @param members members to be linked
  * @param visibleMemberMap the visible inherited members map
  * @param liNav the content tree to which the navigation summary link will be added
  */
 protected void addNavSummaryLink(
     List<?> members, VisibleMemberMap visibleMemberMap, Content liNav) {
   if (members.size() > 0) {
     liNav.addContent(getNavSummaryLink(null, true));
     return;
   }
   ClassDoc icd = classdoc.superclass();
   while (icd != null) {
     List<?> inhmembers = visibleMemberMap.getMembersFor(icd);
     if (inhmembers.size() > 0) {
       liNav.addContent(getNavSummaryLink(icd, true));
       return;
     }
     icd = icd.superclass();
   }
   liNav.addContent(getNavSummaryLink(null, false));
 }
 /**
  * Write out class use pages.
  *
  * @throws DocletAbortException
  */
 public static void generate(ConfigurationImpl configuration, ClassTree classtree) {
   ClassUseMapper mapper = new ClassUseMapper(configuration.root, classtree);
   for (ClassDoc aClass : configuration.root.classes()) {
     // If -nodeprecated option is set and the containing package is marked
     // as deprecated, do not generate the class-use page. We will still generate
     // the class-use page if the class is marked as deprecated but the containing
     // package is not since it could still be linked from that package-use page.
     if (!(configuration.nodeprecated && Util.isDeprecated(aClass.containingPackage())))
       ClassUseWriter.generate(configuration, mapper, aClass);
   }
   for (PackageDoc pkg : configuration.packages) {
     // If -nodeprecated option is set and the package is marked
     // as deprecated, do not generate the package-use page.
     if (!(configuration.nodeprecated && Util.isDeprecated(pkg)))
       PackageUseWriter.generate(configuration, mapper, pkg);
   }
 }
 /**
  * Return true if the given <code>ProgramElement</code> is inherited by the class that is being
  * documented.
  *
  * @param ped The <code>ProgramElement</code> being checked. return true if the <code>
  *     ProgramElement</code> is being inherited and false otherwise.
  */
 protected boolean isInherited(ProgramElementDoc ped) {
   if (ped.isPrivate()
       || (ped.isPackagePrivate()
           && !ped.containingPackage().equals(classdoc.containingPackage()))) {
     return false;
   }
   return true;
 }
  /**
   * 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;
  }
 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);
   }
 }
 /**
  * Get the header for the class use Listing.
  *
  * @return a content tree representing the class use header
  */
 protected Content getClassUseHeader() {
   String cltype =
       configuration.getText(classdoc.isInterface() ? "doclet.Interface" : "doclet.Class");
   String clname = classdoc.qualifiedName();
   String title = configuration.getText("doclet.Window_ClassUse_Header", cltype, clname);
   Content bodyTree = getBody(true, getWindowTitle(title));
   addTop(bodyTree);
   addNavLinks(true, bodyTree);
   ContentBuilder headContent = new ContentBuilder();
   headContent.addContent(getResource("doclet.ClassUse_Title", cltype));
   headContent.addContent(new HtmlTree(HtmlTag.BR));
   headContent.addContent(clname);
   Content heading =
       HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headContent);
   Content div = HtmlTree.DIV(HtmlStyle.header, heading);
   bodyTree.addContent(div);
   return bodyTree;
 }
 /**
  * Add a row for the class that uses the given package.
  *
  * @param usedClass the class that uses the given package
  * @param packageName the name of the package to which the class belongs
  * @param contentTree the content tree to which the row will be added
  */
 protected void addClassRow(ClassDoc usedClass, String packageName, Content contentTree) {
   DocPath dp = pathString(usedClass, DocPaths.CLASS_USE.resolve(DocPath.forName(usedClass)));
   Content td =
       HtmlTree.TD(
           HtmlStyle.colOne,
           getHyperLink(dp.fragment(packageName), new StringContent(usedClass.name())));
   addIndexComment(usedClass, td);
   contentTree.addContent(td);
 }
Example #24
0
 /**
  * Search for the given method in the given class.
  *
  * @param cd Class to search into.
  * @param method Method to be searched.
  * @return MethodDoc Method found, null otherwise.
  */
 public static MethodDoc findMethod(ClassDoc cd, MethodDoc method) {
   MethodDoc[] methods = cd.methods();
   for (int i = 0; i < methods.length; i++) {
     if (executableMembersEqual(method, methods[i])) {
       return methods[i];
     }
   }
   return null;
 }
 /**
  * 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);
 }
Example #26
0
 /**
  * Given a class, return the closest visible super class.
  *
  * @param classDoc the class we are searching the parent for.
  * @param configuration the current configuration of the doclet.
  * @return the closest visible super class. Return null if it cannot be found (i.e. classDoc is
  *     java.lang.Object).
  */
 public static Type getFirstVisibleSuperClass(ClassDoc classDoc, Configuration configuration) {
   if (classDoc == null) {
     return null;
   }
   Type sup = classDoc.superclassType();
   ClassDoc supClassDoc = classDoc.superclass();
   while (sup != null && (!(supClassDoc.isPublic() || isLinkable(supClassDoc, configuration)))) {
     if (supClassDoc.superclass().qualifiedName().equals(supClassDoc.qualifiedName())) break;
     sup = supClassDoc.superclassType();
     supClassDoc = supClassDoc.superclass();
   }
   if (classDoc.equals(supClassDoc)) {
     return null;
   }
   return sup;
 }
Example #27
0
  protected FieldDefsRes fieldDefs(ClassDoc clazz, String cname, boolean bottomMost)
      throws ClassNotFoundException {
    FieldDefsRes res;
    int offset;
    boolean didTwoWordFields = false;
    ClassDoc superclazz = clazz.superclass();

    if (superclazz != null) {
      String supername = superclazz.qualifiedName();
      res = new FieldDefsRes(clazz, fieldDefs(superclazz, cname, false), bottomMost);
      offset = res.parent.byteSize;
    } else {
      res = new FieldDefsRes(clazz, null, bottomMost);
      offset = 0;
    }

    FieldDoc[] fields = clazz.fields();

    for (int i = 0; i < fields.length; i++) {
      FieldDoc field = fields[i];

      if (doubleAlign && !didTwoWordFields && (offset % 8) == 0) {
        offset = doTwoWordFields(res, clazz, offset, cname, false);
        didTwoWordFields = true;
      }

      String tc = field.type().typeName();
      boolean twoWords = (tc.equals("long") || tc.equals("double"));

      if (!doubleAlign || !twoWords) {
        if (doField(res, field, cname, false)) offset += 4;
      }
    }

    if (doubleAlign && !didTwoWordFields) {
      if ((offset % 8) != 0) offset += 4;
      offset = doTwoWordFields(res, clazz, offset, cname, true);
    }

    res.byteSize = offset;
    return res;
  }
 /**
  * Build the serialization overview for the given class.
  *
  * @param classDoc the class to print the overview for.
  * @param classContentTree content tree to which the documentation will be added
  */
 public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
   if (classDoc.definesSerializableFields()) {
     FieldDoc serialPersistentField = classDoc.serializableFields()[0];
     // Check to see if there are inline comments, tags or deprecation
     // information to be printed.
     if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
       Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
       Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
       fieldWriter.addMemberDeprecatedInfo(serialPersistentField, fieldsOverviewContentTree);
       if (!configuration.nocomment) {
         fieldWriter.addMemberDescription(serialPersistentField, fieldsOverviewContentTree);
         fieldWriter.addMemberTags(serialPersistentField, fieldsOverviewContentTree);
       }
       serializableFieldsTree.addContent(fieldsOverviewContentTree);
       classContentTree.addContent(
           fieldWriter.getSerializableFields(
               configuration.getText("doclet.Serialized_Form_class"), serializableFieldsTree));
     }
   }
 }
 /**
  * Build the summaries for the fields that belong to the given class.
  *
  * @param node the XML element that specifies which components to document
  * @param classContentTree content tree to which the documentation will be added
  */
 public void buildSerializableFields(XMLNode node, Content classContentTree) {
   MemberDoc[] members = currentClass.serializableFields();
   int membersLength = members.length;
   if (membersLength > 0) {
     Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
     for (int i = 0; i < membersLength; i++) {
       currentMember = members[i];
       if (!currentClass.definesSerializableFields()) {
         Content fieldsContentTree = fieldWriter.getFieldsContentHeader((i == membersLength - 1));
         buildChildren(node, fieldsContentTree);
         serializableFieldsTree.addContent(fieldsContentTree);
       } else {
         buildSerialFieldTagsInfo(serializableFieldsTree);
       }
     }
     classContentTree.addContent(
         fieldWriter.getSerializableFields(
             configuration.getText("doclet.Serialized_Form_fields"), serializableFieldsTree));
   }
 }
 /**
  * Build the field sub header.
  *
  * @param node the XML element that specifies which components to document
  * @param fieldsContentTree content tree to which the documentation will be added
  */
 public void buildFieldSubHeader(XMLNode node, Content fieldsContentTree) {
   if (!currentClass.definesSerializableFields()) {
     FieldDoc field = (FieldDoc) currentMember;
     fieldWriter.addMemberHeader(
         field.type().asClassDoc(),
         field.type().typeName(),
         field.type().dimension(),
         field.name(),
         fieldsContentTree);
   }
 }