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

Quick Search    Search Deep

Source code: com/arranger/jarl/util/doclet/JarlDoclet.java


1   package com.arranger.jarl.util.doclet;
2   
3   import com.sun.javadoc.ClassDoc;
4   import com.sun.javadoc.RootDoc;
5   import com.sun.javadoc.Tag;
6   import com.sun.tools.doclets.DocletAbortException;
7   import com.sun.tools.doclets.standard.Standard;
8   
9   import java.util.HashMap;
10  import java.util.Map;
11  
12  /**
13   * JarlDoclet created on Mar 14, 2003
14   */
15  public class JarlDoclet extends Standard {
16  
17      protected static final String TRAIT_ATTRIBUTE = "@traitAttribute";
18      protected static final String STROKE_ATTRIBUTE = "@strokeAttribute";
19      protected static final String WIDGET_ATTRIBUTE = "@widgetAttribute";
20      protected static final String FILTER_ATTRIBUTE = "@filterAttribute";
21  
22      protected Map m_traitMap = new HashMap();
23      protected Map m_strokeMap = new HashMap();
24      protected Map m_widgetMap = new HashMap();
25      protected Map m_filterMap = new HashMap();
26      protected Map m_commonMap = new HashMap();
27  
28      protected static JarlDoclet s_jarlDoclet;
29  
30      public Map getTraitMap() {
31          return m_traitMap;
32      }
33  
34      public Map getStrokeMap() {
35          return m_strokeMap;
36      }
37  
38      public Map getWidgetMap() {
39          return m_widgetMap;
40      }
41  
42      public Map getFilterMap() {
43          return m_filterMap;
44      }
45  
46      public Map getCommonMap() {
47          return m_commonMap;
48      }
49  
50      public static JarlDoclet getJarlDoclet() {
51          return s_jarlDoclet;
52      }
53  
54      public static boolean start(RootDoc root) {
55          try {
56              configuration().setOptions(root);
57  
58              s_jarlDoclet = new JarlDoclet();
59              s_jarlDoclet.startGeneration(root);
60          } catch (DocletAbortException exc) {
61              return false;
62          }
63          return true;
64      }
65  
66      protected void startGeneration(RootDoc rootDoc) {
67          //filter out some custom tags saving for later
68          ClassDoc[] classes = rootDoc.classes();
69          for (int index = 0; index < classes.length; index++) {
70              ClassDoc classDoc = classes[index];
71              Tag[] tags = classDoc.tags();
72              for (int tagIndex = 0; tagIndex < tags.length; tagIndex++) {
73                  processTag(tags[tagIndex]);
74              }
75          }
76      }
77  
78      protected void processTag(Tag tag) {
79          Map set = null;
80          String tagName = tag.name();
81  
82          if (TRAIT_ATTRIBUTE.equals(tagName)) {
83              set = m_traitMap;
84          } else if (STROKE_ATTRIBUTE.equals(tagName)) {
85              set = m_strokeMap;
86          } else if (WIDGET_ATTRIBUTE.equals(tagName)) {
87              set = m_widgetMap;
88          } else if (FILTER_ATTRIBUTE.equals(tagName)) {
89              set = m_filterMap;
90          }
91          if (set == null) {
92              return;
93          }
94  
95          JarlAttributeDef jarlAttributeDef = JarlAttributeDef.getAttributeDef(tag);
96          String name = jarlAttributeDef.getName();
97  
98          boolean isUnique = true;
99          if (m_traitMap.containsKey(name) && !m_traitMap.equals(set)) {
100             m_traitMap.remove(name);
101             isUnique = false;
102         } else if (m_strokeMap.containsKey(name) && !m_strokeMap.equals(set)) {
103             m_strokeMap.remove(name);
104             isUnique = false;
105         } else if (m_widgetMap.containsKey(name) && !m_widgetMap.equals(set)) {
106             m_widgetMap.remove(name);
107             isUnique = false;
108         } else if (m_filterMap.containsKey(name) && !m_filterMap.equals(set)) {
109             m_filterMap.remove(name);
110             isUnique = false;
111         } else if (m_commonMap.containsKey(name)) {
112             isUnique = false;
113         }
114 
115         if (isUnique) {
116             set.put(name, jarlAttributeDef);
117         } else {
118             set.remove(name);
119             m_commonMap.put(name, jarlAttributeDef);
120         }
121     }
122 }