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


001:        /*
002:         * Author:  Chris Seguin
003:         *
004:         * This software has been developed under the copyleft
005:         * rules of the GNU General Public License.  Please
006:         * consult the GNU General Public License for more
007:         * details about use and distribution of this software.
008:         */
009:        package org.acm.seguin.refactor;
010:
011:        import java.util.LinkedList;
012:        import java.util.Iterator;
013:        import java.io.File;
014:        import org.acm.seguin.summary.PackageSummary;
015:        import org.acm.seguin.summary.FileSummary;
016:        import org.acm.seguin.summary.ImportSummary;
017:        import org.acm.seguin.summary.TypeSummary;
018:        import org.acm.seguin.refactor.type.TypeChangeVisitor;
019:
020:        /**
021:         *  Description of the Class
022:         *
023:         *@author    Chris Seguin
024:         */
025:        public class EliminatePackageImportVisitor extends TypeChangeVisitor {
026:            private PackageSummary packageSummary;
027:            private LinkedList filterList = new LinkedList();
028:
029:            /**
030:             *  Constructor for the EliminatePackageImportVisitor object
031:             *
032:             *@param  complex  Description of Parameter
033:             */
034:            public EliminatePackageImportVisitor(ComplexTransform complex) {
035:                super (complex);
036:            }
037:
038:            /**
039:             *  Sets the Package attribute of the EliminatePackageImportVisitor object
040:             *
041:             *@param  summary  The new Package value
042:             */
043:            public void setPackageSummary(PackageSummary summary) {
044:                packageSummary = summary;
045:            }
046:
047:            /**
048:             *  Adds a feature to the FilterClass attribute of the
049:             *  EliminatePackageImportVisitor object
050:             *
051:             *@param  name  The feature to be added to the FilterClass attribute
052:             */
053:            public void addFilterClass(String name) {
054:                filterList.add(name);
055:            }
056:
057:            /**
058:             *  Gets the File Specific Transform
059:             *
060:             *@param  summary  Description of Parameter
061:             *@return          The FileSpecificTransform value
062:             */
063:            protected TransformAST getFileSpecificTransform(FileSummary summary) {
064:                return new RemoveImportTransform(packageSummary);
065:            }
066:
067:            /**
068:             *  Gets the New Imports transform
069:             *
070:             *@param  node       Description of Parameter
071:             *@param  className  Description of Parameter
072:             *@return            The NewImports value
073:             */
074:            protected AddImportTransform getNewImports(FileSummary node,
075:                    String className) {
076:                return new AddImportTransform(packageSummary.getName(),
077:                        className);
078:            }
079:
080:            /**
081:             *  Gets the Remove Imports transform
082:             *
083:             *@param  node  Description of Parameter
084:             *@return       The transform
085:             */
086:            protected RemoveImportTransform getRemoveImportTransform(
087:                    ImportSummary node) {
088:                return null;
089:            }
090:
091:            /**
092:             *  Gets the list of classes to iterate over
093:             *
094:             *@param  node  Description of Parameter
095:             *@return       The list
096:             */
097:            protected LinkedList getAppropriateClasses(FileSummary node) {
098:                LinkedList list = new LinkedList();
099:
100:                Iterator fileIterator = packageSummary.getFileSummaries();
101:                if (fileIterator != null) {
102:                    while (fileIterator.hasNext()) {
103:                        FileSummary fileSummary = (FileSummary) fileIterator
104:                                .next();
105:
106:                        addTypesFromFile(fileSummary, list);
107:                    }
108:                }
109:
110:                return list;
111:            }
112:
113:            /**
114:             *  Gets the reference to the file where the refactored output should be sent
115:             *
116:             *@param  node  Description of Parameter
117:             *@return       The NewFile value
118:             */
119:            protected File getNewFile(FileSummary node) {
120:                return node.getFile();
121:            }
122:
123:            /**
124:             *  Return the current package
125:             *
126:             *@return    the current package of the class
127:             */
128:            protected String getCurrentPackage() {
129:                return packageSummary.getName();
130:            }
131:
132:            /**
133:             *  Checks any preconditions
134:             *
135:             *@param  summary  Description of Parameter
136:             *@return          Description of the Returned Value
137:             */
138:            protected boolean preconditions(FileSummary summary) {
139:                if (summary.getParent() == packageSummary) {
140:                    return false;
141:                }
142:
143:                Iterator iter = summary.getImports();
144:                if (iter != null) {
145:                    while (iter.hasNext()) {
146:                        ImportSummary next = (ImportSummary) iter.next();
147:                        if (isImportingPackage(next)) {
148:                            return true;
149:                        }
150:                    }
151:                }
152:
153:                return false;
154:            }
155:
156:            /**
157:             *  Gets the RenamingTransform
158:             *
159:             *@param  refactoring  The feature to be added to the RenamingTransforms
160:             *      attribute
161:             *@param  node         The feature to be added to the RenamingTransforms
162:             *      attribute
163:             *@param  className    The feature to be added to the RenamingTransforms
164:             *      attribute
165:             */
166:            protected void addRenamingTransforms(ComplexTransform refactoring,
167:                    FileSummary node, String className) {
168:            }
169:
170:            /**
171:             *  Gets the InFilter attribute of the EliminatePackageImportVisitor object
172:             *
173:             *@param  type  Description of Parameter
174:             *@return       The InFilter value
175:             */
176:            private boolean isInFilter(TypeSummary type) {
177:                Iterator iter = filterList.iterator();
178:                String name = type.getName();
179:                while (iter.hasNext()) {
180:                    if (name.equals(iter.next())) {
181:                        return true;
182:                    }
183:                }
184:                return false;
185:            }
186:
187:            /**
188:             *  Determines if we are importing the package that we are eliminiating
189:             *
190:             *@param  next  the import statement in question
191:             *@return       true if this is the import statement
192:             */
193:            private boolean isImportingPackage(ImportSummary next) {
194:                return (next.getType() == null)
195:                        && (next.getPackage() == packageSummary);
196:            }
197:
198:            /**
199:             *  Adds a feature to the TypesFromFile attribute of the
200:             *  EliminatePackageImportVisitor object
201:             *
202:             *@param  fileSummary  The feature to be added to the TypesFromFile attribute
203:             *@param  list         The feature to be added to the TypesFromFile attribute
204:             */
205:            private void addTypesFromFile(FileSummary fileSummary,
206:                    LinkedList list) {
207:                Iterator typeIterator = fileSummary.getTypes();
208:                if (typeIterator != null) {
209:                    while (typeIterator.hasNext()) {
210:                        TypeSummary next = (TypeSummary) typeIterator.next();
211:                        if (next.isPublic() && !isInFilter(next)) {
212:                            list.add(next.getName());
213:                        }
214:                    }
215:                }
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.