DocTree.java revision 3337:cba09a2e6ae9
1/*
2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.source.doctree;
27
28/**
29 * Common interface for all nodes in a documentation syntax tree.
30 *
31 * @since 1.8
32 */
33public interface DocTree {
34    /**
35     * Enumerates all kinds of trees.
36     */
37    enum Kind {
38        /**
39         * Used for instances of {@link AttributeTree}
40         * representing an HTML attribute.
41         */
42        ATTRIBUTE,
43
44        /**
45         * Used for instances of {@link AuthorTree}
46         * representing an @author tag.
47         */
48        AUTHOR("author"),
49
50        /**
51         * Used for instances of {@link LiteralTree}
52         * representing an @code tag.
53         */
54        CODE("code"),
55
56        /**
57         * Used for instances of {@link CommentTree}
58         * representing an HTML comment.
59         */
60        COMMENT,
61
62        /**
63         * Used for instances of {@link DeprecatedTree}
64         * representing an @deprecated tag.
65         */
66        DEPRECATED("deprecated"),
67
68        /**
69         * Used for instances of {@link DocCommentTree}
70         * representing a complete doc comment.
71         */
72        DOC_COMMENT,
73
74        /**
75         * Used for instances of {@link DocRootTree}
76         * representing an @docRoot tag.
77         */
78        DOC_ROOT("docRoot"),
79
80        /**
81         * Used for instances of {@link EndElementTree}
82         * representing the end of an HTML element.
83         */
84        END_ELEMENT,
85
86        /**
87         * Used for instances of {@link EntityTree}
88         * representing an HTML entity.
89         */
90        ENTITY,
91
92        /**
93         * Used for instances of {@link ErroneousTree}
94         * representing some invalid text.
95         */
96        ERRONEOUS,
97
98        /**
99         * Used for instances of {@link ThrowsTree}
100         * representing an @exception tag.
101         */
102        EXCEPTION("exception"),
103
104        /**
105         * Used for instances of {@link HiddenTree}
106         * representing an @hidden tag.
107         */
108        HIDDEN("hidden"),
109
110        /**
111         * Used for instances of {@link IdentifierTree}
112         * representing an identifier.
113         */
114        IDENTIFIER,
115
116        /**
117         * Used for instances of {@link IndexTree}
118         * representing a search term.
119         */
120        INDEX("index"),
121
122        /**
123         * Used for instances of {@link InheritDocTree}
124         * representing an @inheritDoc tag.
125         */
126        INHERIT_DOC("inheritDoc"),
127
128        /**
129         * Used for instances of {@link LinkTree}
130         * representing an @link tag.
131         */
132        LINK("link"),
133
134        /**
135         * Used for instances of {@link LinkTree}
136         * representing an @linkplain tag.
137         */
138        LINK_PLAIN("linkplain"),
139
140        /**
141         * Used for instances of {@link LiteralTree}
142         * representing an @literal tag.
143         */
144        LITERAL("literal"),
145
146        /**
147         * Used for instances of {@link ParamTree}
148         * representing an @param tag.
149         */
150        PARAM("param"),
151
152        /**
153         * Used for instances of {@link ReferenceTree}
154         * representing a reference to a element in the
155         * Java programming language.
156         */
157        REFERENCE,
158
159        /**
160         * Used for instances of {@link ReturnTree}
161         * representing an @return tag.
162         */
163        RETURN("return"),
164
165        /**
166         * Used for instances of {@link SeeTree}
167         * representing an @see tag.
168         */
169        SEE("see"),
170
171        /**
172         * Used for instances of {@link SerialTree}
173         * representing an @serial tag.
174         */
175        SERIAL("serial"),
176
177        /**
178         * Used for instances of {@link SerialDataTree}
179         * representing an @serialData tag.
180         */
181        SERIAL_DATA("serialData"),
182
183        /**
184         * Used for instances of {@link SerialFieldTree}
185         * representing an @serialField tag.
186         */
187        SERIAL_FIELD("serialField"),
188
189        /**
190         * Used for instances of {@link SinceTree}
191         * representing an @since tag.
192         */
193        SINCE("since"),
194
195        /**
196         * Used for instances of {@link EndElementTree}
197         * representing the start of an HTML element.
198         */
199        START_ELEMENT,
200
201        /**
202         * Used for instances of {@link TextTree}
203         * representing some documentation text.
204         */
205        TEXT,
206
207        /**
208         * Used for instances of {@link ThrowsTree}
209         * representing an @throws tag.
210         */
211        THROWS("throws"),
212
213        /**
214         * Used for instances of {@link UnknownBlockTagTree}
215         * representing an unknown block tag.
216         */
217        UNKNOWN_BLOCK_TAG,
218
219        /**
220         * Used for instances of {@link UnknownInlineTagTree}
221         * representing an unknown inline tag.
222         */
223        UNKNOWN_INLINE_TAG,
224
225        /**
226         * Used for instances of {@link ValueTree}
227         * representing an @value tag.
228         */
229        VALUE("value"),
230
231        /**
232         * Used for instances of {@link VersionTree}
233         * representing an @version tag.
234         */
235        VERSION("version"),
236
237        /**
238         * An implementation-reserved node. This is the not the node
239         * you are looking for.
240         */
241        OTHER;
242
243        /**
244         * The name of the tag, if any, associated with this kind of node.
245         */
246        public final String tagName;
247
248        Kind() {
249            tagName = null;
250        }
251
252        Kind(String tagName) {
253            this.tagName = tagName;
254        }
255    }
256
257    /**
258     * Returns the kind of this tree.
259     *
260     * @return the kind of this tree.
261     */
262    Kind getKind();
263
264    /**
265     * Accept method used to implement the visitor pattern.  The
266     * visitor pattern is used to implement operations on trees.
267     *
268     * @param <R> result type of this operation.
269     * @param <D> type of additional data.
270     * @param visitor the visitor to be called
271     * @param data a parameter value to be passed to the visitor method
272     * @return the value returned from the visitor method
273     */
274    <R, D> R accept(DocTreeVisitor<R,D> visitor, D data);
275}
276