Source Code Cross Referenced for MoveClass.java in  » UML » jrefactory » org » acm » seguin » refactor » type » 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.type 
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.type;
010:
011:        import java.io.File;
012:        import java.io.IOException;
013:        import java.util.Iterator;
014:        import java.util.LinkedList;
015:        import net.sourceforge.jrefactory.ast.ASTName;
016:        import net.sourceforge.jrefactory.ast.SimpleNode;
017:        import net.sourceforge.jrefactory.query.PackageNameGetter;
018:        import org.acm.seguin.refactor.Refactoring;
019:        import org.acm.seguin.refactor.RefactoringException;
020:        import org.acm.seguin.summary.*;
021:        import org.acm.seguin.summary.query.TopLevelDirectory;
022:        import org.acm.seguin.refactor.RefactoringException;
023:
024:        /**
025:         *  Main program for repackaging. This object simply stores the main program
026:         *  and interprets the command line arguments for repackaging one or more
027:         *  files.
028:         *
029:         *@author     Chris Seguin
030:         *@created    June 2, 1999
031:         */
032:        public class MoveClass extends Refactoring {
033:            //  Instance Variables
034:            /**
035:             *  The directory
036:             */
037:            protected String initDir;
038:            /**
039:             *  The list of filenames
040:             */
041:            protected LinkedList fileList;
042:            private String oldPackage;
043:            private File base;
044:            private String srcPackage;
045:            private String destPackage;
046:
047:            /**
048:             *  Constructor for repackage
049:             */
050:            protected MoveClass() {
051:                destPackage = null;
052:                initDir = System.getProperty("user.dir");
053:                fileList = new LinkedList();
054:            }
055:
056:            /**
057:             *  Set the destination package
058:             *
059:             *@param  dest  the package name
060:             */
061:            public void setDestinationPackage(String dest) {
062:                destPackage = dest;
063:            }
064:
065:            /**
066:             *  Set the directory
067:             *
068:             *@param  dir  the initial directory
069:             */
070:            public void setDirectory(String dir) {
071:                initDir = dir;
072:            }
073:
074:            /**
075:             *  Gets the Description attribute of the MoveClass object
076:             *
077:             *@return    The Description value
078:             */
079:            public String getDescription() {
080:                return "Repackaging classes from " + srcPackage + " to "
081:                        + destPackage;
082:            }
083:
084:            /**
085:             *  Gets the id for this refactoring to track which refactorings are used.
086:             *
087:             *@return    the id
088:             */
089:            public int getID() {
090:                return REPACKAGE;
091:            }
092:
093:            /**
094:             *  Add a file to the list. The file name includes only the name, and not the
095:             *  entire path.
096:             *
097:             *@param  filename  the file to add
098:             */
099:            public void add(String filename) {
100:                fileList.add(filename);
101:            }
102:
103:            /**
104:             *  Main processing method for the MoveClass object
105:             *
106:             *@exception  RefactoringException  Description of Exception
107:             */
108:            protected void preconditions() throws RefactoringException {
109:                if ((destPackage == null) || (fileList.size() == 0)) {
110:                    if (destPackage == null)
111:                        System.out.println("destPackage can not be null");
112:                    if (fileList.size() == 0)
113:                        System.out.println("No files provided");
114:                    return;
115:                }
116:                //Checks if the class extension  is valid
117:                validateClassName(fileList);
118:
119:                File startDir = new File(initDir);
120:                String firstFilename = (String) fileList.get(0);
121:                ASTName srcPackageName = PackageNameGetter.query(startDir,
122:                        firstFilename);
123:                srcPackage = "";
124:                if (srcPackageName != null) {
125:                    srcPackage = srcPackageName.getName();
126:                }
127:
128:                base = TopLevelDirectory.query(startDir, firstFilename);
129:
130:                String topLevelDir = base.getPath();
131:                try {
132:                    topLevelDir = base.getCanonicalPath();
133:                } catch (IOException ioe) {
134:                }
135:                (new SummaryTraversal(topLevelDir)).run();
136:            }
137:
138:            /**
139:             *  Performs the transformation of the class
140:             */
141:            protected void transform() {
142:                MoveClassVisitor mcv = new MoveClassVisitor(srcPackage,
143:                        destPackage, base, getComplexTransform());
144:                Iterator iter = fileList.iterator();
145:                while (iter.hasNext()) {
146:                    //  Get the next file
147:                    String nextFile = (String) iter.next();
148:
149:                    int start = Math.max(0, nextFile.indexOf(File.separator));
150:                    int end = nextFile.indexOf(".java");
151:
152:                    String nextClass = "";
153:                    if (end > 0) {
154:                        nextClass = nextFile.substring(start, end);
155:                    } else {
156:                        nextClass = nextFile.substring(start);
157:                    }
158:
159:                    mcv.add(nextClass);
160:                }
161:
162:                mcv.visit(null);
163:            }
164:
165:            protected void validateClassName(LinkedList inputFileList)
166:                    throws RefactoringException {
167:                Iterator iter = inputFileList.iterator();
168:                while (iter.hasNext()) {
169:                    //  Get the next file
170:                    String nextFile = (String) iter.next();
171:                    if (!nextFile.endsWith(".java"))
172:                        throw new RefactoringException(nextFile
173:                                + " should ba a java file");
174:                }
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.