Source Code Cross Referenced for TypeSummary.java in  » UML » jrefactory » org » acm » seguin » summary » 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 
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;
053:
054:        import java.util.Iterator;
055:        import java.util.LinkedList;
056:        import net.sourceforge.jrefactory.ast.ModifierHolder;
057:        import net.sourceforge.jrefactory.ast.SimpleNode;
058:
059:        /**
060:         *  Stores the summary of a type (either class or interface)
061:         *
062:         *@author     Chris Seguin
063:         *@author     Mike Atkinson
064:         *@created    June 6, 1999
065:         */
066:        public class TypeSummary extends Summary {
067:            //  Instance Variables
068:            private String name;
069:            private boolean bInterface;
070:            private TypeDeclSummary parentClass;
071:            private LinkedList interfaceList;
072:            private LinkedList methodList;
073:            private LinkedList fieldList;
074:            private LinkedList typeList;
075:
076:            /**
077:             *  Creates a TypeSummary object
078:             *
079:             *@param  parentSummary  the parent summary
080:             *@param  typeDecl       the type declaration
081:             */
082:            public TypeSummary(Summary parentSummary, SimpleNode typeDecl) {
083:                //  Invoke parent class constructor
084:                super (parentSummary);
085:
086:                //  Initialize the variables
087:                name = "";
088:                bInterface = false;
089:                methodList = null;
090:                fieldList = null;
091:                typeList = null;
092:                interfaceList = null;
093:                parentClass = null;
094:            }
095:
096:            /**
097:             *  Set the name of this object
098:             *
099:             *@param  newName  the name
100:             */
101:            public void setName(String newName) {
102:                name = newName;
103:            }
104:
105:            /**
106:             *  Check to see if this is an interface or a class
107:             *
108:             *@return    true if this is an interface
109:             */
110:            public boolean isInterface() {
111:                return bInterface;
112:            }
113:
114:            /**
115:             *  Get the name of this object
116:             *
117:             *@return    the name
118:             */
119:            public String getName() {
120:                return name;
121:            }
122:
123:            /**
124:             *  Return the list of methods
125:             *
126:             *@return    an iterator of methods
127:             */
128:            public Iterator getMethods() {
129:                if (methodList == null) {
130:                    return null;
131:                }
132:
133:                return methodList.iterator();
134:            }
135:
136:            /**
137:             *  Get the total number of methods - class and instance - that are
138:             *  associated with this object.
139:             *
140:             *@return    the number of methods
141:             */
142:            public int getMethodCount() {
143:                if (methodList == null) {
144:                    return 0;
145:                }
146:
147:                return methodList.size();
148:            }
149:
150:            /**
151:             *  Return a list of fields
152:             *
153:             *@return    an iterator of fields
154:             */
155:            public Iterator getFields() {
156:                if (fieldList == null) {
157:                    return null;
158:                }
159:
160:                return fieldList.iterator();
161:            }
162:
163:            /**
164:             *  Get the total number of fields - class and instance - that are
165:             *  associated with this object.
166:             *
167:             *@return    the number of fields
168:             */
169:            public int getFieldCount() {
170:                if (fieldList == null) {
171:                    return 0;
172:                }
173:                return fieldList.size();
174:            }
175:
176:            /**
177:             *  Return the iterator over the types
178:             *
179:             *@return    an iterator full of types
180:             */
181:            public Iterator getTypes() {
182:                if (typeList == null) {
183:                    return null;
184:                }
185:
186:                return typeList.iterator();
187:            }
188:
189:            /**
190:             *  Get the total number of nested class and interface declarations that are
191:             *  associated with this object.
192:             *
193:             *@return    the number of nested classes and interfaces
194:             */
195:            public int getTypeCount() {
196:                if (typeList == null) {
197:                    return 0;
198:                }
199:                return typeList.size();
200:            }
201:
202:            /**
203:             *  Return a list of the types that this class/interface implements
204:             *
205:             *@return    an iterator of the types
206:             */
207:            public Iterator getImplementedInterfaces() {
208:                if (interfaceList == null) {
209:                    return null;
210:                }
211:
212:                return interfaceList.iterator();
213:            }
214:
215:            /*
216:             public boolean implementsInterface(String intf) {
217:             if (interfaceList==null) {
218:             return false;
219:             }
220:             Iterator i = interfaceList.iterator();
221:             while (i.hasNext()) {
222:             TypeDeclSummary x = (TypeDeclSummary)i.next();
223:            
224:             if (intf.equals(x.name)) {
225:             return true;
226:             } else if (x.interfaceList != null) {
227:             if (x.implementsInterface(intf)) {
228:             return true;
229:             }
230:             }
231:             }
232:             if (parentClass != null) {
233:             }
234:             }
235:             */
236:            /**
237:             *  Return the parent class
238:             *
239:             *@return    the type declaration representing the parent class
240:             */
241:            public TypeDeclSummary getParentClass() {
242:                return parentClass;
243:            }
244:
245:            /**
246:             *  Finds the package summary associated with this type
247:             *
248:             *@return    the package summary
249:             */
250:            public PackageSummary getPackageSummary() {
251:                Summary current = getParent();
252:                while ((current != null)
253:                        && !(current instanceof  PackageSummary)) {
254:                    current = current.getParent();
255:                }
256:
257:                return (PackageSummary) current;
258:            }
259:
260:            /**
261:             *  Gets a field by a name
262:             *
263:             *@param  name  the name of the field
264:             *@return       the field summary
265:             */
266:            public FieldSummary getField(String name) {
267:                Iterator iter = getFields();
268:                if (iter != null) {
269:                    while (iter.hasNext()) {
270:                        FieldSummary next = (FieldSummary) iter.next();
271:                        if (next.getName().equals(name)) {
272:                            return next;
273:                        }
274:                    }
275:                }
276:
277:                return null;
278:            }
279:
280:            /**
281:             *  Provide method to visit a node
282:             *
283:             *@param  visitor  the visitor
284:             *@param  data     the data for the visit
285:             *@return          some new data
286:             */
287:            public Object accept(SummaryVisitor visitor, Object data) {
288:                return visitor.visit(this , data);
289:            }
290:
291:            /**
292:             *  Convert this object to a string
293:             *
294:             *@return    a string
295:             */
296:            public String toString() {
297:                return getName();
298:            }
299:
300:            /**
301:             *  Add a method summary
302:             *
303:             *@param  methodSummary  the method summary
304:             */
305:            protected void add(MethodSummary methodSummary) {
306:                if (methodSummary != null) {
307:                    if (methodList == null) {
308:                        initMethodList();
309:                    }
310:
311:                    methodList.add(methodSummary);
312:                }
313:            }
314:
315:            /**
316:             *  Add a field summary
317:             *
318:             *@param  fieldSummary  the field summary
319:             */
320:            protected void add(FieldSummary fieldSummary) {
321:                if (fieldSummary != null) {
322:                    if (fieldList == null) {
323:                        initFieldList();
324:                    }
325:
326:                    fieldList.add(fieldSummary);
327:                }
328:            }
329:
330:            /**
331:             *  Add a type summary
332:             *
333:             *@param  typeSummary  the type summary
334:             */
335:            protected void add(TypeSummary typeSummary) {
336:                if (typeSummary != null) {
337:                    if (typeList == null) {
338:                        initTypeList();
339:                    }
340:
341:                    typeList.add(typeSummary);
342:                }
343:            }
344:
345:            /**
346:             *  Add an interface summary
347:             *
348:             *@param  typeDeclSummary  the interface summary
349:             */
350:            protected void add(TypeDeclSummary typeDeclSummary) {
351:                if (typeDeclSummary != null) {
352:                    if (interfaceList == null) {
353:                        initInterfaceList();
354:                    }
355:
356:                    interfaceList.add(typeDeclSummary);
357:                }
358:            }
359:
360:            /**
361:             *  Mark this as an interface or a class
362:             *
363:             *@param  way  the way to set the interface variable
364:             */
365:            void setInterface(boolean way) {
366:                bInterface = way;
367:            }
368:
369:            /**
370:             *  Set the parent class
371:             *
372:             *@param  tds  the type declaration representing the parent class
373:             */
374:            void setParentClass(TypeDeclSummary tds) {
375:                parentClass = tds;
376:            }
377:
378:            /**
379:             *  Gets the Initializer attribute of the TypeSummary object
380:             *
381:             *@param  isStatic  Description of Parameter
382:             *@return           The Initializer value
383:             */
384:            MethodSummary getInitializer(boolean isStatic) {
385:                Iterator iter = getMethods();
386:                if (iter != null) {
387:                    while (iter.hasNext()) {
388:                        MethodSummary next = (MethodSummary) iter.next();
389:                        if (next.isInitializer()) {
390:                            if (next.isStatic() == isStatic) {
391:                                return next;
392:                            }
393:                        }
394:                    }
395:                }
396:
397:                return createInitializer(isStatic);
398:            }
399:
400:            /**
401:             *  Initialize the interface list
402:             */
403:            private void initInterfaceList() {
404:                interfaceList = new LinkedList();
405:            }
406:
407:            /**
408:             *  Initialize the method list
409:             */
410:            private void initMethodList() {
411:                methodList = new LinkedList();
412:            }
413:
414:            /**
415:             *  Initialize the field list
416:             */
417:            private void initFieldList() {
418:                fieldList = new LinkedList();
419:            }
420:
421:            /**
422:             *  Initialize the type list
423:             */
424:            private void initTypeList() {
425:                typeList = new LinkedList();
426:            }
427:
428:            /**
429:             *  Description of the Method
430:             *
431:             *@param  isStatic  Description of Parameter
432:             *@return           Description of the Returned Value
433:             */
434:            private MethodSummary createInitializer(boolean isStatic) {
435:                //  Get the current type summary
436:                MethodSummary methodSummary = new MethodSummary(this );
437:                add(methodSummary);
438:
439:                //  Load the method summary
440:                //  Remember the modifiers
441:                methodSummary.setStatic(isStatic);
442:                methodSummary.setPrivate(true);
443:
444:                //  Load the method names
445:                methodSummary.setName("***Initializer***");
446:
447:                return methodSummary;
448:            }
449:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.