src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java

changeset 1
9a66ca7c79fa
child 554
9d9f26857129
equal deleted inserted replaced
-1:000000000000 1:9a66ca7c79fa
1 /*
2 * Copyright 1997-2003 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package com.sun.tools.javadoc;
27
28 import com.sun.javadoc.*;
29
30 /**
31 * Represents a @throws or @exception documentation tag.
32 * Parses and holds the exception name and exception comment.
33 * The exception name my be the name of a type variable.
34 * Note: @exception is a backwards compatible synonymy for @throws.
35 *
36 * @author Robert Field
37 * @author Atul M Dambalkar
38 * @see ExecutableMemberDocImpl#throwsTags()
39 *
40 */
41 class ThrowsTagImpl extends TagImpl implements ThrowsTag {
42
43 private final String exceptionName;
44 private final String exceptionComment;
45
46 ThrowsTagImpl(DocImpl holder, String name, String text) {
47 super(holder, name, text);
48 String[] sa = divideAtWhite();
49 exceptionName = sa[0];
50 exceptionComment = sa[1];
51 }
52
53 /**
54 * Return the exception name.
55 */
56 public String exceptionName() {
57 return exceptionName;
58 }
59
60 /**
61 * Return the exception comment.
62 */
63 public String exceptionComment() {
64 return exceptionComment;
65 }
66
67 /**
68 * Return the exception as a ClassDocImpl.
69 */
70 public ClassDoc exception() {
71 ClassDocImpl exceptionClass;
72 if (!(holder instanceof ExecutableMemberDoc)) {
73 exceptionClass = null;
74 } else {
75 ExecutableMemberDocImpl emd = (ExecutableMemberDocImpl)holder;
76 ClassDocImpl con = (ClassDocImpl)emd.containingClass();
77 exceptionClass = (ClassDocImpl)con.findClass(exceptionName);
78 }
79 return exceptionClass;
80 }
81
82 /**
83 * Return the type that represents the exception.
84 * This may be a <code>ClassDoc</code> or a <code>TypeVariable</code>.
85 */
86 public Type exceptionType() {
87 //###(gj) TypeVariable not yet supported.
88 return exception();
89 }
90
91
92 /**
93 * Return the kind of this tag. Always "@throws" for instances
94 * of ThrowsTagImpl.
95 */
96 public String kind() {
97 return "@throws";
98 }
99
100 /**
101 * For the exception comment with embedded @link tags return the array of
102 * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s).
103 *
104 * @return TagImpl[] Array of tags with inline SeeTagImpls.
105 * @see TagImpl#inlineTagImpls()
106 * @see ParamTagImpl#inlineTagImpls()
107 */
108 public Tag[] inlineTags() {
109 return Comment.getInlineTags(holder, exceptionComment());
110 }
111 }

mercurial