Source Code Cross Referenced for PushDownMethodRefactoring.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 net.sourceforge.jrefactory.ast.ASTMethodDeclaration;
014:        import net.sourceforge.jrefactory.ast.SimpleNode;
015:        import org.acm.seguin.refactor.ComplexTransform;
016:        import org.acm.seguin.refactor.RefactoringException;
017:        import org.acm.seguin.summary.TypeDeclSummary;
018:        import org.acm.seguin.summary.TypeSummary;
019:        import org.acm.seguin.summary.query.GetTypeSummary;
020:
021:        /**
022:         *  Performs the push down method refactoring
023:         *
024:         *@author    Chris Seguin
025:         */
026:        public class PushDownMethodRefactoring extends
027:                InheretenceMethodRefactoring {
028:            private LinkedList destinations;
029:            private TypeSummary typeSummary;
030:
031:            /**
032:             *  Constructor for the PushDownMethodRefactoring object
033:             */
034:            protected PushDownMethodRefactoring() {
035:                destinations = new LinkedList();
036:            }
037:
038:            /**
039:             *  Gets the description of the refactoring
040:             *
041:             *@return    the description
042:             */
043:            public String getDescription() {
044:                return "Moves a method " + methodSummary.getName()
045:                        + " down into the child classes of "
046:                        + typeSummary.getName();
047:            }
048:
049:            /**
050:             *  Gets the ID attribute of the PushDownMethodRefactoring object
051:             *
052:             *@return    The ID value
053:             */
054:            public int getID() {
055:                return PUSH_DOWN_METHOD;
056:            }
057:
058:            /**
059:             *  Adds a feature to the Child attribute of the PushDownMethodRefactoring
060:             *  object
061:             *
062:             *@param  type  The feature to be added to the Child attribute
063:             */
064:            public void addChild(TypeSummary type) {
065:                destinations.add(type);
066:            }
067:
068:            /**
069:             *  This specifies the preconditions for applying the refactoring
070:             *
071:             *@exception  RefactoringException  Description of Exception
072:             */
073:            protected void preconditions() throws RefactoringException {
074:                if (methodSummary == null) {
075:                    throw new RefactoringException("No method specified");
076:                }
077:
078:                typeSummary = (TypeSummary) methodSummary.getParent();
079:
080:                Iterator iter = destinations.iterator();
081:                while (iter.hasNext()) {
082:                    TypeSummary next = (TypeSummary) iter.next();
083:                    TypeDeclSummary parent = next.getParentClass();
084:                    TypeSummary parentSummary = GetTypeSummary.query(parent);
085:
086:                    if (parentSummary != typeSummary) {
087:                        throw new RefactoringException(next.getName()
088:                                + " is not a subclass of "
089:                                + typeSummary.getName());
090:                    }
091:
092:                    checkDestination(next);
093:                }
094:            }
095:
096:            /**
097:             *  Moves the method to the parent class
098:             */
099:            protected void transform() {
100:                RemoveMethodTransform rft = new RemoveMethodTransform(
101:                        methodSummary);
102:                ComplexTransform transform = getComplexTransform();
103:
104:                removeMethod(typeSummary, transform, rft);
105:
106:                //  Update the method declaration to have the proper permissions
107:                SimpleNode methodDecl = rft.getMethodDeclaration();
108:                if (methodDecl == null) {
109:                    return;
110:                }
111:
112:                ASTMethodDeclaration decl = updateMethod(methodDecl);
113:
114:                Iterator iter = destinations.iterator();
115:                while (iter.hasNext()) {
116:                    TypeSummary next = (TypeSummary) iter.next();
117:                    addMethodToDest(transform, rft, methodDecl, next);
118:                }
119:            }
120:
121:            /**
122:             *  Description of the Method
123:             *
124:             *@param  source     Description of Parameter
125:             *@param  transform  Description of Parameter
126:             *@param  rft        Description of Parameter
127:             */
128:            protected void removeMethod(TypeSummary source,
129:                    ComplexTransform transform, RemoveMethodTransform rft) {
130:                transform.add(new AddAbstractMethod(methodSummary));
131:                super.removeMethod(source, transform, rft);
132:            }
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.