001: /*
002: * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.javadoc;
027:
028: import java.util.regex.*;
029:
030: import com.sun.javadoc.*;
031:
032: /**
033: * Represents an @param documentation tag.
034: * Parses and stores the name and comment parts of the parameter tag.
035: *
036: * @author Robert Field
037: *
038: */
039: class ParamTagImpl extends TagImpl implements ParamTag {
040:
041: private static Pattern typeParamRE = Pattern.compile("<([^<>]+)>");
042:
043: private final String parameterName;
044: private final String parameterComment;
045: private final boolean isTypeParameter;
046:
047: ParamTagImpl(DocImpl holder, String name, String text) {
048: super (holder, name, text);
049: String[] sa = divideAtWhite();
050:
051: Matcher m = typeParamRE.matcher(sa[0]);
052: isTypeParameter = m.matches();
053: parameterName = isTypeParameter ? m.group(1) : sa[0];
054: parameterComment = sa[1];
055: }
056:
057: /**
058: * Return the parameter name.
059: */
060: public String parameterName() {
061: return parameterName;
062: }
063:
064: /**
065: * Return the parameter comment.
066: */
067: public String parameterComment() {
068: return parameterComment;
069: }
070:
071: /**
072: * Return the kind of this tag.
073: */
074: public String kind() {
075: return "@param";
076: }
077:
078: /**
079: * Return true if this ParamTag corresponds to a type parameter.
080: */
081: public boolean isTypeParameter() {
082: return isTypeParameter;
083: }
084:
085: /**
086: * convert this object to a string.
087: */
088: public String toString() {
089: return name + ":" + text;
090: }
091:
092: /**
093: * For the parameter comment with embedded @link tags return the array of
094: * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s).
095: *
096: * @return TagImpl[] Array of tags with inline SeeTagImpls.
097: * @see TagImpl#inlineTagImpls()
098: * @see ThrowsTagImpl#inlineTagImpls()
099: */
100: public Tag[] inlineTags() {
101: return Comment.getInlineTags(holder, parameterComment);
102: }
103: }
|