KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > incava > doctorj > JavadocTags


1 package org.incava.doctorj;
2
3 import java.util.*;
4 import org.incava.analysis.Analyzer;
5 import org.incava.analysis.Report;
6 import org.incava.util.Collect;
7
8
9 /**
10  * Javadoc tags and the order in which they should appear for each Java type.
11  */

12 public class JavadocTags
13 {
14     public static class TagDescription
15     {
16         String JavaDoc tag;
17
18         int index;
19
20         boolean isTypeTag;
21
22         boolean isCtorTag;
23
24         boolean isMethodTag;
25
26         boolean isFieldTag;
27
28         public TagDescription(String JavaDoc tag, int index, boolean isTypeTag, boolean isCtorTag, boolean isMethodTag, boolean isFieldTag)
29         {
30              this.tag = tag;
31              this.index = index;
32              this.isTypeTag = isTypeTag;
33              this.isCtorTag = isCtorTag;
34              this.isMethodTag = isMethodTag;
35              this.isFieldTag = isFieldTag;
36         }
37     }
38
39     public final static String JavaDoc AUTHOR = "@author";
40
41     public final static String JavaDoc VERSION = "@version";
42
43     public final static String JavaDoc PARAM = "@param";
44
45     public final static String JavaDoc RETURN = "@return";
46
47     public final static String JavaDoc EXCEPTION = "@exception";
48
49     public final static String JavaDoc THROWS = "@throws";
50
51     public final static String JavaDoc SEE = "@see";
52
53     public final static String JavaDoc SINCE = "@since";
54
55     public final static String JavaDoc SERIAL = "@serial";
56
57     public final static String JavaDoc SERIALDATA = "@serialData";
58
59     public final static String JavaDoc SERIALFIELD = "@serialField";
60
61     public final static String JavaDoc DEPRECATED = "@deprecated";
62
63     public final static int CUSTOM_TAG = 999;
64
65     private final static Map tags = new HashMap();
66     
67     // reference: http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javadoc.html
68
static {
69         // tag idx type ctor method field
70
add(new TagDescription(AUTHOR, 0, true, false, false, false));
71         add(new TagDescription(VERSION, 1, true, false, false, false));
72         add(new TagDescription(PARAM, 2, false, true, true, false));
73         add(new TagDescription(RETURN, 3, false, false, true, false));
74         add(new TagDescription(EXCEPTION, 4, false, true, true, false));
75         add(new TagDescription(THROWS, 4, false, true, true, false));
76         add(new TagDescription(SEE, 5, true, true, true, true));
77         add(new TagDescription(SINCE, 6, true, true, true, true));
78         add(new TagDescription(SERIAL, 7, true, false, false, true));
79         add(new TagDescription(SERIALDATA, 7, false, true, true, false));
80         add(new TagDescription(SERIALFIELD, 7, false, false, false, true));
81         add(new TagDescription(DEPRECATED, 8, true, true, true, true));
82     }
83
84     public static void add(TagDescription td)
85     {
86         tags.put(td.tag, td);
87     }
88
89     public static int getIndex(String JavaDoc tag)
90     {
91         if (tags.containsKey(tag)) {
92             TagDescription td = (TagDescription)tags.get(tag);
93             return td.index;
94         }
95         else {
96             return -1;
97         }
98     }
99
100     public static List getTagsAtIndex(int index)
101     {
102         Iterator it = tags.keySet().iterator();
103         List list = new ArrayList();
104         while (it.hasNext()) {
105             String JavaDoc tag = (String JavaDoc)it.next();
106             TagDescription td = (TagDescription)tags.get(tag);
107             if (td.index == index) {
108                 list.add(tag);
109             }
110         }
111         return list;
112     }
113
114     static abstract class TagCollect extends Collect
115     {
116         public TagCollect(Collection c)
117         {
118             super(c);
119         }
120         
121         public Object JavaDoc block(Object JavaDoc obj)
122         {
123             return ((TagDescription)obj).tag;
124         }
125     }
126     
127     public static List getValidConstructorTags()
128     {
129         return new TagCollect(tags.values()) {
130                 public boolean where(Object JavaDoc obj) { return ((TagDescription)obj).isCtorTag; }
131             };
132     }
133
134     public static List getValidMethodTags()
135     {
136         return new TagCollect(tags.values()) {
137                 public boolean where(Object JavaDoc obj) { return ((TagDescription)obj).isMethodTag; }
138             };
139     }
140
141     public static List getValidFieldTags()
142     {
143         return new TagCollect(tags.values()) {
144                 public boolean where(Object JavaDoc obj) { return ((TagDescription)obj).isFieldTag; }
145             };
146     }
147
148     public static List getValidInterfaceTags()
149     {
150         return new TagCollect(tags.values()) {
151                 public boolean where(Object JavaDoc obj) { return ((TagDescription)obj).isTypeTag; }
152             };
153     }
154
155     public static List getValidClassTags()
156     {
157         return getValidInterfaceTags();
158     }
159 }
160
Popular Tags