Source Code Cross Referenced for Summary.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.io.Serializable;
055:        import net.sourceforge.jrefactory.ast.ModifierHolder;
056:        import org.acm.seguin.pretty.PrintData;
057:
058:        /**
059:         *  Basic summary class. Provides a single point for a visitor to encounter and
060:         *  a parent summary. All summaries have a parent except package summaries.
061:         *
062:         *@author     Chris Seguin
063:         *@created    May 12, 1999
064:         */
065:        public abstract class Summary implements  ModifierHolder, Serializable {
066:            //  Local Variables
067:            private Summary parent;
068:            private int start;
069:            private int end;
070:            protected int modifiers = 0;
071:
072:            /**
073:             *  Create a summary object
074:             *
075:             *@param  initParent  the parent
076:             */
077:            public Summary(Summary initParent) {
078:                parent = initParent;
079:                start = -1;
080:                end = -1;
081:            }
082:
083:            /**
084:             *  Return the parent object
085:             *
086:             *@return    the parent object
087:             */
088:            public Summary getParent() {
089:                return parent;
090:            }
091:
092:            /**
093:             *  Gets the StartLine attribute of the Summary object
094:             *
095:             *@return    The StartLine value
096:             */
097:            public int getStartLine() {
098:                return start;
099:            }
100:
101:            /**
102:             *  Gets the EndLine attribute of the Summary object
103:             *
104:             *@return    The EndLine value
105:             */
106:            public int getEndLine() {
107:                return end;
108:            }
109:
110:            /**
111:             *  Gets the DeclarationLine attribute of the MethodSummary object
112:             *
113:             *@return    The DeclarationLine value
114:             */
115:            public int getDeclarationLine() {
116:                return Math.min(start + 1, end);
117:            }
118:
119:            /**
120:             *  Returns the name
121:             *
122:             *@return    the name
123:             */
124:            public abstract String getName();
125:
126:            /**
127:             *  Provide method to visit a node
128:             *
129:             *@param  visitor  the visitor
130:             *@param  data     the data for the visit
131:             *@return          some new data
132:             */
133:            public Object accept(SummaryVisitor visitor, Object data) {
134:                return visitor.visit(this , data);
135:            }
136:
137:            /**
138:             *  Sets the StartLine attribute of the Summary object
139:             *
140:             *@param  value  The new StartLine value
141:             */
142:            protected void setStartLine(int value) {
143:                start = value;
144:            }
145:
146:            /**
147:             *  Sets the EndLine attribute of the Summary object
148:             *
149:             *@param  value  The new EndLine value
150:             */
151:            protected void setEndLine(int value) {
152:                end = value;
153:                if (end < start) {
154:                    start = end;
155:                }
156:            }
157:
158:            /**
159:             *  Sets the private bit in the modifiers
160:             *
161:             *@param  value  true if we are setting the private modifier
162:             */
163:            public void setPrivate(boolean value) {
164:                setCode(value, PRIVATE);
165:            }
166:
167:            /**
168:             *  Sets the private bit (to true) in the modifiers
169:             */
170:            public void setPrivate() {
171:                modifiers = modifiers | PRIVATE;
172:            }
173:
174:            /**
175:             *  Sets the protected bit in the modifiers
176:             *
177:             *@param  value  true if we are setting the protected modifier
178:             */
179:            public void setProtected(boolean value) {
180:                setCode(value, PROTECTED);
181:            }
182:
183:            /**
184:             *  Sets the protected bit (to true) in the modifiers
185:             */
186:            public void setProtected() {
187:                modifiers = modifiers | PROTECTED;
188:            }
189:
190:            /**
191:             *  Sets the public bit in the modifiers
192:             *
193:             *@param  value  true if we are setting the public modifier
194:             */
195:            public void setPublic(boolean value) {
196:                setCode(value, PUBLIC);
197:            }
198:
199:            /**
200:             *  Sets the public bit (to true) in the modifiers
201:             */
202:            public void setPublic() {
203:                modifiers = modifiers | PUBLIC;
204:            }
205:
206:            /**
207:             *  Sets the abstract bit in the modifiers
208:             *
209:             *@param  value  true if we are setting the modifier
210:             */
211:            public void setAbstract(boolean value) {
212:                setCode(value, ABSTRACT);
213:            }
214:
215:            /**
216:             *  Sets the abstract bit (to true) in the modifiers
217:             */
218:            public void setAbstract() {
219:                modifiers = modifiers | ABSTRACT;
220:            }
221:
222:            /**
223:             *  Sets the Synchronized bit in the modifiers
224:             *
225:             *@param  value  The new Synchronized value
226:             */
227:            public void setSynchronized(boolean value) {
228:                setCode(value, SYNCHRONIZED);
229:            }
230:
231:            /**
232:             *  Sets the Synchronized bit (to true) in the modifiers
233:             */
234:            public void setSynchronized() {
235:                modifiers = modifiers | SYNCHRONIZED;
236:            }
237:
238:            /**
239:             *  Sets the Static bit in the modifiers
240:             *
241:             *@param  value  The new Static value
242:             */
243:            public void setStatic(boolean value) {
244:                setCode(value, STATIC);
245:            }
246:
247:            /**
248:             *  Sets the Static bit (to true) in the modifiers
249:             */
250:            public void setStatic() {
251:                modifiers = modifiers | STATIC;
252:            }
253:
254:            /**
255:             *  Sets the Final bit (to true) of the in the modifiers
256:             */
257:            public void setFinal() {
258:                modifiers = modifiers | FINAL;
259:            }
260:
261:            /**
262:             *  Sets the StrictFP bit (to true) of the in the modifiers
263:             */
264:            public void setStrict() {
265:                modifiers = modifiers | STRICTFP;
266:            }
267:
268:            /**
269:             *  Determine if the object is abstract
270:             *
271:             *@return    true if this stores an ABSTRACT flag
272:             */
273:            public boolean isAbstract() {
274:                return ((modifiers & ABSTRACT) != 0);
275:            }
276:
277:            /**
278:             *  Determine if the object is explicit
279:             *
280:             *@return    true if this stores an EXPLICIT flag
281:             */
282:            public boolean isExplicit() {
283:                return ((modifiers & EXPLICIT) != 0);
284:            }
285:
286:            /**
287:             *  Determine if the object is final
288:             *
289:             *@return    true if this stores an FINAL flag
290:             */
291:            public boolean isFinal() {
292:                return ((modifiers & FINAL) != 0);
293:            }
294:
295:            /**
296:             *  Determine if the object is interface
297:             *
298:             *@return    true if this stores an INTERFACE flag
299:             */
300:            public boolean isInterface() {
301:                return ((modifiers & INTERFACE) != 0);
302:            }
303:
304:            /**
305:             *  Determine if the object is native
306:             *
307:             *@return    true if this stores an NATIVE flag
308:             */
309:            public boolean isNative() {
310:                return ((modifiers & NATIVE) != 0);
311:            }
312:
313:            /**
314:             *  Determine if the object is private
315:             *
316:             *@return    true if this stores an PRIVATE flag
317:             */
318:            public boolean isPrivate() {
319:                return ((modifiers & PRIVATE) != 0);
320:            }
321:
322:            /**
323:             *  Determine if the object is protected
324:             *
325:             *@return    true if this stores an PROTECTED flag
326:             */
327:            public boolean isProtected() {
328:                return ((modifiers & PROTECTED) != 0);
329:            }
330:
331:            /**
332:             *  Determine if the object is public
333:             *
334:             *@return    true if this stores an PUBLIC flag
335:             */
336:            public boolean isPublic() {
337:                return ((modifiers & PUBLIC) != 0);
338:            }
339:
340:            /**
341:             *  Determine if the object is static
342:             *
343:             *@return    true if this stores an static flag
344:             */
345:            public boolean isStatic() {
346:                return ((modifiers & STATIC) != 0);
347:            }
348:
349:            ///**
350:            // *  Determine if the object is strict
351:            // *
352:            // *@return    true if this stores an STRICT flag
353:            // */
354:            //public boolean isStrict()
355:            //{
356:            //	return ((modifiers & STRICT) != 0);
357:            //}
358:
359:            /**
360:             *  Determine if the object is strictFP
361:             *
362:             *@return    true if this stores an STRICTFP flag
363:             */
364:            public boolean isStrictFP() {
365:                return ((modifiers & STRICTFP) != 0);
366:            }
367:
368:            /**
369:             *  Determine if the object is synchronized
370:             *
371:             *@return    true if this stores an SYNCHRONIZED flag
372:             */
373:            public boolean isSynchronized() {
374:                return ((modifiers & SYNCHRONIZED) != 0);
375:            }
376:
377:            /**
378:             *  Determine if the object is transient
379:             *
380:             *@return    true if this stores an TRANSIENT flag
381:             */
382:            public boolean isTransient() {
383:                return ((modifiers & TRANSIENT) != 0);
384:            }
385:
386:            /**
387:             *  Determine if the object is volatile
388:             *
389:             *@return    true if this stores an VOLATILE flag
390:             */
391:            public boolean isVolatile() {
392:                return ((modifiers & VOLATILE) != 0);
393:            }
394:
395:            /**
396:             *  Determines if this has package scope
397:             *
398:             *@return    true if this has package scope
399:             */
400:            public boolean isPackage() {
401:                return !isPublic() && !isProtected() && !isPrivate();
402:            }
403:
404:            /**
405:             *  Add a modifier
406:             *
407:             *@param  mod  the new modifier
408:             */
409:            public void addModifier(String mod) {
410:                if ((mod == null) || (mod.length() == 0)) {
411:                    //  Nothing to add
412:                    return;
413:                } else if (mod.equalsIgnoreCase(names[0])) {
414:                    modifiers = modifiers | ABSTRACT;
415:                } else if (mod.equalsIgnoreCase(names[1])) {
416:                    modifiers = modifiers | EXPLICIT;
417:                } else if (mod.equalsIgnoreCase(names[2])) {
418:                    modifiers = modifiers | FINAL;
419:                } else if (mod.equalsIgnoreCase(names[3])) {
420:                    modifiers = modifiers | INTERFACE;
421:                } else if (mod.equalsIgnoreCase(names[4])) {
422:                    modifiers = modifiers | NATIVE;
423:                } else if (mod.equalsIgnoreCase(names[5])) {
424:                    modifiers = modifiers | PRIVATE;
425:                } else if (mod.equalsIgnoreCase(names[6])) {
426:                    modifiers = modifiers | PROTECTED;
427:                } else if (mod.equalsIgnoreCase(names[7])) {
428:                    modifiers = modifiers | PUBLIC;
429:                } else if (mod.equalsIgnoreCase(names[8])) {
430:                    modifiers = modifiers | STATIC;
431:                }
432:                //else if (mod.equalsIgnoreCase(names[9])) {
433:                //	modifiers = modifiers | STRICT;
434:                //}
435:                else if (mod.equalsIgnoreCase(names[10])) {
436:                    modifiers = modifiers | STRICTFP;
437:                } else if (mod.equalsIgnoreCase(names[11])) {
438:                    modifiers = modifiers | SYNCHRONIZED;
439:                } else if (mod.equalsIgnoreCase(names[12])) {
440:                    modifiers = modifiers | TRANSIENT;
441:                } else if (mod.equalsIgnoreCase(names[13])) {
442:                    modifiers = modifiers | VOLATILE;
443:                }
444:            }
445:
446:            /**
447:             *  Convert the object to a string
448:             *
449:             *@return    a string describing the modifiers
450:             */
451:            public String toStringAlphabetical() {
452:                //  Local Variables
453:                StringBuffer buf = new StringBuffer();
454:
455:                //  Protection first
456:                if (isPrivate()) {
457:                    buf.append(names[5]);
458:                    buf.append(" ");
459:                }
460:                if (isProtected()) {
461:                    buf.append(names[6]);
462:                    buf.append(" ");
463:                }
464:                if (isPublic()) {
465:                    buf.append(names[7]);
466:                    buf.append(" ");
467:                }
468:
469:                //  Others next
470:                if (isAbstract()) {
471:                    buf.append(names[0]);
472:                    buf.append(" ");
473:                }
474:                if (isExplicit()) {
475:                    buf.append(names[1]);
476:                    buf.append(" ");
477:                }
478:                if (isFinal()) {
479:                    buf.append(names[2]);
480:                    buf.append(" ");
481:                }
482:                if (isInterface()) {
483:                    buf.append(names[3]);
484:                    buf.append(" ");
485:                }
486:                if (isNative()) {
487:                    buf.append(names[4]);
488:                    buf.append(" ");
489:                }
490:                if (isStatic()) {
491:                    buf.append(names[8]);
492:                    buf.append(" ");
493:                }
494:                //if (isStrict()) {
495:                //	buf.append(names[9]);
496:                //	buf.append(" ");
497:                //}
498:                if (isStrictFP()) {
499:                    buf.append(names[10]);
500:                    buf.append(" ");
501:                }
502:                if (isSynchronized()) {
503:                    buf.append(names[11]);
504:                    buf.append(" ");
505:                }
506:                if (isTransient()) {
507:                    buf.append(names[12]);
508:                    buf.append(" ");
509:                }
510:                if (isVolatile()) {
511:                    buf.append(names[13]);
512:                    buf.append(" ");
513:                }
514:
515:                return buf.toString();
516:            }
517:
518:            /**
519:             *  Convert the object to a string
520:             *
521:             *@return    a string describing the modifiers
522:             */
523:            public String toStandardOrderString() {
524:                //  Local Variables
525:                StringBuffer buf = new StringBuffer();
526:
527:                //  Protection first
528:                if (isPrivate()) {
529:                    buf.append(names[5]);
530:                    buf.append(" ");
531:                }
532:                if (isProtected()) {
533:                    buf.append(names[6]);
534:                    buf.append(" ");
535:                }
536:                if (isPublic()) {
537:                    buf.append(names[7]);
538:                    buf.append(" ");
539:                }
540:
541:                //  Others next
542:                if (isAbstract()) {
543:                    buf.append(names[0]);
544:                    buf.append(" ");
545:                }
546:                if (isExplicit()) {
547:                    buf.append(names[1]);
548:                    buf.append(" ");
549:                }
550:                if (isInterface()) {
551:                    buf.append(names[3]);
552:                    buf.append(" ");
553:                }
554:                if (isStatic()) {
555:                    buf.append(names[8]);
556:                    buf.append(" ");
557:                }
558:                //if (isStrict()) {
559:                //	buf.append(names[9]);
560:                //	buf.append(" ");
561:                //}
562:                if (isFinal()) {
563:                    buf.append(names[2]);
564:                    buf.append(" ");
565:                }
566:                if (isSynchronized()) {
567:                    buf.append(names[11]);
568:                    buf.append(" ");
569:                }
570:                if (isTransient()) {
571:                    buf.append(names[12]);
572:                    buf.append(" ");
573:                }
574:                if (isVolatile()) {
575:                    buf.append(names[13]);
576:                    buf.append(" ");
577:                }
578:                if (isNative()) {
579:                    buf.append(names[4]);
580:                    buf.append(" ");
581:                }
582:                if (isStrictFP()) {
583:                    buf.append(names[10]);
584:                    buf.append(" ");
585:                }
586:
587:                return buf.toString();
588:            }
589:
590:            /**
591:             *  Copies the modifiers from another source
592:             *
593:             *@param  source  the source
594:             */
595:            public void copyModifiers(ModifierHolder source) {
596:                modifiers = source.getModifiers();
597:            }
598:
599:            /**
600:             *  Sets or resets a single bit in the modifiers
601:             *
602:             *@param  value  true if we are setting the bit
603:             *@param  code   The new Code value
604:             */
605:            protected void setCode(boolean value, int code) {
606:                if (value) {
607:                    modifiers = modifiers | code;
608:                } else {
609:                    modifiers = modifiers & (~code);
610:                }
611:            }
612:
613:            /**
614:             *  Gets the modifier bits
615:             *
616:             *@return    the modifier bits
617:             */
618:            public int getModifiers() {
619:                return modifiers;
620:            }
621:
622:            /**
623:             *  Sets the modifier bits
624:             *
625:             *@param modifiers    the modifier bits
626:             */
627:            public void setModifiers(int modifiers) {
628:                this .modifiers = modifiers;
629:            }
630:
631:            /**
632:             *  Returns a string containing all the modifiers
633:             *
634:             *@param code the code used to determine the order of the modifiers
635:             *@return    the string representationof the order
636:             */
637:            public String getModifiersString(int code) {
638:                if (code == PrintData.ALPHABETICAL_ORDER)
639:                    return toStringAlphabetical();
640:                else
641:                    return toStandardOrderString();
642:            }
643:
644:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.