47 |
47 |
48 /** |
48 /** |
49 * Stores the set of packages that the classes specified on the command line |
49 * Stores the set of packages that the classes specified on the command line |
50 * belong to. Note that the default package is "". |
50 * belong to. Note that the default package is "". |
51 */ |
51 */ |
52 private Set packageSet; |
52 private Set<String> packageSet; |
53 |
53 |
54 |
54 |
55 /** |
55 /** |
56 * Stores all classes for each package |
56 * Stores all classes for each package |
57 */ |
57 */ |
58 private Map allClasses; |
58 private Map<String,Set<ClassDoc>> allClasses; |
59 |
59 |
60 /** |
60 /** |
61 * Stores ordinary classes (excluding Exceptions and Errors) for each |
61 * Stores ordinary classes (excluding Exceptions and Errors) for each |
62 * package |
62 * package |
63 */ |
63 */ |
64 private Map ordinaryClasses; |
64 private Map<String,Set<ClassDoc>> ordinaryClasses; |
65 |
65 |
66 /** |
66 /** |
67 * Stores exceptions for each package |
67 * Stores exceptions for each package |
68 */ |
68 */ |
69 private Map exceptions; |
69 private Map<String,Set<ClassDoc>> exceptions; |
70 |
70 |
71 /** |
71 /** |
72 * Stores enums for each package. |
72 * Stores enums for each package. |
73 */ |
73 */ |
74 private Map enums; |
74 private Map<String,Set<ClassDoc>> enums; |
75 |
75 |
76 /** |
76 /** |
77 * Stores annotation types for each package. |
77 * Stores annotation types for each package. |
78 */ |
78 */ |
79 private Map annotationTypes; |
79 private Map<String,Set<ClassDoc>> annotationTypes; |
80 |
80 |
81 /** |
81 /** |
82 * Stores errors for each package |
82 * Stores errors for each package |
83 */ |
83 */ |
84 private Map errors; |
84 private Map<String,Set<ClassDoc>> errors; |
85 |
85 |
86 /** |
86 /** |
87 * Stores interfaces for each package |
87 * Stores interfaces for each package |
88 */ |
88 */ |
89 private Map interfaces; |
89 private Map<String,Set<ClassDoc>> interfaces; |
90 |
90 |
91 /** |
91 /** |
92 * Construct a new ClassDocCatalog. |
92 * Construct a new ClassDocCatalog. |
93 * |
93 * |
94 * @param classdocs the array of ClassDocs to catalog |
94 * @param classdocs the array of ClassDocs to catalog |
107 public ClassDocCatalog () { |
107 public ClassDocCatalog () { |
108 init(); |
108 init(); |
109 } |
109 } |
110 |
110 |
111 private void init() { |
111 private void init() { |
112 allClasses = new HashMap(); |
112 allClasses = new HashMap<String,Set<ClassDoc>>(); |
113 ordinaryClasses = new HashMap(); |
113 ordinaryClasses = new HashMap<String,Set<ClassDoc>>(); |
114 exceptions = new HashMap(); |
114 exceptions = new HashMap<String,Set<ClassDoc>>(); |
115 enums = new HashMap(); |
115 enums = new HashMap<String,Set<ClassDoc>>(); |
116 annotationTypes = new HashMap(); |
116 annotationTypes = new HashMap<String,Set<ClassDoc>>(); |
117 errors = new HashMap(); |
117 errors = new HashMap<String,Set<ClassDoc>>(); |
118 interfaces = new HashMap(); |
118 interfaces = new HashMap<String,Set<ClassDoc>>(); |
119 packageSet = new HashSet(); |
119 packageSet = new HashSet<String>(); |
120 } |
120 } |
121 |
121 |
122 /** |
122 /** |
123 * Add the given class to the catalog. |
123 * Add the given class to the catalog. |
124 * @param classdoc the ClassDoc to add to the catelog. |
124 * @param classdoc the ClassDoc to add to the catelog. |
146 /** |
146 /** |
147 * Add the given class to the given map. |
147 * Add the given class to the given map. |
148 * @param classdoc the ClassDoc to add to the catelog. |
148 * @param classdoc the ClassDoc to add to the catelog. |
149 * @param map the Map to add the ClassDoc to. |
149 * @param map the Map to add the ClassDoc to. |
150 */ |
150 */ |
151 private void addClass(ClassDoc classdoc, Map map) { |
151 private void addClass(ClassDoc classdoc, Map<String,Set<ClassDoc>> map) { |
152 |
152 |
153 PackageDoc pkg = classdoc.containingPackage(); |
153 PackageDoc pkg = classdoc.containingPackage(); |
154 if (pkg.isIncluded()) { |
154 if (pkg.isIncluded()) { |
155 //No need to catalog this class since it's package is |
155 //No need to catalog this class since it's package is |
156 //included on the command line |
156 //included on the command line |
157 return; |
157 return; |
158 } |
158 } |
159 String key = Util.getPackageName(pkg); |
159 String key = Util.getPackageName(pkg); |
160 Set s = (Set) map.get(key); |
160 Set<ClassDoc> s = map.get(key); |
161 if (s == null) { |
161 if (s == null) { |
162 packageSet.add(key); |
162 packageSet.add(key); |
163 s = new HashSet(); |
163 s = new HashSet<ClassDoc>(); |
164 } |
164 } |
165 s.add(classdoc); |
165 s.add(classdoc); |
166 map.put(key, s); |
166 map.put(key, s); |
167 |
167 |
168 } |
168 } |
169 |
169 |
170 private ClassDoc[] getArray(Map m, String key) { |
170 private ClassDoc[] getArray(Map<String,Set<ClassDoc>> m, String key) { |
171 Set s = (Set) m.get(key); |
171 Set<ClassDoc> s = m.get(key); |
172 if (s == null) { |
172 if (s == null) { |
173 return new ClassDoc[] {}; |
173 return new ClassDoc[] {}; |
174 } else { |
174 } else { |
175 return (ClassDoc[]) s.toArray(new ClassDoc[] {}); |
175 return s.toArray(new ClassDoc[] {}); |
176 } |
176 } |
177 } |
177 } |
178 |
178 |
179 /** |
179 /** |
180 * Return all of the classes specified on the command-line that |
180 * Return all of the classes specified on the command-line that |
200 /** |
200 /** |
201 * Return the array of package names that this catalog stores |
201 * Return the array of package names that this catalog stores |
202 * ClassDocs for. |
202 * ClassDocs for. |
203 */ |
203 */ |
204 public String[] packageNames() { |
204 public String[] packageNames() { |
205 return (String[]) packageSet.toArray(new String[] {}); |
205 return packageSet.toArray(new String[] {}); |
206 } |
206 } |
207 |
207 |
208 /** |
208 /** |
209 * Return true if the given package is known to this catalog. |
209 * Return true if the given package is known to this catalog. |
210 * @param packageName the name to check. |
210 * @param packageName the name to check. |