Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/puppycrawl/tools/checkstyle/checks/JavadocTag.java


1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2002  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;
20  
21  /**
22   * Represents a Javadoc tag. Provides methods to query what type of tag it is.
23   * @author <a href="mailto:oliver@puppycrawl.com">Oliver Burn</a>
24   **/
25  class JavadocTag
26  {
27      /** the line number of the tag **/
28      private final int mLineNo;
29      /** the tag string **/
30      private final String mTag;
31      /** an optional first argument. For example the parameter name. **/
32      private final String mArg1;
33  
34      /**
35       * Constructs the object.
36       * @param aLine the line number of the tag
37       * @param aTag the tag string
38       * @param aArg1 the tag argument
39       **/
40      JavadocTag(int aLine, String aTag, String aArg1)
41      {
42          mLineNo = aLine;
43          mTag = aTag;
44          mArg1 = aArg1;
45      }
46  
47      /**
48       * Constructs the object.
49       * @param aLine the line number of the tag
50       * @param aTag the tag string
51       **/
52      JavadocTag(int aLine, String aTag)
53      {
54          this(aLine, aTag, null);
55      }
56  
57      /** @return the tag string **/
58      String getTag()
59      {
60          return mTag;
61      }
62  
63      /** @return the first argument. null if not set. **/
64      String getArg1()
65      {
66          return mArg1;
67      }
68  
69      /** @return the line number **/
70      int getLineNo()
71      {
72          return mLineNo;
73      }
74  
75      /** @return a string representation of the object **/
76      public String toString()
77      {
78          return "{Tag = '" + getTag() + "', lineNo = " + getLineNo()
79              + ", Arg1 = '" + getArg1() + "'}";
80      }
81  
82      /** @return whether the tag is an 'author' tag **/
83      boolean isAuthorTag()
84      {
85          return "author".equals(getTag());
86      }
87  
88      /** @return whether the tag is an 'return' tag **/
89      boolean isReturnTag()
90      {
91          return "return".equals(getTag());
92      }
93  
94      /** @return whether the tag is an 'param' tag **/
95      boolean isParamTag()
96      {
97          return "param".equals(getTag());
98      }
99  
100     /** @return whether the tag is an 'throws' or 'exception' tag **/
101     boolean isThrowsTag()
102     {
103         return ("throws".equals(getTag()) || "exception".equals(getTag()));
104     }
105 
106     /** @return whether the tag is a 'see' or 'inheritDoc' tag **/
107     boolean isSeeOrInheritDocTag()
108     {
109         return ("see".equals(getTag()) || "inheritDoc".equals(getTag()));
110     }
111 }
112