Source Code Cross Referenced for ClassDocCatalog.java in  » 6.0-JDK-Modules-com.sun » tools » com » sun » tools » doclets » internal » toolkit » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules com.sun » tools » com.sun.tools.doclets.internal.toolkit.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.tools.doclets.internal.toolkit.util;
027:
028:        import com.sun.javadoc.*;
029:        import java.util.*;
030:
031:        /**
032:         * This class acts as an artificial PackageDoc for classes specified
033:         * on the command line when running Javadoc.  For example, if you
034:         * specify several classes from package java.lang, this class will catalog
035:         * those classes so that we can retrieve all of the classes from a particular
036:         * package later.
037:         *
038:         * This code is not part of an API.
039:         * It is implementation that is subject to change.
040:         * Do not use it as an API
041:         * 
042:         * @author Jamie Ho
043:         * @since 1.4
044:         */
045:
046:        public class ClassDocCatalog {
047:
048:            /**
049:             * Stores the set of packages that the classes specified on the command line
050:             * belong to.  Note that the default package is "".
051:             */
052:            private Set packageSet;
053:
054:            /**
055:             * Stores all classes for each package
056:             */
057:            private Map allClasses;
058:
059:            /**
060:             * Stores ordinary classes (excluding Exceptions and Errors) for each
061:             * package
062:             */
063:            private Map ordinaryClasses;
064:
065:            /**
066:             * Stores exceptions for each package
067:             */
068:            private Map exceptions;
069:
070:            /**
071:             * Stores enums for each package.
072:             */
073:            private Map enums;
074:
075:            /**
076:             * Stores annotation types for each package.
077:             */
078:            private Map annotationTypes;
079:
080:            /**
081:             * Stores errors for each package
082:             */
083:            private Map errors;
084:
085:            /**
086:             * Stores interfaces for each package
087:             */
088:            private Map interfaces;
089:
090:            /**
091:             * Construct a new ClassDocCatalog.
092:             *
093:             * @param classdocs the array of ClassDocs to catalog
094:             */
095:            public ClassDocCatalog(ClassDoc[] classdocs) {
096:                init();
097:                for (int i = 0; i < classdocs.length; i++) {
098:                    addClassDoc(classdocs[i]);
099:                }
100:            }
101:
102:            /**
103:             * Construct a new ClassDocCatalog.
104:             *
105:             */
106:            public ClassDocCatalog() {
107:                init();
108:            }
109:
110:            private void init() {
111:                allClasses = new HashMap();
112:                ordinaryClasses = new HashMap();
113:                exceptions = new HashMap();
114:                enums = new HashMap();
115:                annotationTypes = new HashMap();
116:                errors = new HashMap();
117:                interfaces = new HashMap();
118:                packageSet = new HashSet();
119:            }
120:
121:            /**
122:             * Add the given class to the catalog.
123:             * @param classdoc the ClassDoc to add to the catelog.
124:             */
125:            public void addClassDoc(ClassDoc classdoc) {
126:                if (classdoc == null) {
127:                    return;
128:                }
129:                addClass(classdoc, allClasses);
130:                if (classdoc.isOrdinaryClass()) {
131:                    addClass(classdoc, ordinaryClasses);
132:                } else if (classdoc.isException()) {
133:                    addClass(classdoc, exceptions);
134:                } else if (classdoc.isEnum()) {
135:                    addClass(classdoc, enums);
136:                } else if (classdoc.isAnnotationType()) {
137:                    addClass(classdoc, annotationTypes);
138:                } else if (classdoc.isError()) {
139:                    addClass(classdoc, errors);
140:                } else if (classdoc.isInterface()) {
141:                    addClass(classdoc, interfaces);
142:                }
143:            }
144:
145:            /**
146:             * Add the given class to the given map.
147:             * @param classdoc the ClassDoc to add to the catelog.
148:             * @param map the Map to add the ClassDoc to.
149:             */
150:            private void addClass(ClassDoc classdoc, Map map) {
151:
152:                PackageDoc pkg = classdoc.containingPackage();
153:                if (pkg.isIncluded()) {
154:                    //No need to catalog this class since it's package is
155:                    //included on the command line
156:                    return;
157:                }
158:                String key = Util.getPackageName(pkg);
159:                Set s = (Set) map.get(key);
160:                if (s == null) {
161:                    packageSet.add(key);
162:                    s = new HashSet();
163:                }
164:                s.add(classdoc);
165:                map.put(key, s);
166:
167:            }
168:
169:            private ClassDoc[] getArray(Map m, String key) {
170:                Set s = (Set) m.get(key);
171:                if (s == null) {
172:                    return new ClassDoc[] {};
173:                } else {
174:                    return (ClassDoc[]) s.toArray(new ClassDoc[] {});
175:                }
176:            }
177:
178:            /**
179:             * Return all of the classes specified on the command-line that
180:             * belong to the given package.
181:             * @param packageDoc the package to return the classes for.
182:             */
183:            public ClassDoc[] allClasses(PackageDoc pkgDoc) {
184:                return pkgDoc.isIncluded() ? pkgDoc.allClasses() : getArray(
185:                        allClasses, Util.getPackageName(pkgDoc));
186:            }
187:
188:            /**
189:             * Return all of the classes specified on the command-line that
190:             * belong to the given package.
191:             * @param packageName the name of the package specified on the
192:             * command-line.
193:             */
194:            public ClassDoc[] allClasses(String packageName) {
195:                return getArray(allClasses, packageName);
196:            }
197:
198:            /**
199:             * Return the array of package names that this catalog stores
200:             * ClassDocs for.
201:             */
202:            public String[] packageNames() {
203:                return (String[]) packageSet.toArray(new String[] {});
204:            }
205:
206:            /**
207:             * Return true if the given package is known to this catalog.
208:             * @param packageName the name to check.
209:             * @return true if this catalog has any information about
210:             * classes in the given package.
211:             */
212:            public boolean isKnownPackage(String packageName) {
213:                return packageSet.contains(packageName);
214:            }
215:
216:            /**
217:             * Return all of the errors specified on the command-line
218:             * that belong to the given package.
219:             * @param packageName the name of the package specified on the
220:             * command-line.
221:             */
222:            public ClassDoc[] errors(String packageName) {
223:                return getArray(errors, packageName);
224:            }
225:
226:            /**
227:             * Return all of the exceptions specified on the command-line
228:             * that belong to the given package.
229:             * @param packageName the name of the package specified on the
230:             * command-line.
231:             */
232:            public ClassDoc[] exceptions(String packageName) {
233:                return getArray(exceptions, packageName);
234:            }
235:
236:            /**
237:             * Return all of the enums specified on the command-line
238:             * that belong to the given package.
239:             * @param packageName the name of the package specified on the
240:             * command-line.
241:             */
242:            public ClassDoc[] enums(String packageName) {
243:                return getArray(enums, packageName);
244:            }
245:
246:            /**
247:             * Return all of the annotation types specified on the command-line
248:             * that belong to the given package.
249:             * @param packageName the name of the package specified on the
250:             * command-line.
251:             */
252:            public ClassDoc[] annotationTypes(String packageName) {
253:                return getArray(annotationTypes, packageName);
254:            }
255:
256:            /**
257:             * Return all of the interfaces specified on the command-line
258:             * that belong to the given package.
259:             * @param packageName the name of the package specified on the
260:             * command-line.
261:             */
262:            public ClassDoc[] interfaces(String packageName) {
263:                return getArray(interfaces, packageName);
264:            }
265:
266:            /**
267:             * Return all of the ordinary classes specified on the command-line
268:             * that belong to the given package.
269:             * @param packageName the name of the package specified on the
270:             * command-line.
271:             */
272:            public ClassDoc[] ordinaryClasses(String packageName) {
273:                return getArray(ordinaryClasses, packageName);
274:            }
275:        }
w_w_w__.j_a_v__a__2___s___.__c_o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.