langtools/src/share/classes/com/sun/javadoc/package.html
author ohair
Wed, 26 May 2010 20:22:54 -0700
changeset 5568 8450cc6bc21c
parent 5520 86e4b9a9da40
permissions -rw-r--r--
6956202: Fix a few missed rebranding issues, please contact lines etc. Reviewed-by: darcy, jjg, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
<html>
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
<head>
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
<TITLE>Doclet API Package</TITLE>
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
<!--
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     6
Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    11
published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    13
by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
5568
8450cc6bc21c 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5520
diff changeset
    25
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8450cc6bc21c 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5520
diff changeset
    26
or visit www.oracle.com if you need additional information or have any
8450cc6bc21c 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5520
diff changeset
    27
questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
-->
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
</head>
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
<body bgcolor="white">
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
The Doclet API (also called the Javadoc API) provides a mechanism
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
for clients to inspect the source-level structure of programs and 
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
libraries, including javadoc comments embedded in the source.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
This is useful for documentation, program checking, automatic
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
code generation and many other tools.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
<p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
Doclets are invoked by javadoc and use this API to write out 
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
program information to files.  For example, the standard doclet is called
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
by default and writes out documentation to HTML files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
<p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
The invocation is defined by the abstract {@link com.sun.javadoc.Doclet} class 
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
-- the entry point is the {@link com.sun.javadoc.Doclet#start(RootDoc) start} method:
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
<pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    public static boolean <b>start</b>(RootDoc root)
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
The {@link com.sun.javadoc.RootDoc} instance holds the root of the program structure
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
information. From this root all other program structure 
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
information can be extracted.  
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
<p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
<a name="terminology"></a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
<h3>Terminology</h3>
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
<a name="included"></a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
When calling javadoc, you pass in package names and source file names --
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
these are called the <em>specified</em> packages and classes.  
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
You also pass in Javadoc options; the <em>access control</em> Javadoc options 
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
(<code>-public</code>, <code>-protected</code>, <code>-package</code>, 
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
and <code>-private</code>) filter program elements, producing a 
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
result set, called the <em>included</em> set, or "documented" set.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
(The unfiltered set is also available through 
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
{@link com.sun.javadoc.PackageDoc#allClasses(boolean) allClasses(false)}.)
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
<p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
<a name="class"></a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
Throughout this API, the term <em>class</em> is normally a
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
shorthand for "class or interface", as in: {@link com.sun.javadoc.ClassDoc}, 
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
{@link com.sun.javadoc.PackageDoc#allClasses() allClasses()}, and
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
{@link com.sun.javadoc.PackageDoc#findClass(String) findClass(String)}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
In only a couple of other places, it means "class, as opposed to interface", 
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
as in:  {@link com.sun.javadoc.Doc#isClass()}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
In the second sense, this API calls out four kinds of classes:
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
{@linkplain com.sun.javadoc.Doc#isOrdinaryClass() ordinary classes}, 
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
{@linkplain com.sun.javadoc.Doc#isEnum() enums},
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
{@linkplain com.sun.javadoc.Doc#isError() errors} and 
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
{@linkplain com.sun.javadoc.Doc#isException() exceptions}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
Throughout the API, the detailed description of each program element 
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
describes explicitly which meaning is being used.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
<p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
<a name="qualified"></a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
A <em>qualified</em> class or interface name is one that has its package
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
name prepended to it, such as <code>java.lang.String</code>.  A non-qualified
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
name has no package name, such as <code>String</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
<p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
<a name="example"></a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
<h3>Example</h3>
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
 
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
The following is an example doclet that 
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
displays information in the <code>@param</code> tags of the processed
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
classes:
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
<pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
public class ListParams extends <font color=red title="Doclet API">Doclet</font> {
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    public static boolean start(<font color=red title="Doclet API">RootDoc</font> root) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        <font color=red title="Doclet API">ClassDoc</font>[] classes = root.<font color=red title="Doclet API">classes</font>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        for (int i = 0; i < classes.length; ++i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            <font color=red title="Doclet API">ClassDoc</font> cd = classes[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            printMembers(cd.<font color=red title="Doclet API">constructors</font>());
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
            printMembers(cd.<font color=red title="Doclet API">methods</font>());
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    static void printMembers(<font color=red title="Doclet API">ExecutableMemberDoc</font>[] mems) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        for (int i = 0; i < mems.length; ++i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            <font color=red title="Doclet API">ParamTag</font>[] params = mems[i].<font color=red title="Doclet API">paramTags</font>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
            System.out.println(mems[i].<font color=red title="Doclet API">qualifiedName</font>());
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
            for (int j = 0; j < params.length; ++j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
                System.out.println("   " + params[j].<font color=red title="Doclet API">parameterName</font>()
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
                    + " - " + params[j].<font color=red title="Doclet API">parameterComment</font>());
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    }        
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
}
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
Interfaces and methods from the Javadoc API are marked in 
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
<font color=red title="Doclet API">red</font>. 
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
{@link com.sun.javadoc.Doclet Doclet} is an abstract class that specifies 
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
the invocation interface for doclets, 
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
{@link com.sun.javadoc.Doclet Doclet} holds class or interface information, 
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
{@link com.sun.javadoc.ExecutableMemberDoc} is a
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
superinterface of {@link com.sun.javadoc.MethodDoc} and 
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
{@link com.sun.javadoc.ConstructorDoc}, 
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
and {@link com.sun.javadoc.ParamTag} holds information
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
from "<code>@param</code>" tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
<p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
This doclet when invoked with a command line like:
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
<pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    javadoc -doclet ListParams -sourcepath &lt;source-location&gt; java.util
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
producing output like:
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
<pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    ...
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    java.util.ArrayList.add
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
       index - index at which the specified element is to be inserted.
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
       element - element to be inserted.
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    java.util.ArrayList.remove
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
       index - the index of the element to removed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    ...
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
@see com.sun.javadoc.Doclet
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
@see com.sun.javadoc.RootDoc
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
</BODY>
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
</HTML>