java character tomust be escapedd is missing 怎么办

Generates HTML pages of API documentation from Java source files.
javadoc {packages|source-files} [options] [@argfiles]
Names of packages that you want to document, separated by spaces, for example java.lang java.lang.reflect java.awt. If you want to also document the subpackages, use the -subpackages option to specify the packages.
By default, javadoc looks for the specified packages in the current directory and subdirectories. Use the -sourcepath option to specify the list of directories where to look for packages.
source-files
Names of Java source files that you want to document, separated by spaces, for example Class.java Object.java Button.java. By default, javadoc looks for the specified classes in the current directory. However, you can specify the full path to the class file and use wildcard characters, for example /home/src/java/awt/Graphics*.java. You can also specify the path relative to the current directory.
Command-line options, separated by spaces. See Options.
Names of files that contain a list of javadoc command options, package names and source file names in any order.
Description
The javadoc command parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages that describe (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields. You can use the javadoc command to generate the API documentation or the implementation documentation for a set of source files.
You can run the javadoc command on entire packages, individual source files, or both. When documenting entire packages, you can either use the -subpackages option to recursively traverse a directory and its subdirectories, or to pass in an explicit list of package names. When you document individual source files, pass in a list of Java source file names. See Simple Examples.
Process Source Files
The javadoc command processes files that end in source and other files described in Source Files. If you run the javadoc command by passing in individual source file names, then you can determine exactly which source files are processed. However, that is not how most developers want to work, because it is simpler to pass in package names. The javadoc command can be run three ways without explicitly specifying the source file names. You can pass in package names, use the -subpackages option, or use wild cards with source file names. In these cases, the javadoc command processes a source file only when the file fulfills all of the following requirements:
The file name prefix (with .java removed) is a valid class name.
The path name relative to the root of the source tree is a valid package name after the separators are converted to dots.
The package statement contains the valid package name.
Processing Links
During a run, the javadoc command adds cross-reference links to package, class, and member names that are being documented as part of that run. Links appear in the following places. See Javadoc Tags for a description of the @ tags.
Declarations (return types, argument types, and field types).
See Also sections that are generated from @see tags.
Inline text generated from {@link} tags.
Exception names generated from @throws tags.
Specified by links to interface members and Overrides links to class members. See Method Comment Inheritance.
Summary tables listing packages, classes and members.
Package and class inheritance trees.
The index.
You can add links to existing text for classes not included on the command line (but generated separately) by way of the -link and -linkoffline options.
Processing Details
The javadoc command produces one complete document every time it runs. It does not do incremental builds that modify or directly incorporate the results from earlier runs. However, the javadoc command can link to results from other runs.
The javadoc command implementation requires and relies on the Java compiler. The javadoc command calls part of the javac command to compile the declarations and ignore the member implementations. The javadoc command builds a rich internal representation of the classes that includes the class hierarchy and use relationships to generate the HTML. The javadoc command also picks up user-supplied documentation from documentation comments in the source code. See Documentation Comments.
The javadoc command runs on source files that are pure stub files with no method bodies. This means you can write documentation comments and run the javadoc command in the early stages of design before API implementation.
Relying on the compiler ensures that the HTML output corresponds exactly with the actual implementation, which may rely on implicit, rather than explicit, source code. For example, the javadoc command documents default constructors that are present in the compiled class files but not in the source code.
In many cases, the javadoc command lets you generate documentation for source files with incomplete or erroneous code. You can generate documentation before all debugging and troubleshooting is done. The javadoc command does primitive checking of documentation comments.
When the javadoc command builds its internal structure for the documentation, it loads all referenced classes. Because of this, the javadoc command must be able to find all referenced classes, whether bootstrap classes, extensions, or user classes. See How Classes Are Found at
/javase/8/docs/technotes/tools/findingclasses.html
Typically, classes you create must either be loaded as an extension or in the javadoc command class path.
Javadoc Doclets
You can customize the content and format of the javadoc command output with doclets. The javadoc command has a default built-in doclet, called the standard doclet, that generates HTML-formatted API documentation. You can modify or make a subclass of the standard doclet, or write your own doclet to generate HTML, XML, MIF, RTF or whatever output format you want.
When a custom doclet is not specified with the -doclet option, the javadoc command uses the default standard doclet. The javadoc command has several options that are available regardless of which doclet is being used. The standard doclet adds a supplementary set of command-line options. See Options.
Source Files
The javadoc command generates output that originates from the following types of source files: Java language source files for classes (.java), package comment files, overview comment files, and miscellaneous unprocessed files. This section also describes test files and template files that can also be in the source tree, but that you want to be sure not to document.
Class Source Files
Each class or interface and its members can have their own documentation comments contained in a source file. See Documentation Comments.
Package Comment Files
Each package can have its own documentation comment, contained in its own source file, that the javadoc command merges into the generated package summary page. You typically include in this comment any documentation that applies to the entire package.
To create a package comment file, you can place your comments in one of the following files:
The package-info.java file can contain the package declaration, package annotations, package comments, and Javadoc tags. This file is preferred.
The package.html file contains only package comments and Javadoc tags. No package annotations.
A package can have a single package.html file or a single package-info.java file, but not both. Place either file in the package directory in the source tree with your source files.
The package-info.java File
The package-info.java file can contain a package comment of the following structure. The comment is placed before the package declaration.
Note: The comment separators /** and */ must be present, but the leading asterisks on the intermediate lines can be left off.
* Provides the classes necessary to create an
* applet and the classes an applet uses
* to communicate with its applet context.
* The applet framework involves two entities:
* the applet and the applet context.
* An applet is an embeddable window (see the
* {@link java.awt.Panel} class) with a few extra
* methods that the applet context can use to
* initialize, start, and stop the applet.
* @since 1.0
* @see java.awt
package java.lang.
The package.html File
The package.html file can contain a package comment of the following structure. The comment is placed in the &body& element.
File: java/applet/package.html
Provides the classes necessary to create an applet and the
classes an applet uses to communicate with its applet context.
The applet framework involves two entities: the applet
and the applet context. An applet is an embeddable
window (see the {@link java.awt.Panel} class) with a
few extra methods that the applet context can use to
initialize, start, and stop the applet.
@since 1.0
@see java.awt
The package.html file is a typical HTML file and does not include a package declaration. The content of the package comment file is written in HTML with one exception. The documentation comment should not include the comment separators /** and */ or leading asterisks. When writing the comment, make the first sentence a summary about the package, and do not put a title or any other text between the &body& tag and the first sentence. You can include package tags. All block tags must appear after the main description. If you add an @see tag in a package comment file, then it must have a fully qualified name.
Processing the Comment File
When the javadoc command runs, it searches for the package comment file. If the package comment file is found, then the javadoc command does the following:
Copies the comment for processing. For package.html, the javadoc command copies all content between the &body& and &/body& HTML tags. You can include a &head& section to put a &title& tag, source file copyright statement, or other information, but none of these appear in the generated documentation.
Processes the package tags. See Package Tags.
Inserts the processed text at the bottom of the generated package summary page. See Java Platform, Standard Edition API Specification Overview at
/javase/8/docs/api/overview-summary.html
Copies the first sentence of the package comment to the top of the package summary page. The javadoc command also adds the package name and this first sentence to the list of packages on the overview page. See Java Platform, Standard Edition API Specification Overview at
/javase/8/docs/api/overview-summary.html
The end of the sentence is determined by the same rules used for the end of the first sentence of class and member main descriptions.
Overview Comment Files
Each application or set of packages that you are documenting can have its own overview documentation comment that is kept in its own source file, that the javadoc command merges into the generated overview page. You typically include in this comment any documentation that applies to the entire application or set of packages.
You can name the file anything you want such as overview.html and place it anywhere. A typical location is at the top of the source tree.
For example, if the source files for the java.applet package are contained in the C:\user\src\java\applet directory, then you could create an overview comment file at C:\user\src\overview.html.
You can have multiple overview comment files for the same set of source files in case you want to run the javadoc command multiple times on different sets of packages. For example, you could run the javadoc command once with -private for internal documentation and again without that option for public documentation. In this case, you could describe the documentation as public or internal in the first sentence of each overview comment file.
The content of the overview comment file is one big documentation comment that is written in HTML. Make the first sentence a summary about the application or set of packages. Do not put a title or any other text between the &body& tag and the first sentence. All tags except inline tags, such as an {@link} tag, must appear after the main description. If you add an @see tag, then it must have a fully qualified name.
When you run the javadoc command, specify the overview comment file name with the -overview option. The file is then processed similarly to that of a package comment file. The javadoc command does the following:
Copies all content between the &body& and &/body& tags for processing.
Processes the overview tags that are present. See Overview Tags.
Inserts the processed text at the bottom of the generated overview page. See Java Platform Standard Edition API Specification Overview at
/javase/8/docs/api/overview-summary.html
Copies the first sentence of the overview comment to the top of the overview summary page.
Unprocessed Files
Your source files can include any files that you want the javadoc command to copy to the destination directory. These files usually include graphic files, example Java source and class files, and self-standing HTML files with a lot of content that would overwhelm the documentation comment of a typical Java source file.
To include unprocessed files, put them in a directory called doc-files. The doc-files directory can be a subdirectory of any package directory that contains source files. You can have one doc-files subdirectory for each package.
For example, if you want to include the image of a button in the java.awt.Button class documentation, then place the image file in the \src\java\awt\doc-files directory. Do not place the doc-files directory at \src\java\doc-files, because java is not a package. It does not contain any source files.
All links to the unprocessed files must be included in the code because the javadoc command does not look at the files. The javadoc command copies the directory and all of its contents to the destination. The following example shows how the link in the Button.java documentation comment might look:
* This button looks like this:
* &img src=&doc-files/Button.gif&&
Test and Template Files
You can store test and template files in the source tree in the same directory with or in a subdirectory of the directory where the source files reside. To prevent test and template files from being processed, run the javadoc command and explicitly pass in individual source file names.
Test files are valid, compilable source files. Template files are not valid, compatible source files, but they often have the .java suffix.
Test Files
If you want your test files to belong to either an unnamed package or to a package other than the package that the source files are in, then put the test files in a subdirectory underneath the source files and give the directory an invalid name. If you put the test files in the same directory with the source and call the javadoc command with a command-line argument that indicates its package name, then the test files cause warnings or errors. If the files are in a subdirectory with an invalid name, then the test file directory is skipped and no errors or warnings are issued. For example, to add test files for source files in com.package1, put them in a subdirectory in an invalid package name. The following directory name is invalid because it contains a hyphen:
com\package1\test-files\
If your test files contain documentation comments, then you can set up a separate run of the javadoc command to produce test file documentation by passing in their test source file names with wild cards, such as com/package1/test-files/*.java.
Template Files
If you want a template file to be in the source directory, but not generate errors when you execute the javadoc command, then give it an invalid file name such as Buffer-Template.java to prevent it from being processed. The javadoc command only processes source files with names, when stripped of the .java suffix, that are valid class names.
Generated Files
By default, the javadoc command uses a standard doclet that generates HTML-formatted documentation. The standard doclet generates basic content, cross-reference, and support pages described here. Each HTML page corresponds to a separate file. The javadoc command generates two types of files. The first type is named after classes and interfaces. The second type contain hyphens (such as package-summary.html) to prevent conflicts with the first type of file.
Basic Content Pages
One class or interface page (classname.html) for each class or interface being documented.
One package page (package-summary.html) for each package being documented. The javadoc command includes any HTML text provided in a file with the name package.html or package-info.java in the package directory of the source tree.
One overview page (overview-summary.html) for the entire set of packages. The overview page is the front page of the generated document. The javadoc command includes any HTML text provided in a file specified by the -overview option. The Overview page is created only when you pass two or more package names into the javadoc command. See HTML Frames and Options.
Cross-Reference Pages
One class hierarchy page for the entire set of packages (overview-tree.html). To view the hierarchy page, click Overview in the navigation bar and click Tree.
One class hierarchy page for each package (package-tree.html) To view the hierarchy page, go to a particular package, class, or interface page, and click Tree to display the hierarchy for that package.
One use page for each package (package-use.html) and a separate use page for each class and interface (class-use/classname.html). The use page describes what packages, classes, methods, constructors and fields use any part of the specified class, interface, or package. For example, given a class or interface A, its use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. To view the use page, go to the package, class, or interface and click the Use link in the navigation bar.
A deprecated API page (deprecated-list.html) that lists all deprecated APIs and their suggested replacements. Avoid deprecated APIs because they can be removed in future implementations.
A constant field values page (constant-values.html) for the values of static fields.
A serialized form page (serialized-form.html) that provides information about serializable and externalizable classes with field and method descriptions. The information on this page is of interest to reimplementors, and not to developers who want to use the API. To access the serialized form page, go to any serialized class and click Serialized Form in the See Also section of the class comment. The standard doclet generates a serialized form page that lists any class (public or non-public) that implements Serializable with its readObject and writeObject methods, the fields that are serialized, and the documentation comments from the @serial, @serialField, and @serialData tags. Public serializable classes can be excluded by marking them (or their package) with @serial exclude, and package-private serializable classes can be included by marking them (or their package) with an @serial include. As of Release 1.4, you can generate the complete serialized form for public and private classes by running the javadoc command without specifying the -private option. See Options.
An index page (index-*.html) of all class, interface, constructor, field and method names, in alphabetical order. The index page is internationalized for Unicode and can be generated as a single file or as a separate file for each starting character (such as AZ for English).
Support Pages
A help page (help-doc.html) that describes the navigation bar and the previous pages. Use -helpfile to override the default help file with your own custom help file.
One index.html file that creates the HTML frames for display. Load this file to display the front page with frames. The index.html file contains no text content.
Several frame files (*-frame.html) that contains lists of packages, classes, and interfaces. The frame files display the HTML frames.
A package list file (package-list) that is used by the -link and -linkoffline options. The package list file is a text file that is not reachable through links.
A style sheet file (stylesheet.css) that controls a limited amount of color, font family, font size, font style, and positioning information on the generated pages.
A doc-files directory that holds image, example, source code, or other files that you want copied to the destination directory. These files are not processed by the javadoc command. This directory is not processed unless it exists in the source tree.
See Options.
HTML Frames
The javadoc command generates the minimum number of frames (two or three) necessary based on the values passed to the command. It omits the list of packages when you pass a single package name or source files that belong to a single package as an argument to the javadoc command. Instead, the javadoc command creates one frame in the left-hand column that displays the list of classes. When you pass two or more package names, the javadoc command creates a third frame that lists all packages and an overview page (overview-summary.html). To bypass frames, click the No Frames link or enter the page set from the overview-summary.html page.
Generated File Structure
The generated class and interface files are organized in the same directory hierarchy that Java source files and class files are organized. This structure is one directory per subpackage.
For example, the document generated for the java.applet.Applet class would be located at java\applet\Applet.html.
The file structure for the java.applet package follows,◇◇uming that the destination directory is named apidocs. All files that contain the word frame appear in the upper-left or lower-left frames, as noted. All other HTML files appear in the right-hand frame.
Directories are bold. The asterisks (*) indicate the files and directories that are omitted when the arguments to the javadoc command are source file names rather than package names. When arguments are source file names, an empty package list is created. The doc-files directory is not created in the destination unless it exists in the source tree. See Generated Files.
apidocs: Top-level directory
index.html: Initial Page that sets up HTML frames
*overview-summary.html: Package list with summaries
overview-tree.html: Class hierarchy for all packages
deprecated-list.html: Deprecated APIs for all packages
constant-values.html: Static field values for all packages
serialized-form.html: Serialized forms for all packages
*overview-frame.html: All packages for display in upper-left frame
allclasses-frame.html: All classes for display in lower-left frame
help-doc.html: Help about Javadoc page organization
index-all.html: Default index created without -splitindex option
index-files: Directory created with -splitindex option
index-&number&.html: Index files created with -splitindex option
package-list: Package names for resolving external references
stylesheet.css: Defines fonts, colors, positions, and so on
java: Package directory
applet: Subpackage directory
Applet.html: Applet class page
AppletContext.html: AppletContext interface
AppletStub.html: AppletStub interface
AudioClip.html: AudioClip interface
package-summary.html: Classes with summaries
package-frame.html: Package classes for display in lower-left frame
package-tree.html: Class hierarchy for this package
package-use.html: Where this package is used
doc-files: Image and example files directory
class-use: Image and examples file location
- Applet.html: Uses of the Applet class
- AppletContext.html: Uses of the AppletContext interface
- AppletStub.html: Uses of the AppletStub interface
- AudioClip.html: Uses of the AudioClip interface
src-html: Source code directory
java: Package directory
applet: Subpackage directory
- Applet.html: Applet source code
- AppletContext.html: AppletContext source code
- AppletStub.html: AppletStub source code
- AudioClip.html: AudioClip source code
Generated API Declarations
The javadoc command generates a declaration at the start of each class, interface, field, constructor, and method description for that API item. For example, the declaration for the Boolean class is:
public final class Boolean
extends Object
implements Serializable
The declaration for the Boolean.valueOf method is:
public static Boolean valueOf(String s)
The javadoc command can include the modifiers public, protected, private, abstract, final, static, transient, and volatile, but not synchronized or native. The synchronized and native modifiers are considered implementation detail and not part of the API specification.
Rather than relying on the keyword synchronized, APIs should document their concurrency semantics in the main description of the comment. For example, a description might be: A single enumeration cannot be used by multiple threads concurrently. The document should not describe how to achieve these semantics. As another example, while the Hashtable option should be thread-safe, there is no reason to specify that it is achieved by synchronizing all of its exported methods. It is better to reserve the right to synchronize internally at the bucket level for higher concurrency.
Documentation Comments
This section describes source code comments and comment inheritance.
Source Code Comments
You can include documentation comments in the source code, ahead of declarations for any class, interface, method, constructor, or field. You can also create documentation comments for each package and another one for the overview, though their syntax is slightly different. A documentation comment consists of the characters between /** and */ that end it. Leading asterisks are allowed on each line and are described further in the following section. The text in a comment can continue onto multiple lines.
* This is the typical format of a simple documentation comment
* that spans two lines.
To save space you can put a comment on one line:
/** This comment takes up only one line. */
Placement of Comments
Documentation comments are recognized only when placed immediately before class, interface, constructor, method, or field declarations. Documentation comments placed in the body of a method are ignored. The javadoc command recognizes only one documentation comment per declaration statement. See Where Tags Can Be Used.
A common mistake is to put an import statement between the class comment and the class declaration. Do not put an import statement at this location because the javadoc command ignores the class comment.
* This is the class comment for the class Whatever.
import com.
// MISTAKE - Important not to put import statement here
public class Whatever{ }
Parts of Comments
A documentation comment has a main description followed by a tag section. The main description begins after the starting delimiter /** and continues until the tag section. The tag section starts with the first block tag, which is defined by the first @ character that begins a line (ignoring leading asterisks, white space, and leading separator /**). It is possible to have a comment with only a tag section and no main description. The main description cannot continue after the tag section begins. The argument to a tag can span multiple lines. There can be any number of tags, and some types of tags can be repeated while others cannot. For example, this @see tag starts the tag section:
* This sentence holds the main description for this documentation comment.
* @see java.lang.Object
Block and inline Tags
A tag is a special keyword within a documentation comment that the javadoc command processes. There are two kinds of tags: block tags, which appear as an @tag tag (also known as standalone tags), and inline tags, which appear within braces, as an {@tag} tag. To be interpreted, a block tag must appear at the beginning of a line, ignoring leading asterisks, white space, and the separator (/**). This means you can use the @ character elsewhere in the text and it will not be interpreted as the start of a tag. If you want to start a line with the @ character and not have it be interpreted, then use the HTML entity @. Each block tag has◇◇ociated text, which includes any text following the tag up to, but not including, either the next tag, or the end of the documentation comment. This◇◇ociated text can span multiple lines. An inline tag is allowed and interpreted anywhere that text is allowed. The following example contains the @deprecated block tag and the {@link} inline tag. See Javadoc Tags.
* @deprecated
As of JDK 1.1, replaced by {@link #setBounds(int,int,int,int)}
Write Comments in HTML
The text must be written in HTML with HTML entities and HTML tags. You can use whichever version of HTML your browser supports. The standard doclet generates HTML 3.2-compliant code elsewhere (outside of the documentation comments) with the inclusion of cascading style sheets and frames. HTML 4.0 is preferred for generated files because of the frame sets.
For example, entities for the less than symbol (&) and the greater than symbol (&) should be written as & and &. Similarly, the ampersand (&) should be written as &. The bold HTML tag &b& is shown in the following example.
* This is a &b&doc&/b& comment.
* @see java.lang.Object
Leading Asterisks
When the javadoc command parses a documentation comment, leading asterisks (*) on each line are discarded, and blanks and tabs that precede the initial asterisks (*) are also discarded. If you omit the leading asterisk on a line, then the leading white space is no longer removed so that you can paste code examples directly into a documentation comment inside a &PRE& tag with its indentation preserved. Spaces are interpreted by browsers more uniformly than tabs. Indentation is relative to the left margin (rather than the separator /** or &PRE& tag).
First Sentence
The first sentence of each documentation comment should be a summary sentence that contains a concise but complete description of the declared entity. This sentence ends at the first period that is followed by a blank, tab, or line terminator, or at the first block tag. The javadoc command copies this first sentence to the member summary at the top of the HTML page.
Multiple-Field Declarations
The Java platform lets you declare multiple fields in a single statement, but this statement can have only one documentation comment that is copied for all fields. If you want individual documentation comments for each field, then declare each field in a separate statement. For example, the following documentation comment does not make sense written as a single declaration and would be better handled as two declarations:
* The horizontal and vertical distances of point (x,y)
public int x,
// Avoid this
The javadoc command generates the following documentation from the previous code:
public int x
The horizontal and vertical distances of point (x, y).
public int y
The horizontal and vertical distances of point (x, y).
Use of Header Tags
When writing documentation comments for members, it is best not to use HTML heading tags such as &H1& and &H2&, because the javadoc command creates an entire structured document, and these structural tags might interfere with the formatting of the generated document. However, you can use these headings in class and package comments to provide your own structure.
Method Comment Inheritance
The javadoc command allows method comment inheritance in classes and interfaces to fill in missing text or to explicitly inherit method comments. Constructors, fields, and nested classes do not inherit documentation comments.
Note: The source file for an inherited method must be on the path specified by the -sourcepath option for the documentation comment to be available to copy. Neither the class nor its package needs to be passed in on the command line. This contrasts with Release 1.3.n and earlier releases, where the class had to be a documented class.
Fill in Missing Text
When a main description, or @return, @param, or @throws tag is missing from a method comment, the javadoc command copies the corresponding main description or tag comment from the method it overrides or implements (if any). See Method Comment Inheritance.
When an @param tag for a particular parameter is missing, the comment for that parameter is copied from the method further up the inheritance hierarchy. When an @throws tag for a particular exception is missing, the @throws tag is copied only when that exception is declared.
This behavior contrasts with Release 1.3 and earlier, where the presence of any main description or tag would prevent all comments from being inherited.
See Javadoc Tags and Options.
Explicit Inheritance
Insert the {@inheritDoc} inline tag in a method main description or @return, @param, or @throws tag comment. The corresponding inherited main description or tag comment is copied into that spot.
Class and Interface Inheritance
Comment inheritance occurs in all possible cases of inheritance from classes and interfaces:
When a method in a class overrides a method in a superclass
When a method in an interface overrides a method in a superinterface
When a method in a class implements a method in an interface
In the first two cases, the javadoc command generates the subheading Overrides in the documentation for the overriding method. A link to the method being overridden is included, whether or not the comment is inherited.
In the third case, when a method in a specified class implements a method in an interface, the javadoc command generates the subheading Specified by in the documentation for the overriding method. A link to the method being implemented is included, whether or not the comment is inherited.
Method Comments Algorithm
If a method does not have a documentation comment, or has an {@inheritDoc} tag, then the javadoc command uses the following algorithm to search for an applicable comment. The algorithm is designed to find the most specific applicable documentation comment, and to give preference to interfaces over superclasses:
Look in each directly implemented (or extended) interface in the order they appear following the word implements (or extends) in the method declaration. Use the first documentation comment found for this method.
If Step 1 failed to find a documentation comment, then recursively apply this entire algorithm to each directly implemented (or extended) interface in the same order they were examined in Step 1.
When Step 2 fails to find a documentation comment and this is a class other than the Object class, but not an interface:
If the superclass has a documentation comment for this method, then use it.
If Step 3a failed to find a documentation comment, then recursively apply this entire algorithm to the superclass.
Javadoc Tags
The javadoc command parses special tags when they are embedded within a Java documentation comment. The javadoc tags let you autogenerate a complete, well-formatted API from your source code. The tags start with an at sign (@) and are case-sensitive. They must be typed with the uppercase and lowercase letters as shown. A tag must start at the beginning of a line (after any leading spaces and an optional asterisk), or it is treated as text. By convention, tags with the same name are grouped together. For example, put all @see tags together. For more information, see Where Tags Can Be Used.
Tags have the following types:
Bock tags: Place block tags only in the tag section that follows the description. Block tags have the form: @tag.
Inline tags: Place inline tags anywhere in the main description or in the comments for block tags. Inline tags are enclosed within braces: {@tag}.
For custom tags, see -tag tagname:Xaoptcmf:&taghead&. See also Where Tags Can Be Used.
Tag Descriptions
@author name-text
Introduced in JDK 1.0
Adds an Author entry with the specified name text to the generated documents when the -author option is used. A documentation comment can contain multiple @author tags. You can specify one name per @author tag or multiple names per tag. In the former case, the javadoc command inserts a comma (,) and space between names. In the latter case, the entire text is copied to the generated document without being parsed. Therefore, you can use multiple names per line if you want a localized name separator other than a comma. See @author in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#@author
{@code text}
Introduced in JDK 1.5
Equivalent to &code&{@literal}&/code&.
Displays text in code font without interpreting the text as HTML markup or nested Javadoc tags. This enables you to use regular angle brackets (& and &) instead of the HTML entities (& and &) in documentation comments, such as in parameter types (&Object&), inequalities (3 & 4), or arrows (&-). For example, the documentation comment text {@code A&B&C} displayed in the generated HTML page unchanged as A&B&C. This means that the &B& is not interpreted as bold and is in code font. If you want the same functionality without the code font, then use the {@literal} tag.
@deprecated deprecated-text
Introduced in JDK 1.0
Adds a comment indicating that this API should no longer be used (even though it may continue to work). The javadoc command moves deprecated-text ahead of the main description, placing it in italics and preceding it with a bold warning: Deprecated. This tag is valid in all documentation comments: overview, package, class, interface, constructor, method and field.
The first sentence of deprecated text should tell the user when the API was deprecated and what to use as a replacement. The javadoc command copies the first sentence to the summary section and index. Subsequent sentences can also explain why it was deprecated. You should include an {@link} tag (for Javadoc 1.2 or later) that points to the replacement API.
Use the @deprecated annotation tag to deprecate a program element. See How and When to Deprecate APIs at
/javase/8/docs/technotes/guides/javadoc/deprecation/deprecation.html
See also @deprecated in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#@deprecated
{@docRoot}
Introduced in JDK 1.3
Represents the relative path to the generated document's (destination) root directory from any generated page. This tag is useful when you want to include a file, such as a copyright page or company logo, that you want to reference from all generated pages. Linking to the copyright page from the bottom of each page is common.
This {@docRoot} tag can be used both on the command line and in a documentation comment. This tag is valid in all documentation comments: overview, package, class, interface, constructor, method and field, and includes the text portion of any tag (such as the @return, @param and @deprecated tags).
On the command line, where the header, footer, or bottom are defined: javadoc -bottom '&a href=&{@docRoot}/copyright.html&&Copyright&/a&'.
When you use the {@docRoot} tag this way in a make file, some makefile programs require a special way to escape for the brace {} characters. For example, the Inprise MAKE version 5.2 running on Windows requires double braces: {{@docRoot}}. It also requires double (rather than single) quotation marks to enclose arguments to options such as the -bottom option (with the quotation marks around the href argument omitted).
In a documentation comment:
* See the &a href=&{@docRoot}/copyright.html&&Copyright&/a&.
This tag is needed because the generated documents are in hierarchical directories, as deep as the number of subpackages. The expression: &a href=&{@docRoot}/copyright.html&& resolves to &a href=&../../copyright.html&& for java/lang/Object.java and &a href=&../../../copyright.html&& for java/lang/ref/Reference.java.
@exception class-name description
Introduced in JDK 1.0
Identical to the @throws tag. See @throws class-name description.
{@inheritDoc}
Introduced in JDK 1.4
Inherits (copies) documentation from the nearest inheritable class or implementable interface into the current documentation comment at this tag's location. This enables you to write more general comments higher up the inheritance tree and to write around the copied text.
This tag is valid only in these places in a documentation comment:
In the main description block of a method. In this case, the main description is copied from a class or interface up the hierarchy.
In the text arguments of the @return, @param, and @throws tags of a method. In this case, the tag text is copied from the corresponding tag up the hierarchy.
See Method Comment Inheritance for a description of how comments are found in the inheritance hierarchy. Note that if this tag is missing, then the comment is or is not automatically inherited according to rules described in that section.
{@link package.class#member label}
Introduced in JDK 1.2
Inserts an inline link with a visible text label that points to the documentation for the specified package, class, or member name of a referenced class. This tag is valid in all documentation comments: overview, package, class, interface, constructor, method and field, including the text portion of any tag, such as the @return, @param and @deprecated tags. See @link in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#{@link
This tag is similar to the @see tag. Both tags require the same references and accept the same syntax for package.class#member and label. The main difference is that the {@link} tag generates an inline link rather than placing the link in the See Also section. The {@link} tag begins and ends with braces to separate it from the rest of the inline text. If you need to use the right brace (}) inside the label, then use the HTML entity notation }.
There is no limit to the number of {@link} tags allowed in a sentence. You can use this tag in the main description part of any documentation comment or in the text portion of any tag, such as the @deprecated, @return or @param tags.
For example, here is a comment that refers to the getComponentAt(int, int) method:
Use the {@link #getComponentAt(int, int) getComponentAt} method.
From this code, the standard doclet generates the following HTML (assuming it refers to another class in the same package):
Use the &a href=&Component.html#getComponentAt(int, int)&&getComponentAt&/a& method.
The previous line appears on the web page as:
Use the getComponentAt method.
{@linkplain package.class#member label}
Introduced in JDK 1.4
Behaves the same as the {@link} tag, except the link label is displayed in plain text rather than code font. Useful when the label is plain text. For example, Refer to {@linkplain add() the overridden method}. displays as: Refer to the overridden method.
{@literal text}
Introduced in JDK 1.5
Displays text without interpreting the text as HTML markup or nested Javadoc tags. This enables you to use angle brackets (& and &) instead of the HTML entities (& and &) in documentation comments, such as in parameter types (&Object&), inequalities (3 & 4), or arrows (&-). For example, the documentation comment text {@literal A&B&C} displays unchanged in the generated HTML page in your browser, as A&B&C. The &B& is not interpreted as bold (and it is not in code font). If you want the same functionality with the text in code font, then use the {@code} tag.
@param parameter-name description
Introduced in JDK 1.0
Adds a parameter with the specified parameter-name followed by the specified description to the Parameters section. When writing the documentation comment, you can continue the description onto multiple lines. This tag is valid only in a documentation comment for a method, constructor, or class. See @param in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#@param
The parameter-name can be the name of a parameter in a method or constructor, or the name of a type parameter of a class, method, or constructor. Use angle brackets around this parameter name to specify the use of a type parameter.
Example of a type parameter of a class:
* @param &E& Type of element stored in a list
public interface List&E& extends Collection&E& {
Example of a type parameter of a method:
* @param string
the string to be converted
* @param type
the type to convert the string to
* @param &T&
the type of the element
* @param &V&
the value of the element
&T, V extends T& V convert(String string, Class&T& type) {
@return description
Introduced in JDK 1.0
Adds a Returns section with the description text. This text should describe the return type and permissible range of values. This tag is valid only in a documentation comment for a method. See @return in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#@return
@see reference
Introduced in JDK 1.0
Adds a See Also heading with a link or text entry that points to a reference. A documentation comment can contain any number of @see tags, which are all grouped under the same heading. The @see tag has three variations. The form is the most common. This tag is valid in any documentation comment: overview, package, class, interface, constructor, method, or field. For inserting an inline link within a sentence to a package, class, or member, see {@link}.
Form 1. The @see string tag form adds a text entry for string. No link is generated. The string is a book or other reference to information not available by URL. The javadoc command distinguishes this from the previous cases by searching for a double quotation mark (&) as the first character. For example, @see &The Java Programming Language& that generates the following text:
&The Java Programming Language&
Form 2. The @see &a href=&URL#value&&label&/a& form adds a link as defined by URL#value. The URL#value parameter is a relative or absolute URL. The javadoc command distinguishes this from other cases by searching for a less-than symbol (&) as the first character. For example, @see &a href=&spec.html#section&&Java Spec&/a& generates the following link:
Form 3. The @see package.class#member label form adds a link with a visible text label that points to the documentation for the specified name in the Java Language that is referenced. The label is optional. If the label is omitted, then the name appears instead as visible text, suitably shortened. Use the -noqualifier option to globally remove the package name from this visible text. Use the label when you want the visible text to be different from the autogenerated visible text. See How a Name Appears.
In Java SE 1.2 only, the name but not the label automatically appears in &code& HTML tags. Starting with Java SE 1.2.2, the &code& tag is always included around the visible text, whether or not a label is used.
package.class#member is any valid program element name that is referenced, such as a package, class, interface, constructor, method or field name, except that the character ahead of the member name should be a number sign (#). The class represents any top-level or nested class or interface. The member represents any constructor, method, or field (not a nested class or interface). If this name is in the documented classes, then the javadoc command create a link to it. To create links to external referenced classes, use the -link option. Use either of the other two @see tag forms to refer to the documentation of a name that does not belong to a referenced class. See Specify a Name.
Note: External referenced classes are classes that are not passed into the javadoc command on the command line. Links in the generated documentation to external referenced classes are called external references or external links. For example, if you run the javadoc command on only the java.awt package, then any class in java.lang, such as Object, is an external referenced class. Use the -link and -linkoffline options to link to external referenced classes. The source comments of external referenced classes are not available to the javadoc command run.
label is optional text that is visible as the link label. The label can contain white space. If label is omitted, then package.class.member appears, suitably shortened relative to the current class and package. See How a Name Appears.
A space is the delimiter between package.class#member and label. A space inside parentheses does not indicate the start of a label, so spaces can be used between parameters in a method.
In the following example, an @see tag (in the Character class) refers to the equals method in the String class. The tag includes both arguments: the name String#equals(Object) and the label equals.
* @see String#equals(Object) equals
The standard doclet produces HTML that is similar to:
&dt&&b&See Also:&/b&
&dd&&a href=&../../java/lang/String#equals(java.lang.Object)&&&code&equals&code&&/a&
The previous code looks similar to the following in a browser, where the label is the visible link text:
Specify a Name
This package.class#member name can be either fully qualified, such as java.lang.String#toUpperCase() or not, such as String#toUpperCase() or #toUpperCase(). If the name is less than fully qualified, then the javadoc command uses the standard Java compiler search order to find it. See Search Order for the @see Tag. The name can contain white space within parentheses, such as between method arguments.The advantage to providing shorter, partially qualified names is that they are shorter to type and there is less clutter in the source code. The following listing shows the different forms of the name, where Class can be
Type can be a class, interface, array, and method can be a method or constructor.
Typical forms for @see package.class#member
Referencing a member of the current class
@see #field
@see #method(Type, Type,...)
@see #method(Type argname, Type argname,...)
@see #constructor(Type, Type,...)
@see #constructor(Type argname, Type argname,...)
Referencing another class in the current or imported packages
@see Class#field
@see Class#method(Type, Type,...)
@see Class#method(Type argname, Type argname,...)
@see Class#constructor(Type, Type,...)
@see Class#constructor(Type argname, Type argname,...)
@see Class.NestedClass
@see Class
Referencing an element in another package (fully qualified)
@see package.Class#field
@see package.Class#method(Type, Type,...)
@see package.Class#method(Type argname, Type argname,...)
@see package.Class#constructor(Type, Type,...)
@see package.Class#constructor(Type argname, Type argname,...)
@see package.Class.NestedClass
@see package.Class
@see package
Notes about the previous listing:
The first set of forms with no class or package causes the javadoc command to search only through the current class hierarchy. It finds a member of the current class or interface, one of its superclasses or superinterfaces, or one of its enclosing classes or interfaces (search Items 13). It does not search the rest of the current package or other packages (search Items 45). See Search Order for the @see Tag.
If any method or constructor is entered as a name with no parentheses, such as getValue, and if there is no field with the same name, then the javadoc command still creates a link to the method. If this method is overloaded, then the javadoc command links to the first method its search encounters, which is unspecified.
Nested classes must be specified as outer.inner, not simply inner, for all forms.
As stated, the number sign (#), rather than a dot (.) separates a member from its class. This enables the javadoc command to resolve ambiguities, because the dot also separates classes, nested classes, packages, and subpackages. However, the javadoc command properly parses a dot when there is no ambiguity, but prints a warning to alert you.
Search Order for the @see Tag
The javadoc command processes an @see tag that appears in a source file, package file, or overview file. In the latter two files, you must fully qualify the name you supply with the @see tag. In a source file, you can specify a name that is fully qualified or partially qualified.
The following is the search order for the @see tag.
The current class or interface.
Any enclosing classes and interfaces searching the closest first.
Any superclasses and superinterfaces, searching the closest first.
The current package.
Any imported packages, classes, and interfaces, searching in the order of the import statement.
The javadoc command continues to search recursively through Items 1-3 for each class it encounters until it finds a match. That is, after it searches through the current class and its enclosing class E, it searches through the superclasses of E before the enclosing classes of E. In Items 4 and 5, the javadoc command does not search classes or interfaces within a package in any specified order (that order depends on the particular compiler). In Item 5, the javadoc command searches in java.lang because that is imported by all programs.
When the javadoc command encounters an @see tag in a source file that is not fully qualified, it searches for the specified name in the same order as the Java compiler would, except the javadoc command does not detect certain name space ambiguities because it◇◇umes the source code is free of these errors. This search order is formally defined in the Java Language Specification. The javadoc command searches for that name through all related and imported classes and packages. In particular, it searches in this order:
The current class or interface.
Any enclosing classes and interfaces, searching the closest first.
Any superclasses and superinterfaces, searching the closest first.
The current package.
Any imported packages, classes, and interfaces, searching in the order of the import statements.
The javadoc command does not necessarily look in subclasses, nor will it look in other packages even when their documentation is being generated in the same run. For example, if the @see tag is in the java.awt.event.KeyEvent class and refers to a name in the java.awt package, then the javadoc command does not look in that package unless that class imports it.
How a Name Appears
If label is omitted, then package.class.member appears. In general, it is suitably shortened relative to the current class and package. Shortened means the javadoc command displays only the minimum name necessary. For example, if the String.toUpperCase() method contains references to a member of the same class and to a member of a different class, then the class name is displayed only in the latter case, as shown in the following listing. Use the -noqualifier option to globally remove the package names.
Type of reference: The @see tag refers to a member of the same class, same package
Example in: @see String#toLowerCase()
Appears as: toLowerCase() - omits the package and class names
Type of reference: The @see tag refers to a member of a different class, same package
Example in: @see Character#toLowerCase(char)
Appears as: Character.toLowerCase(char) - omits the package name, includes the class name
Type of reference: The @see tag refers to a member of a different class, different package
Example in: @see java.io.File#exists()
Appears as: java.io.File.exists() - includes the package and class names
Examples of the @see Tag
The comment to the right shows how the name appears when the @see tag is in a class in another package, such as java.applet.Applet. See @see in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#@see
@see java.lang.String
@see java.lang.String The String class
The String class
@see String
@see String#equals(Object)
String.equals(Object)
@see String#equals
String.equals(java.lang.Object)
@see java.lang.Object#wait(long)
java.lang.Object.wait(long)
@see Character#MAX_RADIX
Character.MAX_RADIX
@see &a href=&spec.html&&Java Spec&/a&
@see &The Java Programming Language&
&The Java Programming Language&
Note: You can extend the @see tag to link to classes not being documented with the -link option.
@serial field-description | include | exclude
Introduced in JDK 1.2
Used in the documentation comment for a default serializable field. See Documenting Serializable Fields and Data for a Class at
/javase/8/docs/platform/serialization/spec/serial-arch.html#5251
See also Oracle's Criteria for Including Classes in the Serialized Form Specification at
/technetwork/java/javase/documentation/serialized-criteria-137781.html
An optional field-description should explain the meaning of the field and list the acceptable values. When needed, the description can span multiple lines. The standard doclet adds this information to the serialized form page. See Cross-Reference Pages.
If a serializable field was added to a class after the class was made serializable, then a statement should be added to its main description to identify at which version it was added.
The include and exclude arguments identify whether a class or package should be included or excluded from the serialized form page. They work as follows:
A public or protected class that implements Serializable is included unless that class (or its package) is marked with the @serial exclude tag.
A private or package-private class that implements Serializable is excluded unless that class (or its package) is marked with the @serial include tag.
For example, the javax.swing package is marked with the @serial exclude tag in package.html or package-info.java. The public class java.security.BasicPermission is marked with the @serial exclude tag. The package-private class java.util.PropertyPermissionCollection is marked with the @serial include tag.
The @serial tag at the class level overrides the @serial tag at the package level.
@serialData data-description
Introduced in JDK 1.2
Uses the data description value to document the types and order of data in the serialized form. This data includes the optional data written by the writeObject method and all data (including base classes) written by the Externalizable.writeExternal method.
The @serialData tag can be used in the documentation comment for the writeObject, readObject, writeExternal, readExternal, writeReplace, and readResolve methods.
@serialField field-name field-type field-description
Introduced in JDK 1.2
Documents an ObjectStreamField component of the serialPersistentFields member of a Serializable class. Use one @serialField tag for each ObjectStreamField component.
@since since-text
Introduced in JDK 1.1
Adds a Since heading with the specified since-text value to the generated documentation. The text has no special internal structure. This tag is valid in any documentation comment: overview, package, class, interface, constructor, method, or field. This tag means that this change or feature has existed since the software release specified by the since-text value, for example: @since 1.5.
For Java platform source code, the @since tag indicates the version of the Java platform API specification, which is not necessarily when the source code was added to the reference implementation. Multiple @since tags are allowed and are treated like multiple @author tags. You could use multiple tags when the program element is used by more than one API.
@throws class-name description
Introduced in JDK 1.2
Behaves the same as the @exception tag. See @throws in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#@exception
The @throws tag adds a Throws subheading to the generated documentation, with the class-name and description text. The class-name is the name of the exception that might be thrown by the method. This tag is valid only in the documentation comment for a method or constructor. If this class is not fully specified, then the javadoc command uses the search order to look up this class. Multiple @throws tags can be used in a specified documentation comment for the same or different exceptions. See Search Order for the @see Tag.
To ensure that all checked exceptions are documented, when an @throws tag does not exist for an exception in the throws clause, the javadoc command adds that exception to the HTML output (with no description) as though it were documented with the @throws tag.
The @throws documentation is copied from an overridden method to a subclass only when the exception is explicitly declared in the overridden method. The same is true for copying from an interface method to an implementing method. You can use the {@inheritDoc} tag to force the @throws tag to inherit documentation.
{@value package.class#field}
Introduced in JDK 1.4
Displays constant values. When the {@value} tag is used without an argument in the documentation comment of a static field, it displays the value of that constant:
* The value of this constant is {@value}.
public static final String SCRIPT_START = &&script&&
When used with the argument package.class#field in any documentation comment, he {@value} tag displays the value of the specified constant:
* Evaluates the script starting with {@value #SCRIPT_START}.
public String evalScript(String script) {}
The argument package.class#field takes a form similar to that of the @see tag argument, except that the member must be a static field.
The values of these constants are also displayed in Constant Field Values at
/javase/8/docs/api/constant-values.html
@version version-text
Introduced in JDK 1.0
Adds a Version subheading with the specified version-text value to the generated documents when the -version option is used. This tag is intended to hold the current release number of the software that this code is part of, as opposed to the @since tag, which holds the release number where this code was introduced. The version-text value has no special internal structure. See @version in How to Write Doc Comments for the Javadoc Tool at
/technetwork/java/javase/documentation/index-137868.html#@version
A documentation comment can contain multiple @version tags. When it makes sense, you can specify one release number per @version tag or multiple release numbers per tag. In the former case, the javadoc command inserts a comma (,) and a space between the names. In the latter case, the entire text is copied to the generated document without being parsed. Therefore, you can use multiple names per line when you want a localized name separator other than a comma.
Where Tags Can Be Used
The following sections describe where tags can be used. Note that the following tags can be used in all documentation comments: @see, @since, @deprecated, {@link}, {@linkplain}, and {@docroot}.
Overview Tags
Overview tags are tags that can appear in the documentation comment for the overview page (which resides in the source file typically named overview.html). Similar to any other documentation comments, these tags must appear after the main description
Note: The {@link} tag has a bug in overview documents in Java SE 1.2. The text appears correctly but has no link. The {@docRoot} tag does not currently work in overview documents.
The overview tags are the following:
@see reference || @since since-text || @serialField field-name field-type field-description || @author name-text || @version version-text || {@link package.class#member label} || {@linkplain package.class#member label} || {@docRoot} ||
Package Tags
Package tags are tags that can appear in the documentation comment for a package, that resides in the source file named package.html or package-info.java. The @serial tag can only be used here with the include or exclude argument.
The package tags are the following:
@see reference || @since since-text || @serial field-description | include | exclude || @author name-text || @version version-text || {@linkplain package.class#member label} || {@linkplain package.class#member label} || {@docRoot} ||
Class and Interface Tags
The following are tags that can appear in the documentation comment for a class or interface. The @serial tag can only be used within the documentation for a class or interface with an include or exclude argument.
@see reference || @since since-text || @deprecated deprecated-text || @serial field-description | include | exclude || @author name-text || @version version-text || {@link package.class#member label} || {@linkplain package.class#member label} || {@docRoot} ||
Class comment example:
* A class representing a window on the screen.
* For example:
Window win = new Window(parent);
win.show();
Sami Shaio
* @version 1.13, 06/08/06
java.awt.BaseWindow
java.awt.Button
class Window extends BaseWindow {
Field Tags
These tags can appear in fields:
@see reference || @since since-text || @deprecated deprecated-text || @serial field-description | include | exclude || @serialField field-name field-type field-description || {@link package.class#member label} || {@linkplain package.class#member label} || {@docRoot} || {@value package.class#field}
Field comment example:
* The X-coordinate of the component.
* @see #getLocation()
int x = 1263732;
Constructor and Method Tags
The following tags can appear in the documentation comment for a constructor or a method, except for the @

我要回帖

更多关于 java character 比较 的文章

 

随机推荐