Source Code Cross Referenced for Repackage.java in  » UML » jrefactory » org » acm » seguin » tools » builder » 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.tools.builder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 1999
003:         *
004:         *  Chris Seguin
005:         *  All rights reserved
006:         */
007:        package org.acm.seguin.tools.builder;
008:
009:        import java.io.BufferedReader;
010:        import java.io.FileReader;
011:        import java.io.IOException;
012:        import java.util.StringTokenizer;
013:        import org.acm.seguin.refactor.RefactoringException;
014:        import org.acm.seguin.refactor.RefactoringFactory;
015:        import org.acm.seguin.refactor.type.MoveClass;
016:        import org.acm.seguin.tools.RefactoryInstaller;
017:        import org.acm.seguin.util.FileSettings;
018:
019:        /**
020:         *  Main program for repackaging. This object simply stores the main program and
021:         *  interprets the command line arguments for repackaging one or more files. It
022:         *  has two options --package or nopackage. package builds a specified package
023:         *  hierarchy and nopackage removes the package hierarchy and updates the java
024:         *  file(s) accordingly This program uses relative pathname to create a new
025:         *  package. So it may give unexpectd results if run on a file whose package
026:         *  name is not in accordance with its package hierarchy
027:         *
028:         *@author      Chris Seguin
029:         *@created     June 2, 1999
030:         *@Modified    by Praveen on Feb 2002 Incorporated better messages
031:         */
032:        public class Repackage {
033:            private boolean setPackage = false;
034:            private boolean atLeastOneClass = false;
035:            //  Instance Variables
036:            private MoveClass moveClass;
037:
038:            /**
039:             *  Initialize the variables with command line arguments
040:             *
041:             *@param  args  the command line arguments
042:             *@return       true if we should continue processing
043:             */
044:            public boolean init(String[] args) {
045:                int nCurrentArg = 0;
046:
047:                while (nCurrentArg < args.length) {
048:                    if (args[nCurrentArg].equalsIgnoreCase("-dir")) {
049:                        moveClass.setDirectory(args[nCurrentArg + 1]);
050:                        nCurrentArg += 2;
051:                    } else if (args[nCurrentArg].equalsIgnoreCase("-package")) {
052:                        moveClass.setDestinationPackage(args[nCurrentArg + 1]);
053:                        nCurrentArg += 2;
054:                        setPackage = true;
055:                    } else if (args[nCurrentArg].equalsIgnoreCase("-nopackage")) {
056:                        moveClass.setDestinationPackage("");
057:                        nCurrentArg++;
058:                        setPackage = true;
059:                    } else if (args[nCurrentArg].equalsIgnoreCase("-file")) {
060:                        String filename = args[nCurrentArg + 1];
061:                        load(filename);
062:                        nCurrentArg += 2;
063:                        atLeastOneClass = true;
064:                    } else if ((args[nCurrentArg].equalsIgnoreCase("-help"))
065:                            || (args[nCurrentArg].equalsIgnoreCase("--help"))) {
066:                        printHelpMessage();
067:                        nCurrentArg++;
068:                        return false;
069:                    } else {
070:                        moveClass.add(args[nCurrentArg]);
071:                        nCurrentArg++;
072:                        atLeastOneClass = true;
073:                    }
074:                }
075:
076:                return atLeastOneClass && setPackage;
077:            }
078:
079:            /**
080:             *  Actual work of the main program occurs here
081:             *
082:             *@param  args                      the command line arguments
083:             *@exception  RefactoringException  Description of Exception
084:             */
085:            public void run(String[] args) throws RefactoringException {
086:                moveClass = RefactoringFactory.get().moveClass();
087:                if (args.length == 0) {
088:                    printHelpMessage();
089:                }
090:                try {
091:                    if (init(args)) {
092:                        moveClass.run();
093:                    }
094:                    //catches if the number of arguments are not as expected e.g. no dir for -dir
095:                } catch (Exception aoe) {
096:                    printHelpMessage();
097:                }
098:            }
099:
100:            /**
101:             *  Print the help message
102:             */
103:            protected void printHelpMessage() {
104:                System.out.println("Syntax:  java Repackage \\ ");
105:                System.out.println("        [-dir <dir>] [-help | --help] ");
106:                System.out
107:                        .println("        [-package <packagename> | -nopackage] (<file.java>)*");
108:                System.out.println("");
109:                System.out.println("  where:");
110:                System.out
111:                        .println("    <dir>        is the name of the directory containing the files");
112:                System.out
113:                        .println("    <package>    is the name of the new package");
114:                System.out
115:                        .println("    <nopackage>  is the way of flatening package hieracrhy");
116:                System.out
117:                        .println("    <file.java>  is the name of the java file(s) separated");
118:                System.out
119:                        .println("                 by whitespace to be moved");
120:                System.out.println("    The syntax is case insensitive. ");
121:            }
122:
123:            /**
124:             *  Loads a file listing the names of java files to be moved
125:             *
126:             *@param  filename  the name of the file
127:             */
128:            private void load(String filename) {
129:                try {
130:                    BufferedReader input = new BufferedReader(new FileReader(
131:                            filename));
132:                    String line = input.readLine();
133:                    if (line == null) {
134:                        System.out.println("Should have atleast one file name");
135:                        printHelpMessage();
136:                    }
137:                    while (line != null) {
138:                        StringTokenizer tok = new StringTokenizer(line);
139:                        while (tok.hasMoreTokens()) {
140:                            String next = tok.nextToken();
141:                            System.out.println("Adding:  " + next);
142:                            moveClass.add(next);
143:                        }
144:                        line = input.readLine();
145:                    }
146:                    input.close();
147:                } catch (IOException ioe) {
148:                    ioe.printStackTrace();
149:                }
150:            }
151:
152:            /**
153:             *  Main program
154:             *
155:             *@param  args  the command line arguments
156:             */
157:            public static void main(String[] args) {
158:                try {
159:                    for (int ndx = 0; ndx < args.length; ndx++) {
160:                        if (args[ndx].equals("-config")) {
161:                            String dir = args[ndx + 1];
162:                            ndx++;
163:                            FileSettings.setSettingsRoot(dir);
164:                        }
165:                    }
166:
167:                    //  Make sure everything is installed properly
168:                    (new RefactoryInstaller(true)).run();
169:
170:                    (new Repackage()).run(args);
171:                } catch (Throwable thrown) {
172:                    thrown.printStackTrace(System.out);
173:                }
174:
175:                System.exit(0);
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.