Source Code Cross Referenced for RenameFieldRefactoring.java in  » UML » jrefactory » org » acm » seguin » refactor » field » 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.field 
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.field;
010:
011:        import java.util.Iterator;
012:        import org.acm.seguin.refactor.ComplexTransform;
013:        import org.acm.seguin.refactor.RefactoringException;
014:        import org.acm.seguin.summary.FieldSummary;
015:        import org.acm.seguin.summary.FileSummary;
016:        import org.acm.seguin.summary.Summary;
017:        import org.acm.seguin.summary.PackageSummary;
018:
019:        /**
020:         *  Renames a field
021:         *
022:         *@author    Chris Seguin
023:         */
024:        public class RenameFieldRefactoring extends FieldRefactoring {
025:            private String newName;
026:            private FieldSummary oldField;
027:
028:            /**
029:             *  Constructor for the RenameFieldRefactoring object
030:             */
031:            public RenameFieldRefactoring() {
032:                super ();
033:            }
034:
035:            /**
036:             *  Sets the NewName attribute of the RenameFieldRefactoring object
037:             *
038:             *@param  value  The new NewName value
039:             */
040:            public void setNewName(String value) {
041:                newName = value;
042:            }
043:
044:            /**
045:             *  Gets the Description attribute of the RenameFieldRefactoring object
046:             *
047:             *@return    The Description value
048:             */
049:            public String getDescription() {
050:                return "Renames the field " + field + " to " + newName;
051:            }
052:
053:            /**
054:             *  Gets the ID attribute of the RenameFieldRefactoring object
055:             *
056:             *@return    The ID value
057:             */
058:            public int getID() {
059:                return RENAME_FIELD;
060:            }
061:
062:            /**
063:             *  Check that thsi refactoring can be performed
064:             *
065:             *@exception  RefactoringException  Description of Exception
066:             */
067:            protected void preconditions() throws RefactoringException {
068:                Iterator iter = typeSummary.getFields();
069:                if (iter == null) {
070:                    throw new RefactoringException(
071:                            typeSummary.getName()
072:                                    + " has no fields associated with it, so it cannot be renamed");
073:                }
074:
075:                boolean found = false;
076:                while (iter.hasNext()) {
077:                    FieldSummary next = (FieldSummary) iter.next();
078:                    if (next.getName().equals(field)) {
079:                        found = true;
080:                        oldField = next;
081:                    }
082:                    if (next.getName().equals(newName)) {
083:                        throw new RefactoringException("A field named "
084:                                + newName + " already exists in class "
085:                                + typeSummary.getName());
086:                    }
087:                }
088:
089:                if (!found) {
090:                    throw new RefactoringException("No field named " + field
091:                            + " is contained in " + typeSummary.getName());
092:                }
093:            }
094:
095:            /**
096:             *  Applies the transformation to the system to rename the method
097:             */
098:            protected void transform() {
099:                if (oldField.getName().equals(newName)) {
100:                    return;
101:                }
102:
103:                FileSummary fileSummary = (FileSummary) getFileSummary(typeSummary);
104:                RenameFieldTransform rft = new RenameFieldTransform(oldField,
105:                        newName);
106:                ComplexTransform transform = getComplexTransform();
107:                transform.add(rft);
108:                transform.apply(fileSummary.getFile(), fileSummary.getFile());
109:
110:                if (oldField.isPrivate()) {
111:                    //  We are done
112:                } else if (oldField.isPackage()) {
113:                    RenameSystemTraversal rsv = new RenameSystemTraversal();
114:                    rsv.visit(getPackage(), new RenameFieldData(oldField,
115:                            newName, transform));
116:                } else {
117:                    RenameSystemTraversal rsv = new RenameSystemTraversal();
118:                    rsv
119:                            .visit(new RenameFieldData(oldField, newName,
120:                                    transform));
121:                }
122:            }
123:
124:            /**
125:             *  Gets the Package attribute of the RenameFieldRefactoring object
126:             *
127:             *@return    The Package value
128:             */
129:            private PackageSummary getPackage() {
130:                Summary current = oldField;
131:                while (!(current instanceof  PackageSummary)) {
132:                    current = current.getParent();
133:                }
134:
135:                return (PackageSummary) current;
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.