Source Code Cross Referenced for RenameSystemTraversal.java in  » UML » jrefactory » org » acm » seguin » refactor » method » 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.method 
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.method;
010:
011:        import java.util.Iterator;
012:        import java.util.LinkedList;
013:        import java.util.StringTokenizer;
014:        import org.acm.seguin.refactor.ComplexTransform;
015:        import org.acm.seguin.summary.FieldAccessSummary;
016:        import org.acm.seguin.summary.FieldSummary;
017:        import org.acm.seguin.summary.FileSummary;
018:        import org.acm.seguin.summary.LocalVariableSummary;
019:        import org.acm.seguin.summary.MessageSendSummary;
020:        import org.acm.seguin.summary.MethodSummary;
021:        import org.acm.seguin.summary.ParameterSummary;
022:        import org.acm.seguin.summary.Summary;
023:        import org.acm.seguin.summary.TraversalVisitor;
024:        import org.acm.seguin.summary.TypeDeclSummary;
025:        import org.acm.seguin.summary.TypeSummary;
026:        import org.acm.seguin.summary.VariableSummary;
027:
028:        /**
029:         *  All items that want to visit a summary tree should implement this
030:         *  interface.
031:         *
032:         *@author     Chris Seguin
033:         *@created    May 15, 1999
034:         */
035:        public class RenameSystemTraversal extends TraversalVisitor {
036:            /**
037:             *  Visit a file summary.
038:             *
039:             *@param  node  the summary that we are visiting
040:             *@param  data  the data that was passed in
041:             *@return       the result
042:             */
043:            public Object visit(FileSummary node, Object data) {
044:                if (node.getFile() == null) {
045:                    return data; // this file summary is from a stub (probably the JDK).
046:                }
047:                System.out.println("RenameSystemTraversal.visit(FileSummary "
048:                        + node + ", Object data)");
049:
050:                //  Over the types
051:                Boolean result = Boolean.FALSE;
052:                Iterator iter = node.getTypes();
053:                if (iter != null) {
054:                    while (iter.hasNext() && result.equals(Boolean.FALSE)) {
055:                        TypeSummary next = (TypeSummary) iter.next();
056:                        result = (Boolean) next.accept(this , data);
057:                    }
058:                }
059:
060:                if (result.booleanValue()) {
061:                    //  Apply the refactoring to this file
062:                    System.out
063:                            .println("Updating:  " + node.getFile().getPath());
064:                    RenameMethodData rfd = (RenameMethodData) data;
065:                    transform(node, rfd.getOldMethod(), rfd.getNewName(), rfd
066:                            .getComplexTransform());
067:                }
068:
069:                //  Return some value
070:                return data;
071:            }
072:
073:            /**
074:             *  Visit a type summary.
075:             *
076:             *@param  node  the summary that we are visiting
077:             *@param  data  the data that was passed in
078:             *@return       the result
079:             */
080:            public Object visit(TypeSummary node, Object data) {
081:                System.out.println("RenameSystemTraversal.visit(TypeSummary "
082:                        + node + ", Object data)");
083:                RenameMethodData rfd = (RenameMethodData) data;
084:                if (node.equals(rfd.getTypeSummary())) {
085:                    System.out.println("  - not found");
086:                    return Boolean.FALSE;
087:                }
088:
089:                //  Over the fields
090:                Iterator iter = node.getMethods();
091:                if (iter != null) {
092:                    while (iter.hasNext()) {
093:                        MethodSummary next = (MethodSummary) iter.next();
094:                        Boolean result = (Boolean) next.accept(this , data);
095:                        if (result.equals(Boolean.TRUE)) {
096:                            System.out.println("  - found");
097:                            return result;
098:                        }
099:                    }
100:                }
101:
102:                //  Over the types
103:                iter = node.getTypes();
104:                if (iter != null) {
105:                    while (iter.hasNext()) {
106:                        TypeSummary next = (TypeSummary) iter.next();
107:                        Boolean result = (Boolean) next.accept(this , data);
108:                        if (result.equals(Boolean.TRUE)) {
109:                            System.out.println("  - found");
110:                            return result;
111:                        }
112:                    }
113:                }
114:
115:                System.out.println("  - not found");
116:                //  Return some value
117:                return Boolean.FALSE;
118:            }
119:
120:            /**
121:             *  Visit a method summary.
122:             *
123:             *@param  node  the summary that we are visiting
124:             *@param  data  the data that was passed in
125:             *@return       the result
126:             */
127:            public Object visit(MethodSummary node, Object data) {
128:                System.out.println("RenameSystemTraversal.visit(MethodSummary "
129:                        + node + ", Object data)");
130:                //  Finally visit the dependencies
131:                Iterator iter = node.getDependencies();
132:                if (iter != null) {
133:                    while (iter.hasNext()) {
134:                        Summary next = (Summary) iter.next();
135:                        Boolean result = (Boolean) next.accept(this , data);
136:                        if (result.equals(Boolean.TRUE)) {
137:                            System.out.println("  - found");
138:                            return result;
139:                        }
140:                    }
141:                }
142:
143:                System.out.println("  - not found");
144:                return Boolean.FALSE;
145:            }
146:
147:            /**
148:             *  Visit a field summary.
149:             *
150:             *@param  node  the summary that we are visiting
151:             *@param  data  the data that was passed in
152:             *@return       the result
153:             */
154:            public Object visit(FieldSummary node, Object data) {
155:                return Boolean.FALSE;
156:            }
157:
158:            /**
159:             *  Visit a parameter summary.
160:             *
161:             *@param  node  the summary that we are visiting
162:             *@param  data  the data that was passed in
163:             *@return       the result
164:             */
165:            public Object visit(ParameterSummary node, Object data) {
166:                return Boolean.FALSE;
167:            }
168:
169:            /**
170:             *  Visit a local variable summary.
171:             *
172:             *@param  node  the summary that we are visiting
173:             *@param  data  the data that was passed in
174:             *@return       the result
175:             */
176:            public Object visit(LocalVariableSummary node, Object data) {
177:                return Boolean.FALSE;
178:            }
179:
180:            /**
181:             *  Visit a variable summary.
182:             *
183:             *@param  node  the summary that we are visiting
184:             *@param  data  the data that was passed in
185:             *@return       the result
186:             */
187:            public Object visit(VariableSummary node, Object data) {
188:                return Boolean.FALSE;
189:            }
190:
191:            /**
192:             *  Visit a type declaration summary.
193:             *
194:             *@param  node  the summary that we are visiting
195:             *@param  data  the data that was passed in
196:             *@return       the result
197:             */
198:            public Object visit(TypeDeclSummary node, Object data) {
199:                return Boolean.FALSE;
200:            }
201:
202:            /**
203:             *  Visit a message send summary.
204:             *
205:             *@param  node  the summary that we are visiting
206:             *@param  data  the data that was passed in
207:             *@return       the result
208:             */
209:            public Object visit(MessageSendSummary node, Object data) {
210:                System.out
211:                        .println("RenameSystemTraversal.visit(MessageSendSummary "
212:                                + node + ", Object data)");
213:                String message = node.toString();
214:
215:                RenameMethodData rfd = (RenameMethodData) data;
216:                String oldName = rfd.getOldName();
217:                StringTokenizer tok = new StringTokenizer(message, ".");
218:
219:                while (tok.hasMoreTokens()) {
220:                    String next = tok.nextToken();
221:                    int index = next.indexOf("(");
222:                    if (index > 0) {
223:                        next = next.substring(0, index);
224:                    }
225:                    System.out.println("  next=" + next + ", oldName="
226:                            + oldName);
227:                    if (next.equals(oldName)) {
228:                        System.out.println("  - found");
229:                        return Boolean.TRUE;
230:                    }
231:                }
232:
233:                System.out.println("  - not found");
234:                return Boolean.FALSE;
235:            }
236:
237:            /**
238:             *  Visit a field access summary.
239:             *
240:             *@param  node  the summary that we are visiting
241:             *@param  data  the data that was passed in
242:             *@return       the result
243:             */
244:            public Object visit(FieldAccessSummary node, Object data) {
245:                System.out
246:                        .println("RenameSystemTraversal.visit(FieldAccessSummary "
247:                                + node + ", Object data)");
248:                String message = node.getName();
249:
250:                RenameMethodData rfd = (RenameMethodData) data;
251:                StringTokenizer tok = new StringTokenizer(message, ".");
252:
253:                while (tok.hasMoreTokens()) {
254:                    String next = tok.nextToken();
255:                    if (next.equals(rfd.getOldName())) {
256:                        System.out.println("  - found");
257:                        return Boolean.TRUE;
258:                    }
259:                }
260:
261:                System.out.println("  - not found");
262:                return Boolean.FALSE;
263:            }
264:
265:            /**
266:             *  Perform the rename transformation on this particular file
267:             *
268:             *@param  fileSummary  Description of Parameter
269:             *@param  oldField     Description of Parameter
270:             *@param  newName      Description of Parameter
271:             *@param  transform    Description of Parameter
272:             */
273:            private void transform(FileSummary fileSummary,
274:                    MethodSummary oldMethod, String newName,
275:                    ComplexTransform transform) {
276:                System.out.println("RenameSystemTraversal.transform()");
277:                transform.clear();
278:
279:                RenameMethodTransform rft = new RenameMethodTransform(
280:                        oldMethod, newName);
281:                transform.add(rft);
282:                transform.apply(fileSummary.getFile(), fileSummary.getFile());
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.