KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > javadoc > JavadocTag


1 ////////////////////////////////////////////////////////////////////////////////
2
// checkstyle: Checks Java source code for adherence to a set of rules.
3
// Copyright (C) 2001-2005 Oliver Burn
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2.1 of the License, or (at your option) any later version.
9
//
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
////////////////////////////////////////////////////////////////////////////////
19
package com.puppycrawl.tools.checkstyle.checks.javadoc;
20
21 /**
22  * Represents a Javadoc tag. Provides methods to query what type of tag it is.
23  * @author Oliver Burn
24  **/

25 class JavadocTag
26 {
27     /** the line number of the tag **/
28     private final int mLineNo;
29     /** the column number of the tag **/
30     private int mColumnNo;
31     /** the tag string **/
32     private final String JavaDoc mTag;
33     /** an optional first argument. For example the parameter name. **/
34     private final String JavaDoc mArg1;
35
36     /**
37      * Constructs the object.
38      * @param aLine the line number of the tag
39      * @param aColumn the column number of the tag
40      * @param aTag the tag string
41      * @param aArg1 the tag argument
42      **/

43     JavadocTag(int aLine, int aColumn, String JavaDoc aTag, String JavaDoc aArg1)
44     {
45         mLineNo = aLine;
46         mColumnNo = aColumn;
47         mTag = aTag;
48         mArg1 = aArg1;
49     }
50
51     /**
52      * Constructs the object.
53      * @param aLine the line number of the tag
54      * @param aColumn the column number of the tag
55      * @param aTag the tag string
56      **/

57     JavadocTag(int aLine, int aColumn, String JavaDoc aTag)
58     {
59         this(aLine, aColumn, aTag, null);
60     }
61
62     /** @return the tag string **/
63     String JavaDoc getTag()
64     {
65         return mTag;
66     }
67
68     /** @return the first argument. null if not set. **/
69     String JavaDoc getArg1()
70     {
71         return mArg1;
72     }
73
74     /** @return the line number **/
75     int getLineNo()
76     {
77         return mLineNo;
78     }
79
80     /** @return the column number */
81     int getColumnNo()
82     {
83         return mColumnNo;
84     }
85
86     /** @return a string representation of the object **/
87     public String JavaDoc toString()
88     {
89         return "{Tag = '" + getTag() + "', lineNo = " + getLineNo()
90             + ", columnNo=" + mColumnNo + ", Arg1 = '" + getArg1() + "'}";
91     }
92
93     /** @return whether the tag is an 'author' tag **/
94     boolean isAuthorTag()
95     {
96         return "author".equals(getTag());
97     }
98
99     /** @return whether the tag is an 'return' tag **/
100     boolean isReturnTag()
101     {
102         return "return".equals(getTag());
103     }
104
105     /** @return whether the tag is an 'param' tag **/
106     boolean isParamTag()
107     {
108         return "param".equals(getTag());
109     }
110
111     /** @return whether the tag is an 'throws' or 'exception' tag **/
112     boolean isThrowsTag()
113     {
114         return ("throws".equals(getTag()) || "exception".equals(getTag()));
115     }
116
117     /** @return whether the tag is a 'see' or 'inheritDoc' tag **/
118     boolean isSeeOrInheritDocTag()
119     {
120         return ("see".equals(getTag()) || isInheritDocTag());
121     }
122
123     /** @return whether the tag is a 'inheritDoc' tag **/
124     boolean isInheritDocTag()
125     {
126         return "inheritDoc".equals(getTag());
127     }
128 }
129
130
Popular Tags