|
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 java.util.regex.*; |
|
29 |
|
30 import com.sun.javadoc.*; |
|
31 |
|
32 /** |
|
33 * Represents an @param documentation tag. |
|
34 * Parses and stores the name and comment parts of the parameter tag. |
|
35 * |
|
36 * @author Robert Field |
|
37 * |
|
38 */ |
|
39 class ParamTagImpl extends TagImpl implements ParamTag { |
|
40 |
|
41 private static Pattern typeParamRE = Pattern.compile("<([^<>]+)>"); |
|
42 |
|
43 private final String parameterName; |
|
44 private final String parameterComment; |
|
45 private final boolean isTypeParameter; |
|
46 |
|
47 ParamTagImpl(DocImpl holder, String name, String text) { |
|
48 super(holder, name, text); |
|
49 String[] sa = divideAtWhite(); |
|
50 |
|
51 Matcher m = typeParamRE.matcher(sa[0]); |
|
52 isTypeParameter = m.matches(); |
|
53 parameterName = isTypeParameter ? m.group(1) : sa[0]; |
|
54 parameterComment = sa[1]; |
|
55 } |
|
56 |
|
57 /** |
|
58 * Return the parameter name. |
|
59 */ |
|
60 public String parameterName() { |
|
61 return parameterName; |
|
62 } |
|
63 |
|
64 /** |
|
65 * Return the parameter comment. |
|
66 */ |
|
67 public String parameterComment() { |
|
68 return parameterComment; |
|
69 } |
|
70 |
|
71 /** |
|
72 * Return the kind of this tag. |
|
73 */ |
|
74 public String kind() { |
|
75 return "@param"; |
|
76 } |
|
77 |
|
78 /** |
|
79 * Return true if this ParamTag corresponds to a type parameter. |
|
80 */ |
|
81 public boolean isTypeParameter() { |
|
82 return isTypeParameter; |
|
83 } |
|
84 |
|
85 /** |
|
86 * convert this object to a string. |
|
87 */ |
|
88 public String toString() { |
|
89 return name + ":" + text; |
|
90 } |
|
91 |
|
92 /** |
|
93 * For the parameter comment with embedded @link tags return the array of |
|
94 * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s). |
|
95 * |
|
96 * @return TagImpl[] Array of tags with inline SeeTagImpls. |
|
97 * @see TagImpl#inlineTagImpls() |
|
98 * @see ThrowsTagImpl#inlineTagImpls() |
|
99 */ |
|
100 public Tag[] inlineTags() { |
|
101 return Comment.getInlineTags(holder, parameterComment); |
|
102 } |
|
103 } |