コード例 #1
0
 /**
  * Construct a new EnumConstantsBuilder.
  *
  * @param configuration the current configuration of the doclet.
  * @param classDoc the class whoses members are being documented.
  * @param writer the doclet specific writer.
  */
 public static EnumConstantBuilder getInstance(
     Configuration configuration, ClassDoc classDoc, EnumConstantWriter writer) {
   EnumConstantBuilder builder = new EnumConstantBuilder(configuration);
   builder.classDoc = classDoc;
   builder.writer = writer;
   builder.visibleMemberMap =
       new VisibleMemberMap(classDoc, VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated);
   builder.enumConstants =
       new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
   if (configuration.getMemberComparator() != null) {
     Collections.sort(builder.enumConstants, configuration.getMemberComparator());
   }
   return builder;
 }
コード例 #2
0
ファイル: Util.java プロジェクト: subxiang/jdk-source-code
 /** 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"));
       }
     }
   }
 }
コード例 #3
0
 /**
  * Construct a new FieldBuilder.
  *
  * @param configuration the current configuration of the doclet.
  * @param classDoc the class whoses members are being documented.
  * @param writer the doclet specific writer.
  */
 public static FieldBuilder getInstance(
     Configuration configuration, ClassDoc classDoc, FieldWriter writer) {
   FieldBuilder builder = new FieldBuilder(configuration);
   builder.classDoc = classDoc;
   builder.writer = writer;
   builder.visibleMemberMap =
       new VisibleMemberMap(classDoc, VisibleMemberMap.FIELDS, configuration.nodeprecated);
   builder.fields =
       new ArrayList<ProgramElementDoc>(
           builder.visibleMemberMap.getLeafClassMembers(configuration));
   if (configuration.getMemberComparator() != null) {
     Collections.sort(builder.fields, configuration.getMemberComparator());
   }
   return builder;
 }
コード例 #4
0
ファイル: Util.java プロジェクト: subxiang/jdk-source-code
 /**
  * Copy the given directory contents from the source package directory to the generated
  * documentation directory. For example for a package java.lang this method find out the source
  * location of the package using {@link SourcePath} and if given directory is found in the source
  * directory structure, copy the entire directory, to the generated documentation hierarchy.
  *
  * @param configuration The configuration of the current doclet.
  * @param path The relative path to the directory to be copied.
  * @param dir The original directory name to copy from.
  * @param overwrite Overwrite files if true.
  */
 public static void copyDocFiles(
     Configuration configuration, String path, String dir, boolean overwrite) {
   if (checkCopyDocFilesErrors(configuration, path, dir)) {
     return;
   }
   String destname = configuration.docFileDestDirName;
   File srcdir = new File(path + dir);
   if (destname.length() > 0 && !destname.endsWith(DirectoryManager.URL_FILE_SEPERATOR)) {
     destname += DirectoryManager.URL_FILE_SEPERATOR;
   }
   String dest = destname + dir;
   try {
     File destdir = new File(dest);
     DirectoryManager.createDirectory(configuration, dest);
     String[] files = srcdir.list();
     for (int i = 0; i < files.length; i++) {
       File srcfile = new File(srcdir, files[i]);
       File destfile = new File(destdir, files[i]);
       if (srcfile.isFile()) {
         if (destfile.exists() && !overwrite) {
           configuration.message.warning(
               (SourcePosition) null,
               "doclet.Copy_Overwrite_warning",
               srcfile.toString(),
               destdir.toString());
         } else {
           configuration.message.notice(
               "doclet.Copying_File_0_To_Dir_1", srcfile.toString(), destdir.toString());
           Util.copyFile(destfile, srcfile);
         }
       } else if (srcfile.isDirectory()) {
         if (configuration.copydocfilesubdirs
             && !configuration.shouldExcludeDocFileDir(srcfile.getName())) {
           copyDocFiles(
               configuration,
               path,
               dir + DirectoryManager.URL_FILE_SEPERATOR + srcfile.getName(),
               overwrite);
         }
       }
     }
   } catch (SecurityException exc) {
     throw new DocletAbortException();
   } catch (IOException exc) {
     throw new DocletAbortException();
   }
 }
コード例 #5
0
ファイル: Util.java プロジェクト: subxiang/jdk-source-code
 /**
  * Given a ClassDoc, return the name of its type (Class, Interface, etc.).
  *
  * @param cd the ClassDoc to check.
  * @param lowerCaseOnly true if you want the name returned in lower case. If false, the first
  *     letter of the name is capatilized.
  * @return
  */
 public static String getTypeName(Configuration config, ClassDoc cd, boolean lowerCaseOnly) {
   String typeName = "";
   if (cd.isOrdinaryClass()) {
     typeName = "doclet.Class";
   } else if (cd.isInterface()) {
     typeName = "doclet.Interface";
   } else if (cd.isException()) {
     typeName = "doclet.Exception";
   } else if (cd.isError()) {
     typeName = "doclet.Error";
   } else if (cd.isAnnotationType()) {
     typeName = "doclet.AnnotationType";
   } else if (cd.isEnum()) {
     typeName = "doclet.Enum";
   }
   return config.getText(lowerCaseOnly ? typeName.toLowerCase() : typeName);
 }
コード例 #6
0
ファイル: Util.java プロジェクト: subxiang/jdk-source-code
 /**
  * Return true if this class is linkable and false if we can't link to the desired class. <br>
  * <b>NOTE:</b> You can only link to external classes if they are public or protected.
  *
  * @param classDoc the class to check.
  * @param configuration the current configuration of the doclet.
  * @return true if this class is linkable and false if we can't link to the desired class.
  */
 public static boolean isLinkable(ClassDoc classDoc, Configuration configuration) {
   return ((classDoc.isIncluded() && configuration.isGeneratedDoc(classDoc)))
       || (configuration.extern.isExternal(classDoc)
           && (classDoc.isPublic() || classDoc.isProtected()));
 }