Source Code Cross Referenced for ProGuardObfuscator.java in  » Development » proguard » proguard » wtk » 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 » Development » proguard » proguard.wtk 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ProGuard -- shrinking, optimization, obfuscation, and preverification
003:         *             of Java bytecode.
004:         *
005:         * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
006:         *
007:         * This program is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License as published by the Free
009:         * Software Foundation; either version 2 of the License, or (at your option)
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, but WITHOUT
013:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
015:         * more details.
016:         *
017:         * You should have received a copy of the GNU General Public License along
018:         * with this program; if not, write to the Free Software Foundation, Inc.,
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         */
021:        package proguard.wtk;
022:
023:        import com.sun.kvem.environment.Obfuscator;
024:        import proguard.*;
025:
026:        import java.io.*;
027:
028:        /**
029:         * ProGuard plug-in for the J2ME Wireless Toolkit.
030:         * <p>
031:         * In order to integrate this plug-in in the toolkit, you'll have to put the
032:         * following lines in the file
033:         * {j2mewtk.dir}<code>/wtklib/Linux/ktools.properties</code> or
034:         * {j2mewtk.dir}<code>\wtklib\Windows\ktools.properties</code> (whichever is
035:         * applicable).
036:         * <p>
037:         * <pre>
038:         * obfuscator.runner.class.name: proguard.wtk.ProGuardObfuscator
039:         * obfuscator.runner.classpath: /usr/local/java/proguard1.6/lib/proguard.jar
040:         * </pre>
041:         * Please make sure the class path is set correctly for your system.
042:         *
043:         * @author Eric Lafortune
044:         */
045:        public class ProGuardObfuscator implements  Obfuscator {
046:            private static final String DEFAULT_CONFIGURATION = "default.pro";
047:
048:            // Implementations for Obfuscator.
049:
050:            public void createScriptFile(File jadFile, File projectDir) {
051:                // We don't really need to create a script file;
052:                // we'll just fill out all options in the run method.
053:            }
054:
055:            public void run(File obfuscatedJarFile, String wtkBinDir,
056:                    String wtkLibDir, String jarFileName,
057:                    String projectDirName, String classPath, String emptyAPI)
058:                    throws IOException {
059:                // Create the ProGuard configuration.
060:                Configuration configuration = new Configuration();
061:
062:                // Parse the default configuration file.
063:                ConfigurationParser parser = new ConfigurationParser(this 
064:                        .getClass().getResource(DEFAULT_CONFIGURATION));
065:
066:                try {
067:                    parser.parse(configuration);
068:
069:                    // Fill out the library class path.
070:                    configuration.libraryJars = classPath(classPath);
071:
072:                    // Fill out the program class path (input and output).
073:                    configuration.programJars = new ClassPath();
074:                    configuration.programJars.add(new ClassPathEntry(new File(
075:                            jarFileName), false));
076:                    configuration.programJars.add(new ClassPathEntry(
077:                            obfuscatedJarFile, true));
078:
079:                    // The preverify tool seems to unpack the resulting classes,
080:                    // so we must not use mixed-case class names on Windows.
081:                    configuration.useMixedCaseClassNames = !System.getProperty(
082:                            "os.name").regionMatches(true, 0, "windows", 0, 7);
083:
084:                    // Run ProGuard with these options.
085:                    ProGuard proGuard = new ProGuard(configuration);
086:                    proGuard.execute();
087:
088:                } catch (ParseException ex) {
089:                    throw new IOException(ex.getMessage());
090:                } finally {
091:                    parser.close();
092:                }
093:            }
094:
095:            /**
096:             * Converts the given class path String into a ClassPath object.
097:             */
098:            private ClassPath classPath(String classPathString) {
099:                ClassPath classPath = new ClassPath();
100:
101:                String separator = System.getProperty("path.separator");
102:
103:                int index = 0;
104:                while (index < classPathString.length()) {
105:                    // Find the next separator, or the end of the String.
106:                    int next_index = classPathString.indexOf(separator, index);
107:                    if (next_index < 0) {
108:                        next_index = classPathString.length();
109:                    }
110:
111:                    // Create and add the found class path entry.
112:                    ClassPathEntry classPathEntry = new ClassPathEntry(
113:                            new File(classPathString.substring(index,
114:                                    next_index)), false);
115:
116:                    classPath.add(classPathEntry);
117:
118:                    // Continue after the separator.
119:                    index = next_index + 1;
120:                }
121:
122:                return classPath;
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.