Source Code Cross Referenced for RemoveMethodVisitor.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 net.sourceforge.jrefactory.ast.ASTClassBody;
013:        import net.sourceforge.jrefactory.ast.ASTClassBodyDeclaration;
014:        import net.sourceforge.jrefactory.ast.ASTInterfaceBody;
015:        import net.sourceforge.jrefactory.ast.ASTInterfaceMemberDeclaration;
016:        import net.sourceforge.jrefactory.ast.ASTNestedClassDeclaration;
017:        import net.sourceforge.jrefactory.ast.ASTNestedInterfaceDeclaration;
018:        import net.sourceforge.jrefactory.ast.ASTFormalParameter;
019:        import net.sourceforge.jrefactory.ast.ASTType;
020:        import net.sourceforge.jrefactory.ast.ASTPrimitiveType;
021:        import net.sourceforge.jrefactory.ast.ASTName;
022:        import net.sourceforge.jrefactory.ast.SimpleNode;
023:        import net.sourceforge.jrefactory.parser.ChildrenVisitor;
024:        import org.acm.seguin.summary.MethodSummary;
025:        import org.acm.seguin.summary.ParameterSummary;
026:
027:        /**
028:         *  Visitor that traverses an AST and removes a specified method
029:         *
030:         *@author    Chris Seguin
031:         */
032:        public class RemoveMethodVisitor extends IdentifyMethodVisitor {
033:            private SimpleNode methodDecl;
034:
035:            /**
036:             *  Constructor for RemoveMethodVisitor that specifies the method to remove
037:             *
038:             *@param  method  the name of the method
039:             */
040:            public RemoveMethodVisitor(MethodSummary method) {
041:                super (method);
042:                methodDecl = null;
043:            }
044:
045:            /**
046:             *  Gets the MethodDeclaration attribute of the RemoveMethodVisitor object
047:             *
048:             *@return    The MethodDeclaration value
049:             */
050:            public SimpleNode getMethodDeclaration() {
051:                return methodDecl;
052:            }
053:
054:            /**
055:             *  Visit a class body
056:             *
057:             *@param  node  the class body node
058:             *@param  data  the data for the visitor
059:             *@return       the method if it is found
060:             */
061:            public Object visit(ASTClassBody node, Object data) {
062:                Object result = removeMethod(node);
063:                if (result == null) {
064:                    result = super .visit(node, data);
065:                }
066:                return result;
067:            }
068:
069:            /**
070:             *  Visit an interface body
071:             *
072:             *@param  node  the interface body node
073:             *@param  data  data for the visitor
074:             *@return       the method that was removed
075:             */
076:            public Object visit(ASTInterfaceBody node, Object data) {
077:                Object result = removeMethod(node);
078:                if (result == null) {
079:                    result = super .visit(node, data);
080:                }
081:                return result;
082:            }
083:
084:            /**
085:             *  Skip nested classes
086:             *
087:             *@param  node  the nested class
088:             *@param  data  the data for the visitor
089:             *@return       the method if it is found
090:             */
091:            public Object visit(ASTNestedClassDeclaration node, Object data) {
092:                return null;
093:            }
094:
095:            /**
096:             *  Skip nested interfaces
097:             *
098:             *@param  node  the nested interface
099:             *@param  data  the data for the visitor
100:             *@return       the method if it is found
101:             */
102:            public Object visit(ASTNestedInterfaceDeclaration node, Object data) {
103:                return null;
104:            }
105:
106:            /**
107:             *  Remove the method, if it is the correct one. Return the method
108:             *  declaration that was removed
109:             *
110:             *@param  node  The node we are considering removing the method from
111:             *@return       The method declaration
112:             */
113:            private Object removeMethod(SimpleNode node) {
114:                int loop = node.jjtGetNumChildren();
115:                for (int ndx = 0; ndx < loop; ndx++) {
116:                    SimpleNode next = (SimpleNode) node.jjtGetChild(ndx);
117:                    SimpleNode possible = (SimpleNode) next.jjtGetFirstChild();
118:                    if (isFound(possible)) {
119:                        removeSingle(node, next, ndx);
120:                        return next;
121:                    }
122:                }
123:                return null;
124:            }
125:
126:            /**
127:             *  Removes a method declaration where only a single variable was declared
128:             *
129:             *@param  node  the class or interface body node
130:             *@param  next  the container for the method declaration
131:             *@param  ndx   the index of the node to delete
132:             */
133:            private void removeSingle(SimpleNode node, SimpleNode next, int ndx) {
134:                methodDecl = next;
135:                node.jjtDeleteChild(ndx);
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.