Source Code Cross Referenced for Pk.java in  » Development » RetroGuard » COM » rl » obf » 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 » RetroGuard » COM.rl.obf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================================
002:         * $RCSfile: Pk.java,v $
003:         * ===========================================================================
004:         *
005:         * RetroGuard -- an obfuscation package for Java classfiles.
006:         *
007:         * Copyright (c) 1998-2006 Mark Welsh (markw@retrologic.com)
008:         *
009:         * This program can be redistributed and/or modified under the terms of the 
010:         * Version 2 of the GNU General Public License as published by the Free 
011:         * Software Foundation.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
016:         * GNU General Public License for more details.
017:         *
018:         */
019:
020:        package COM.rl.obf;
021:
022:        import java.io.*;
023:        import java.lang.reflect.*;
024:        import java.util.*;
025:        import COM.rl.util.*;
026:        import COM.rl.obf.classfile.*;
027:
028:        /**
029:         * Tree item representing a package.
030:         *
031:         * @author      Mark Welsh
032:         */
033:        public class Pk extends PkCl {
034:            // Constants -------------------------------------------------------------
035:
036:            // Fields ----------------------------------------------------------------
037:            private Hashtable pks = new Hashtable(); // Owns a list of sub-package levels
038:            private String repackageName = null; // Compact name for this package
039:
040:            // Class Methods ---------------------------------------------------------
041:            /** Create the root entry for a tree. */
042:            public static Pk createRoot(ClassTree classTree) {
043:                return new Pk(classTree);
044:            }
045:
046:            // Instance Methods ------------------------------------------------------
047:            /** Constructor for default package level. */
048:            public Pk(ClassTree classTree) {
049:                this (null, "");
050:                this .classTree = classTree;
051:            }
052:
053:            /** Constructor for regular package levels. */
054:            public Pk(TreeItem parent, String name) {
055:                super (parent, name);
056:                if (parent == null && !name.equals("")) {
057:                    System.err
058:                            .println("Internal error: only the default package has no parent");
059:                } else if (parent != null && name.equals("")) {
060:                    System.err
061:                            .println("Internal error: the default package cannot have a parent");
062:                }
063:            }
064:
065:            /** Set the repackage name of the entry. */
066:            public void setRepackageName(String repackageName) {
067:                this .repackageName = repackageName;
068:            }
069:
070:            /** Return the repackage name of the entry. */
071:            public String getRepackageName() {
072:                return this .repackageName;
073:            }
074:
075:            /** Get a package level by name. */
076:            public Pk getPackage(String name) throws Exception {
077:                return (Pk) pks.get(name);
078:            }
079:
080:            /** Get a package level by obfuscated name. */
081:            public Pk getObfPackage(String name) throws Exception {
082:                for (Enumeration enm = pks.elements(); enm.hasMoreElements();) {
083:                    Pk pk = (Pk) enm.nextElement();
084:                    if (name.equals(pk.getOutName())) {
085:                        return pk;
086:                    }
087:                }
088:                return null;
089:            }
090:
091:            /** Get a package level by obfuscated repackage name. */
092:            public Pk getObfRepackage(String name) throws Exception {
093:                for (Enumeration enm = pks.elements(); enm.hasMoreElements();) {
094:                    Pk pk = (Pk) enm.nextElement();
095:                    if (name.equals(pk.getRepackageName())) {
096:                        return pk;
097:                    }
098:                    Pk sub = pk.getObfRepackage(name);
099:                    if (sub != null) {
100:                        return sub;
101:                    }
102:                }
103:                return null;
104:            }
105:
106:            /** Get an Enumeration of packages. */
107:            public Enumeration getPackageEnum() throws Exception {
108:                return pks.elements();
109:            }
110:
111:            /** Return number of packages. */
112:            public int getPackageCount() {
113:                return pks.size();
114:            }
115:
116:            /** Add a sub-package level. */
117:            public Pk addPackage(String name) throws Exception {
118:                Pk pk = getPackage(name);
119:                if (pk == null) {
120:                    pk = new Pk(this , name);
121:                    pks.put(name, pk);
122:                }
123:                return pk;
124:            }
125:
126:            /** Add a class. */
127:            public Cl addClass(String name, String super Name,
128:                    String[] interfaceNames, int access) throws Exception {
129:                return addClass(false, name, super Name, interfaceNames, access);
130:            }
131:
132:            /** Add a placeholder class. */
133:            public Cl addPlaceholderClass(String name) throws Exception {
134:                return addPlaceholderClass(false, name);
135:            }
136:
137:            /** Generate unique obfuscated names for this namespace. */
138:            public void generateNames() throws Exception {
139:                super .generateNames();
140:                generateNames(pks);
141:            }
142:
143:            /** Generate unique-across-run obfuscated repackage name. */
144:            public void repackageName(NameMaker nm) throws Exception {
145:                if (!isFixed()) {
146:                    setRepackageName(nm.nextName(null));
147:                    setOutName(getInName());
148:                }
149:            }
150:
151:            /** Construct and return the full obfuscated name of the entry. */
152:            public String getFullOutName() {
153:                if (getRepackageName() == null) {
154:                    return super.getFullOutName();
155:                } else {
156:                    return getRepackageName();
157:                }
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.