/**
  * 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));
       }
     }
   }
 }
Esempio n. 2
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);
 }
  /**
   * 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);
        }
      }
    }
  }
 /**
  * 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);
   }
 }
Esempio n. 5
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;
   }
 }
Esempio n. 6
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());
   }
 }
 /**
  * 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);
 }
Esempio n. 8
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;
 }
Esempio n. 9
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"));
       }
     }
   }
 }
Esempio n. 10
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;
  }
 /**
  * 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;
 }
 /**
  * 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));
 }
Esempio n. 13
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 "";
 }
Esempio n. 14
0
  /**
   * 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;
  }
 /**
  * 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);
 }
Esempio n. 16
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);
 }
Esempio n. 18
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;
 }
  private static void scanClassDoc(List<ApiDoc> apiDocs, ClassDoc classDoc) {
    AnnotationDesc[] annDescs = classDoc.annotations();
    for (AnnotationDesc annDesc : annDescs) {
      if (IgnoreDocument.class.getName().equals(annDesc.annotationType().qualifiedTypeName()))
        return;
    }

    MethodDoc[] methodDocs = classDoc.methods();
    if (ArrayUtils.isNotEmpty(methodDocs)) {
      for (MethodDoc methodDoc : methodDocs) {
        ApiDoc apiDoc = scanMethodDoc(classDoc, methodDoc);
        if (apiDoc != null) apiDocs.add(apiDoc);
      }
    }

    ClassDoc[] innerClassDocs = classDoc.innerClasses();
    if (ArrayUtils.isNotEmpty(innerClassDocs)) {
      for (ClassDoc innerClassDoc : innerClassDocs) scanClassDoc(apiDocs, innerClassDoc);
    }
  }
 /**
  * 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);
   }
 }
 /**
  * Build the serial UID information for the given class.
  *
  * @param node the XML element that specifies which components to document
  * @param classTree content tree to which the serial UID information will be added
  */
 public void buildSerialUIDInfo(XMLNode node, Content classTree) {
   Content serialUidTree = writer.getSerialUIDInfoHeader();
   FieldDoc[] fields = currentClass.fields(false);
   for (int i = 0; i < fields.length; i++) {
     if (fields[i].name().equals("serialVersionUID")
         && fields[i].constantValueExpression() != null) {
       writer.addSerialUIDInfo(
           SERIAL_VERSION_UID_HEADER, fields[i].constantValueExpression(), serialUidTree);
       break;
     }
   }
   classTree.addContent(serialUidTree);
 }
Esempio n. 24
0
 private static void findAllInterfaceTypes(
     Map results, ClassDoc c, boolean raw, Configuration configuration) {
   Type superType = c.superclassType();
   if (superType == null) return;
   addAllInterfaceTypes(
       results,
       superType,
       superType instanceof ClassDoc
           ? ((ClassDoc) superType).interfaceTypes()
           : ((ParameterizedType) superType).interfaceTypes(),
       raw,
       configuration);
 }
Esempio n. 25
0
  /**
   * Parses the enum type definition
   *
   * @param docClass
   * @return
   */
  protected static Enum ParseEnum(ClassDoc docClass) {
    assert (docClass != null);

    Enum xmlEnum = new Enum();

    xmlEnum.name = docClass.name();
    xmlEnum.qualifiedName = docClass.qualifiedName();
    xmlEnum.comment = docClass.commentText();
    xmlEnum.isIncluded = docClass.isIncluded();
    xmlEnum.scope = DetermineScope(docClass);
    Type superClassType = docClass.superclassType();
    if (superClassType != null) {
      xmlEnum.superClass = superClassType.qualifiedTypeName();
    }

    Type[] interfaces = docClass.interfaceTypes();

    ArrayList<String> interfaceTypeNames = new ArrayList<String>();
    if (interfaces != null && interfaces.length > 0) {
      for (Type interfaceType : interfaces) {
        interfaceTypeNames.add(interfaceType.qualifiedTypeName());
      }
    }

    xmlEnum.extendedFrom = interfaceTypeNames.toArray(new String[] {});

    FieldDoc[] fields = docClass.enumConstants();

    if (fields != null && fields.length > 0) {
      ArrayList<EnumField> fieldList = new ArrayList<EnumField>();

      for (FieldDoc field : fields) {
        fieldList.add(ParseEnumField(field));
      }

      xmlEnum.fields = fieldList.toArray(new EnumField[] {});
    }

    xmlEnum.annotationInstances =
        ParseAnnotationInstances(docClass.annotations(), docClass.qualifiedName());
    return xmlEnum;
  }
