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


001:        package org.acm.seguin.refactor.type;
002:
003:        import java.io.File;
004:        import org.acm.seguin.summary.Summary;
005:        import org.acm.seguin.summary.PackageSummary;
006:        import org.acm.seguin.summary.FileSummary;
007:        import org.acm.seguin.summary.TypeSummary;
008:        import org.acm.seguin.summary.query.GetTypeSummary;
009:        import net.sourceforge.jrefactory.ast.ASTName;
010:        import org.acm.seguin.refactor.AddImportTransform;
011:        import org.acm.seguin.refactor.ComplexTransform;
012:
013:        /**
014:         *  The visitor object for removing a class from the system. 
015:         *
016:         *@author    Chris Seguin 
017:         */
018:        public class RemoveClassVisitor extends RenameClassVisitor {
019:            private String parentPackage;
020:            private String oldPackage;
021:
022:            /**
023:             *  Constructor for the remove class visitor object 
024:             *
025:             *@param  packageName        the package name 
026:             *@param  oldClass           the name of the class being deleted 
027:             *@param  newClass           the parent class of that being deleted 
028:             *@param  base               the base directory 
029:             *@param  initParentPackage  Description of Parameter 
030:             *@param  complex            Description of Parameter 
031:             */
032:            public RemoveClassVisitor(String packageName, String oldClass,
033:                    String initParentPackage, String newClass, File base,
034:                    ComplexTransform complex) {
035:                super (packageName, oldClass, newClass, base, complex);
036:
037:                parentPackage = initParentPackage;
038:                oldPackage = packageName;
039:            }
040:
041:            /**
042:             *  Gets the New Imports transform 
043:             *
044:             *@param  node       the file summary 
045:             *@param  className  the name of the class that is changing 
046:             *@return            The NewImports value 
047:             */
048:            protected AddImportTransform getNewImports(FileSummary node,
049:                    String className) {
050:                if (newClassName.equals("Object")) {
051:                    return null;
052:                } else if (GetTypeSummary.query(node, newClassName) == null) {
053:                    return new AddImportTransform(parentPackage, newClassName);
054:                } else {
055:                    return null;
056:                }
057:            }
058:
059:            /**
060:             *  Gets the new name 
061:             *
062:             *@return    an ASTName containing the new name 
063:             */
064:            protected ASTName getNewName() {
065:                if (newClassName.equals("Object")) {
066:                    ASTName result = new ASTName();
067:                    result.addNamePart(newClassName);
068:                    return result;
069:                }
070:                if (oldPackage.equals(parentPackage)) {
071:                    return super .getNewName();
072:                }
073:
074:                ASTName result = new ASTName();
075:                result.fromString(parentPackage);
076:                result.addNamePart(newClassName);
077:                return result;
078:            }
079:
080:            /**
081:             *  We are performing the transformation on a refactoring that already has 
082:             *  that type imported from another class 
083:             *
084:             *@param  refactoring   the complex transformation 
085:             *@param  oldOne        the old class name 
086:             *@param  node          the file that is being changed 
087:             *@param  importedType  the type that we are supposedly importing 
088:             */
089:            protected void alreadyImportsType(ComplexTransform refactoring,
090:                    ASTName oldOne, FileSummary node, TypeSummary importedType) {
091:                if (isSamePackage(node, importedType) || isParent(importedType)) {
092:                    ASTName newOne = new ASTName();
093:                    newOne.addNamePart(newClassName);
094:
095:                    refactoring.add(new RenameTypeTransform(oldOne, newOne,
096:                            null));
097:                } else {
098:                    refactoring.add(new RenameTypeTransform(oldOne,
099:                            getNewName(), null));
100:                }
101:            }
102:
103:            /**
104:             *  Gets the SamePackage attribute of the RemoveClassVisitor object 
105:             *
106:             *@param  fileSummary  Description of Parameter 
107:             *@param  typeSummary  Description of Parameter 
108:             *@return              The SamePackage value 
109:             */
110:            private boolean isSamePackage(FileSummary fileSummary,
111:                    TypeSummary typeSummary) {
112:                Summary one = fileSummary;
113:                Summary two = typeSummary;
114:
115:                while (!(one instanceof  PackageSummary)) {
116:                    one = one.getParent();
117:                }
118:
119:                while (!(two instanceof  PackageSummary)) {
120:                    two = two.getParent();
121:                }
122:
123:                return one.equals(two);
124:            }
125:
126:            /**
127:             *  Gets the Parent attribute of the RemoveClassVisitor object 
128:             *
129:             *@param  typeSummary  Description of Parameter 
130:             *@return              The Parent value 
131:             */
132:            private boolean isParent(TypeSummary typeSummary) {
133:                Summary one = typeSummary;
134:
135:                while (!(one instanceof  PackageSummary)) {
136:                    one = one.getParent();
137:                }
138:
139:                PackageSummary packageSummary = (PackageSummary) one;
140:                String packageName = packageSummary.getName();
141:
142:                return packageName.equals(parentPackage);
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.