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

Tue, 09 Oct 2012 19:31:58 -0700

author
jjg
date
Tue, 09 Oct 2012 19:31:58 -0700
changeset 1358
fc123bdeddb8
parent 1053
0d8edba73d70
child 1359
25e14ad23cef
permissions
-rw-r--r--

8000208: fix langtools javadoc comment issues
Reviewed-by: bpatel, mcimadamore

     1 /*
     2  * Copyright (c) 1997, 2012, 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  */
    26 package com.sun.tools.javadoc;
    28 import java.util.regex.*;
    30 import com.sun.javadoc.*;
    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 {
    41     private static Pattern typeParamRE = Pattern.compile("<([^<>]+)>");
    43     private final String parameterName;
    44     private final String parameterComment;
    45     private final boolean isTypeParameter;
    47     /**
    48      * Cached inline tags.
    49      */
    50     private Tag[] inlineTags;
    52     ParamTagImpl(DocImpl holder, String name, String text) {
    53         super(holder, name, text);
    54         String[] sa = divideAtWhite();
    56         Matcher m = typeParamRE.matcher(sa[0]);
    57         isTypeParameter = m.matches();
    58         parameterName = isTypeParameter ? m.group(1) : sa[0];
    59         parameterComment = sa[1];
    60     }
    62     /**
    63      * Return the parameter name.
    64      */
    65     public String parameterName() {
    66         return parameterName;
    67     }
    69     /**
    70      * Return the parameter comment.
    71      */
    72     public String parameterComment() {
    73         return parameterComment;
    74     }
    76     /**
    77      * Return the kind of this tag.
    78      */
    79     @Override
    80     public String kind() {
    81         return "@param";
    82     }
    84     /**
    85      * Return true if this ParamTag corresponds to a type parameter.
    86      */
    87     public boolean isTypeParameter() {
    88         return isTypeParameter;
    89     }
    91     /**
    92      * convert this object to a string.
    93      */
    94     @Override
    95     public String toString() {
    96         return name + ":" + text;
    97     }
    99     /**
   100      * For the parameter comment with embedded @link tags return the array of
   101      * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s).
   102      *
   103      * @return TagImpl[] Array of tags with inline SeeTagImpls.
   104      * @see TagImpl#inlineTags()
   105      * @see ThrowsTagImpl#inlineTags()
   106      */
   107     @Override
   108     public Tag[] inlineTags() {
   109         if (inlineTags == null) {
   110             inlineTags = Comment.getInlineTags(holder, parameterComment);
   111         }
   112         return inlineTags;
   113     }
   114 }

mercurial