Esempio n. 26
0
 /**
  * Given an array of <code>Tag</code>s representing this custom tag, return its string
  * representation.
  *
  * @param throwTags the array of <code>ThrowsTag</code>s to convert.
  * @param writer the TagletWriter that will write this tag.
  * @param alreadyDocumented the set of exceptions that have already been documented.
  * @param allowDups True if we allow duplicate throws tags to be documented.
  * @return the TagletOutput representation of this <code>Tag</code>.
  */
 protected TagletOutput throwsTagsOutput(
     ThrowsTag[] throwTags,
     TagletWriter writer,
     Set<String> alreadyDocumented,
     boolean allowDups) {
   TagletOutput result = writer.getOutputInstance();
   if (throwTags.length > 0) {
     for (int i = 0; i < throwTags.length; ++i) {
       ThrowsTag tt = throwTags[i];
       ClassDoc cd = tt.exception();
       if ((!allowDups)
           && (alreadyDocumented.contains(tt.exceptionName())
               || (cd != null && alreadyDocumented.contains(cd.qualifiedName())))) {
         continue;
       }
       if (alreadyDocumented.size() == 0) {
         result.appendOutput(writer.getThrowsHeader());
       }
       result.appendOutput(writer.throwsTagOutput(tt));
       alreadyDocumented.add(cd != null ? cd.qualifiedName() : tt.exceptionName());
     }
   }
   return result;
 }
Esempio n. 27
0
  public ThrowsTagImpl(String text, ClassDocImpl contextClass, MemberDocImpl contextMember) {
    super(text);

    char[] textarr = text.toCharArray();
    int i = 0;
    for (; i < textarr.length; ++i) {
      if (!Parser.isWhitespace(textarr[i])) break;
    }
    for (; i < textarr.length; ++i) {
      if (Parser.isWhitespace(textarr[i])) {
        this.exceptionName = new String(textarr, 0, i).trim();
        this.exceptionComment = new String(textarr, i, textarr.length - i).trim();
        break;
      }
    }
    if (null != exceptionName) {
      if (contextClass == null) {
        this.exception = Main.getRootDoc().classNamed(exceptionName);
      } else {
        this.exception = contextClass.findClass(exceptionName);
      }
      if (exception != null) this.exceptionName = exception.qualifiedName();
      else {
        if (text.trim().startsWith("<")) {
          Main.getRootDoc()
              .printWarning(
                  "Expected exception name but got '"
                      + text
                      + "' in class "
                      + contextClass.getClassName());
        }
      }
    } else {
      Main.getRootDoc()
          .printWarning(
              "@throws tag in comment for "
                  + contextClass.qualifiedName()
                  + "."
                  + contextMember.name()
                  + " doesn't specify an exception.");
    }
    if (this.exceptionComment != null) {
      setBody(this.exceptionComment, contextClass, contextMember);
    }
  }
Esempio n. 28
0
 /**
  * For the interface passed get the interfaces which it extends, and then put this interface in
  * the sub-interface list of those interfaces. Do it recursively. If a interface doesn't have
  * super-interface just attach that interface in the list of all the baseinterfaces.
  *
  * @param cd Interface under consideration.
  */
 private void processInterface(ClassDoc cd) {
   ClassDoc[] intfacs = cd.interfaces();
   if (intfacs.length > 0) {
     for (int i = 0; i < intfacs.length; i++) {
       if (!add(subinterfaces, intfacs[i], cd)) {
         return;
       } else {
         processInterface(intfacs[i]); // Recurse
       }
     }
   } else {
     // we need to add all the interfaces who do not have
     // super-interfaces to baseinterfaces list to traverse them
     if (!baseinterfaces.contains(cd)) {
       baseinterfaces.add(cd);
     }
   }
 }
Esempio n. 29
0
  /**
   * Add the given class to the given map.
   *
   * @param classdoc the ClassDoc to add to the catelog.
   * @param map the Map to add the ClassDoc to.
   */
  private void addClass(ClassDoc classdoc, Map<String, Set<ClassDoc>> map) {

    PackageDoc pkg = classdoc.containingPackage();
    if (pkg.isIncluded() || (configuration.nodeprecated && Util.isDeprecated(pkg))) {
      // No need to catalog this class if it's package is
      // included on the command line or if -nodeprecated option is set
      // and the containing package is marked as deprecated.
      return;
    }
    String key = Util.getPackageName(pkg);
    Set<ClassDoc> s = map.get(key);
    if (s == null) {
      packageSet.add(key);
      s = new HashSet<ClassDoc>();
    }
    s.add(classdoc);
    map.put(key, s);
  }
Esempio n. 30
0
  /**
   * Determinse if a specified class definition is a Annotation
   *
   * @param classDoc
   * @return
   */
  protected static boolean isAnnotation(ClassDoc classDoc) {
    boolean isAnnotation = false;
    if (classDoc != null) {
      Type[] types = classDoc.interfaceTypes();
      if (types != null) {
        for (Type type : types) {
          isAnnotation =
              0
                  == type.qualifiedTypeName()
                      .compareTo(java.lang.annotation.Annotation.class.getName());
          if (isAnnotation) {
            break;
          }
        }
      }
    }

    return isAnnotation;
  }