📄 javadoc.java
字号:
* @return tag argument to be configured */ public TagArgument createTag() { TagArgument ta = new TagArgument(); tags.addElement (ta); return ta; } /** * Scope element verbose names. (Defined here as fields * cannot be static in inner classes.) The first letter * from each element is used to build up the scope string. */ static final String[] SCOPE_ELEMENTS = { "overview", "packages", "types", "constructors", "methods", "fields" }; /** * Class representing a -tag argument. */ public class TagArgument extends FileSet { /** Name of the tag. */ private String name = null; /** Whether or not the tag is enabled. */ private boolean enabled = true; /** * Scope string of the tag. This will form the middle * argument of the -tag parameter when the tag is enabled * (with an X prepended for and is parsed from human-readable form. */ private String scope = "a"; /** Sole constructor. */ public TagArgument () { //empty } /** * Sets the name of the tag. * * @param name The name of the tag. * Must not be <code>null</code> or empty. */ public void setName (String name) { this.name = name; } /** * Sets the scope of the tag. This is in comma-separated * form, with each element being one of "all" (the default), * "overview", "packages", "types", "constructors", "methods", * "fields". The elements are treated in a case-insensitive * manner. * * @param verboseScope The scope of the tag. * Must not be <code>null</code>, * should not be empty. * * @exception BuildException if all is specified along with * other elements, if any elements are repeated, if no * elements are specified, or if any unrecognised elements are * specified. */ public void setScope (String verboseScope) throws BuildException { verboseScope = verboseScope.toLowerCase(Locale.US); boolean[] elements = new boolean[SCOPE_ELEMENTS.length]; boolean gotAll = false; boolean gotNotAll = false; // Go through the tokens one at a time, updating the // elements array and issuing warnings where appropriate. StringTokenizer tok = new StringTokenizer (verboseScope, ","); while (tok.hasMoreTokens()) { String next = tok.nextToken().trim(); if (next.equals("all")) { if (gotAll) { getProject().log ("Repeated tag scope element: all", Project.MSG_VERBOSE); } gotAll = true; } else { int i; for (i = 0; i < SCOPE_ELEMENTS.length; i++) { if (next.equals (SCOPE_ELEMENTS[i])) { break; } } if (i == SCOPE_ELEMENTS.length) { throw new BuildException ("Unrecognised scope element: " + next); } else { if (elements[i]) { getProject().log ("Repeated tag scope element: " + next, Project.MSG_VERBOSE); } elements[i] = true; gotNotAll = true; } } } if (gotNotAll && gotAll) { throw new BuildException ("Mixture of \"all\" and other scope " + "elements in tag parameter."); } if (!gotNotAll && !gotAll) { throw new BuildException ("No scope elements specified in tag " + "parameter."); } if (gotAll) { this.scope = "a"; } else { StringBuffer buff = new StringBuffer (elements.length); for (int i = 0; i < elements.length; i++) { if (elements[i]) { buff.append (SCOPE_ELEMENTS[i].charAt(0)); } } this.scope = buff.toString(); } } /** * Sets whether or not the tag is enabled. * * @param enabled Whether or not this tag is enabled. */ public void setEnabled (boolean enabled) { this.enabled = enabled; } /** * Returns the -tag parameter this argument represented. * @return the -tag parameter as a string * @exception BuildException if either the name or description * is <code>null</code> or empty. */ public String getParameter() throws BuildException { if (name == null || name.equals("")) { throw new BuildException ("No name specified for custom tag."); } if (getDescription() != null) { return name + ":" + (enabled ? "" : "X") + scope + ":" + getDescription(); } else if (!enabled || !"a".equals(scope)) { return name + ":" + (enabled ? "" : "X") + scope; } else { return name; } } } /** * Separates packages on the overview page into whatever * groups you specify, one group per table. * @return a group argument to be configured */ public GroupArgument createGroup() { GroupArgument ga = new GroupArgument(); groups.addElement(ga); return ga; } /** * A class corresponding to the group nested element. */ public class GroupArgument { private Html title; private Vector packages = new Vector(); /** Constructor for GroupArgument */ public GroupArgument() { //empty } /** * Set the title attribute using a string. * @param src a <code>String</code> value */ public void setTitle(String src) { Html h = new Html(); h.addText(src); addTitle(h); } /** * Set the title attribute using a nested Html value. * @param text a <code>Html</code> value */ public void addTitle(Html text) { title = text; } /** * Get the title. * @return the title */ public String getTitle() { return title != null ? title.getText() : null; } /** * Set the packages to Javadoc on. * @param src a comma separated list of packages */ public void setPackages(String src) { StringTokenizer tok = new StringTokenizer(src, ","); while (tok.hasMoreTokens()) { String p = tok.nextToken(); PackageName pn = new PackageName(); pn.setName(p); addPackage(pn); } } /** * Add a package nested element. * @param pn a nested element specifing the package. */ public void addPackage(PackageName pn) { packages.addElement(pn); } /** * Get the packages as a collon separated list. * @return the packages as a string */ public String getPackages() { StringBuffer p = new StringBuffer(); for (int i = 0; i < packages.size(); i++) { if (i > 0) { p.append(":"); } p.append(packages.elementAt(i).toString()); } return p.toString(); } } /** * Charset for cross-platform viewing of generated documentation. * @param src the name of the charset */ public void setCharset(String src) { this.addArgIfNotEmpty("-charset", src); } /** * Should the build process fail if Javadoc fails (as indicated by * a non zero return code)? * * <p>Default is false.</p> * @param b a <code>boolean</code> value */ public void setFailonerror(boolean b) { failOnError = b; } /** * Enables the -source switch, will be ignored if Javadoc is not * the 1.4 version. * @param source a <code>String</code> value * @since Ant 1.5 */ public void setSource(String source) { this.source = source; } /** * Sets the actual executable command to invoke, instead of the binary * <code>javadoc</code> found in Ant's JDK. * @param executable the command to invoke. * @since Ant 1.6.3 */ public void setExecutable(String executable) { this.executable = executable; } /** * Adds a packageset. * * <p>All included directories will be translated into package * names be converting the directory separator into dots.</p> * @param packageSet a directory set * @since 1.5 */ public void addPackageset(DirSet packageSet) { packageSets.addElement(packageSet); } /** * Adds a fileset. * * <p>All included files will be added as sourcefiles. The task * will automatically add * <code>includes="**/*.java"</code> to the * fileset.</p> * @param fs a file set * @since 1.5 */ public void addFileset(FileSet fs) { createSourceFiles().add(fs); } /** * Adds a container for resource collections. * * <p>All included files will be added as sourcefiles.</p> * @return the source files to configure. * @since 1.7 */ public ResourceCollectionContainer createSourceFiles() { return nestedSourceFiles; } /** * Enables the -linksource switch, will be ignored if Javadoc is not * the 1.4 version. Default is false * @param b a <code>String</code> value * @since Ant 1.6 */ public void setLinksource(boolean b) { this.linksource = b; } /** * Enables the -linksource switch, will be ignored if Javadoc is not * the 1.4 version. Default is false * @param b a <code>String</code> value * @since Ant 1.6 */ public void setBreakiterator(boolean b) { this.breakiterator = b; } /** * Enables the -noqualifier switch, will be ignored if Javadoc is not * the 1.4 version. * @param noqualifier the parameter to the -noqualifier switch * @since Ant 1.6 */ public void setNoqualifier(String noqualifier) { this.noqualifier = noqualifier; } /** * If set to true, Ant will also accept packages that only hold * package.html files but no Java sources. * @param b a <code>boolean</code> value. * @since Ant 1.6.3 */ public void setIncludeNoSourcePackages(boolean b) { this.includeNoSourcePackages = b; } /** * Execute the task. * @throws BuildException on error */ public void execute() throws BuildException { checkTaskName(); Vector packagesToDoc = new Vector(); Path sourceDirs = new Path(getProject()); checkPackageAndSourcePath(); if (sourcePath != null) { sourceDirs.addExisting(sourcePath); } parsePackages(packagesToDoc, sourceDirs); checkPackages(packagesToDoc, sourceDirs); Vector sourceFilesToDoc = (Vector) sourceFiles.clone(); addSourceFiles(sourceFilesToDoc); checkPackagesToDoc(packagesToDoc, sourceFilesToDoc); log("Generating Javadoc", Project.MSG_INFO); Commandline toExecute = (Commandline) cmd.clone(); if (executable != null) { toExecute.setExecutable(executable); } else { toExecute.setExecutable(JavaEnvUtils.getJdkExecutable("javadoc")); } // Javadoc arguments generalJavadocArguments(toExecute); // general Javadoc arguments doSourcePath(toExecute, sourceDirs); // sourcepath doDoclet(toExecute); // arguments for default doclet doBootPath(toExecute); // bootpath doLinks(toExecute); // links arguments doGroup(toExecute); // group attribute doGroups(toExecute); // groups attribute // Javadoc 1.4 parameters if (JAVADOC_4 || executable != null) { doJava14(toExecute); if (breakiterator && (doclet == null || JAVADOC_5)) { toExecute.createArgument().setValue("-breakiterator"); } } else { doNotJava14(); } // Javadoc 1.2/1.3 parameters: if (!JAVADOC_4 || executable != null) { if (old) { toExecute.createArgument().setValue("-1.1"); } } else { if (old) { log("Javadoc 1.4 doesn't support the -1.1 switch anymore", Project.MSG_WARN); } } // If using an external file, write the command line options to it if (useExternalFile && JAVADOC_4) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -