Source Code Cross Referenced for GetTypeSummary.java in  » UML » jrefactory » org » acm » seguin » summary » query » 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 » UML » jrefactory » org.acm.seguin.summary.query 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         * The JRefactory License, Version 1.0
003:         *
004:         * Copyright (c) 2001 JRefactory.  All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * 1. Redistributions of source code must retain the above copyright
011:         *    notice, this list of conditions and the following disclaimer.
012:         *
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         *    notice, this list of conditions and the following disclaimer in
015:         *    the documentation and/or other materials provided with the
016:         *    distribution.
017:         *
018:         * 3. The end-user documentation included with the redistribution,
019:         *    if any, must include the following acknowledgment:
020:         *       "This product includes software developed by the
021:         *        JRefactory (http://www.sourceforge.org/projects/jrefactory)."
022:         *    Alternately, this acknowledgment may appear in the software itself,
023:         *    if and wherever such third-party acknowledgments normally appear.
024:         *
025:         * 4. The names "JRefactory" must not be used to endorse or promote
026:         *    products derived from this software without prior written
027:         *    permission. For written permission, please contact seguin@acm.org.
028:         *
029:         * 5. Products derived from this software may not be called "JRefactory",
030:         *    nor may "JRefactory" appear in their name, without prior written
031:         *    permission of Chris Seguin.
032:         *
033:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
034:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
035:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
036:         * DISCLAIMED.  IN NO EVENT SHALL THE CHRIS SEGUIN OR
037:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
038:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
039:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
040:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
041:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
042:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
043:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
044:         * SUCH DAMAGE.
045:         * ====================================================================
046:         *
047:         * This software consists of voluntary contributions made by many
048:         * individuals on behalf of JRefactory.  For more information on
049:         * JRefactory, please see
050:         * <http://www.sourceforge.org/projects/jrefactory>.
051:         */
052:        package org.acm.seguin.summary.query;
053:
054:        import java.util.Iterator;
055:        import org.acm.seguin.summary.FileSummary;
056:        import org.acm.seguin.summary.ImportSummary;
057:        import org.acm.seguin.summary.MethodSummary;
058:        import org.acm.seguin.summary.PackageSummary;
059:        import org.acm.seguin.summary.Summary;
060:        import org.acm.seguin.summary.TypeDeclSummary;
061:        import org.acm.seguin.summary.TypeSummary;
062:
063:        /**
064:         *  Gets the type summary associated with a particular type declaration, file,
065:         *  or package.
066:         *
067:         *@author     Chris Seguin
068:         *@created    November 30, 1999
069:         */
070:        public class GetTypeSummary {
071:            /**
072:             *  Get the type summary that this object refers to. If the type summary is
073:             *  not found or the type is primitive, a null is returned. If the input is
074:             *  null, the output is also null.
075:             *
076:             *@param  typeDecl  the place to start the search
077:             *@return           the type summary or null
078:             */
079:            public static TypeSummary query(TypeDeclSummary typeDecl) {
080:                if (typeDecl == null) {
081:                    return null;
082:                }
083:
084:                //  Check if it is primitive
085:                if (typeDecl.isPrimitive()) {
086:                    return null;
087:                }
088:
089:                String packageName = typeDecl.getPackage();
090:                String typeName = typeDecl.getType();
091:                if (packageName != null) {
092:                    //  Look up the type in the specified package
093:                    PackageSummary packageSummary = PackageSummary
094:                            .getPackageSummary(packageName);
095:                    return query(packageSummary, typeName);
096:                } else {
097:                    //  Find file summary in parent
098:                    Summary next = typeDecl.getParent();
099:                    while (!(next instanceof  FileSummary)) {
100:                        next = next.getParent();
101:                    }
102:
103:                    FileSummary fileSummary = (FileSummary) next;
104:
105:                    //  Look up the type in the file summary
106:                    return query(fileSummary, typeName);
107:                }
108:            }
109:
110:            /**
111:             *  Searches a package for a particular type. This method returns the type,
112:             *  if it is found. If it is not found or the name is null, this method
113:             *  returns null.
114:             *
115:             *@param  fileSummary  the file summary
116:             *@param  name         the name of the type summary
117:             *@return              the type summary if it is found and null otherwise
118:             */
119:            public static TypeSummary query(FileSummary fileSummary, String name) {
120:                //System.out.println("Searching " + fileSummary.getName() + "(FileSummary) for " + name);
121:                //  Check for null pointers
122:                if (name == null) {
123:                    return null;
124:                }
125:
126:                TypeSummary result = null;
127:
128:                //  First try with the package
129:                result = query((PackageSummary) fileSummary.getParent(), name);
130:                if (result != null) {
131:                    //System.out.println("Found " + name + " in the current package");
132:                    return result;
133:                }
134:
135:                //  Then try each import statement
136:                result = checkImports(fileSummary, name);
137:                if (result != null) {
138:                    //System.out.println("Found " + name + " in an import statement");
139:                    return result;
140:                }
141:
142:                //  Try in java.lang
143:                PackageSummary nextPackage = PackageSummary
144:                        .getPackageSummary("java.lang");
145:                result = query(nextPackage, name);
146:
147:                if (result != null) {
148:                    //System.out.println("Found " + name + " in java.lang");
149:                }
150:
151:                //  Not found
152:                return result;
153:            }
154:
155:            /**
156:             *  Searches a package for a particular type. This method returns the type,
157:             *  if it is found. If it is not found or the name is null, this method
158:             *  returns null.
159:             *
160:             *@param  packageSummary  the package summary
161:             *@param  name            the name of the type summary
162:             *@return                 the type summary if it is found and null otherwise
163:             */
164:            public static TypeSummary query(PackageSummary packageSummary,
165:                    String name) {
166:                //System.out.println("Searching " + packageSummary.getName() + "(PackageSummary) for " + name);
167:                //  Check for null pointers
168:                if (name == null) {
169:                    return null;
170:                }
171:
172:                Iterator fileIterator = packageSummary.getFileSummaries();
173:                if (fileIterator != null) {
174:                    while (fileIterator.hasNext()) {
175:                        FileSummary nextFile = (FileSummary) fileIterator
176:                                .next();
177:
178:                        TypeSummary result = checkType(nextFile, name);
179:                        if (result != null) {
180:                            //System.out.println("Found " + name + " in " + nextFile.getName());
181:                            return result;
182:                        }
183:                    }
184:                }
185:
186:                //  Not found
187:                return null;
188:            }
189:
190:            /**
191:             *  Searches a package for a particular type. This method returns the type,
192:             *  if it is found. If it is not found or the name is null, this method
193:             *  returns null.
194:             *
195:             *@param  packageName  the package name
196:             *@param  name         the name of the type summary
197:             *@return              the type summary if it is found and null otherwise
198:             */
199:            public static TypeSummary query(String packageName, String name) {
200:                return query(PackageSummary.getPackageSummary(packageName),
201:                        name);
202:            }
203:
204:            /**
205:             *  Finds a nested type based on the name of the object
206:             *
207:             *@param  parent  the parent type
208:             *@param  name    the name of the method
209:             *@return         the type summary if found or null otherwise
210:             */
211:            public static TypeSummary query(TypeSummary parent, String name) {
212:                Iterator iter = parent.getTypes();
213:                if (iter == null) {
214:                    return null;
215:                }
216:
217:                while (iter.hasNext()) {
218:                    TypeSummary next = (TypeSummary) iter.next();
219:                    if (next.getName().equals(name)) {
220:                        return next;
221:                    }
222:                }
223:
224:                return null;
225:            }
226:
227:            /**
228:             *  Finds a nested type based on the name of the object
229:             *
230:             *@param  parent  the parent type
231:             *@param  name    the name of the method
232:             *@return         the type summary if found or null otherwise
233:             */
234:            public static TypeSummary query(MethodSummary parent, String name) {
235:                Iterator iter = parent.getDependencies();
236:                if (iter == null) {
237:                    return null;
238:                }
239:
240:                while (iter.hasNext()) {
241:                    Summary next = (Summary) iter.next();
242:                    if (next instanceof  TypeSummary) {
243:                        TypeSummary consider = (TypeSummary) next;
244:                        if (consider.getName().equals(name)) {
245:                            return consider;
246:                        }
247:                    }
248:                }
249:
250:                return null;
251:            }
252:
253:            /**
254:             *  Searches for the type based on the imports
255:             *
256:             *@param  fileSummary  the file summaries
257:             *@param  name         the name we are looking for
258:             *@return              Description of the Returned Value
259:             */
260:            private static TypeSummary checkImports(FileSummary fileSummary,
261:                    String name) {
262:                Iterator iter = fileSummary.getImports();
263:                if (iter != null) {
264:                    while (iter.hasNext()) {
265:                        ImportSummary next = (ImportSummary) iter.next();
266:                        //System.out.println("Searching " + next.getPackage().getName()
267:                        //	+ ((next.getType() == null) ? ".*" : ("." + next.getType()))
268:                        //	+ "(ImportSummary) for " + name);
269:                        String nextTypeName = next.getType();
270:                        if ((nextTypeName == null)
271:                                || (nextTypeName.equals(name))) {
272:                            PackageSummary nextPackage = next.getPackage();
273:                            TypeSummary result = query(nextPackage, name);
274:                            if (result != null) {
275:                                return result;
276:                            }
277:                        }
278:                    }
279:                }
280:
281:                return null;
282:            }
283:
284:            /**
285:             *  Description of the Method
286:             *
287:             *@param  summary  Description of Parameter
288:             *@param  name     Description of Parameter
289:             *@return          Description of the Returned Value
290:             */
291:            private static TypeSummary checkType(FileSummary summary,
292:                    String name) {
293:                Iterator typeIterator = summary.getTypes();
294:                if (typeIterator != null) {
295:                    while (typeIterator.hasNext()) {
296:                        TypeSummary nextType = (TypeSummary) typeIterator
297:                                .next();
298:                        //System.out.println("Searching " + nextType.getName() + "(TypeSummary) for " + name);
299:                        if ((nextType != null)
300:                                && nextType.getName().equals(name)) {
301:                            return nextType;
302:                        }
303:                    }
304:                }
305:
306:                return null;
307:            }
308:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.