Source Code Cross Referenced for PkCl.java in  » Development » javaguard » net » sf » javaguard » 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 » javaguard » net.sf.javaguard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JavaGuard -- an obfuscation package for Java classfiles.
003:         *
004:         * Copyright (c) 1999 Mark Welsh (markw@retrologic.com)
005:         * Copyright (c) 2002 Thorsten Heit (theit@gmx.de)
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         *
021:         * The author may be contacted at theit@gmx.de.
022:         *
023:         *
024:         * $Id: PkCl.java,v 1.5 2002/05/13 17:22:55 glurk Exp $
025:         */package net.sf.javaguard;
026:
027:        import java.util.*;
028:
029:        /** Base to package and class tree item.
030:         *
031:         * @author <a href="mailto:markw@retrologic.com">Mark Welsh</a>
032:         * @author <a href="mailto:theit@gmx.de">Thorsten Heit</a>
033:         */
034:        abstract public class PkCl extends TreeItem {
035:            /** Stores a list of subclasses. */
036:            protected Map cls;
037:
038:            /** Constructor that initializes the tree item.
039:             * @param parent the tree parent for the current element
040:             * @param name the name of the current element
041:             */
042:            public PkCl(TreeItem parent, String name) {
043:                super (parent, name);
044:                cls = new TreeMap();
045:            }
046:
047:            /** Get a class by name.
048:             * @param name the class name to find
049:             * @return the class element with the given name
050:             */
051:            public Cl getClass(String name) {
052:                return (Cl) cls.get(name);
053:            }
054:
055:            /** Get an iteration for all classes directly beneath this tree item.
056:             * @return iterator for all classes beneath the current tree item
057:             */
058:            public Iterator getClassIterator() {
059:                return cls.values().iterator();
060:            }
061:
062:            /** Get an iteration of all classes (both outer and inner) in the tree
063:             * beneath this tree item.
064:             * @return iterator for all subclasses of the current tree item
065:             */
066:            public Iterator getAllClassIterator() {
067:                Vector allClasses = new Vector();
068:                addAllClasses(allClasses);
069:                return allClasses.iterator();
070:            }
071:
072:            /** List classes and recursively compose a list of all inner classes.
073:             * @param allClasses a vector that will hold all subclasses of the current
074:             * tree item
075:             */
076:            protected void addAllClasses(Vector allClasses) {
077:                for (Iterator iter = getClassIterator(); iter.hasNext();) {
078:                    Cl cl = (Cl) iter.next();
079:                    allClasses.addElement(cl);
080:                    cl.addAllClasses(allClasses);
081:                }
082:            }
083:
084:            /** Return the number of classes beneath the current tree item.
085:             * @return number of classes beneath the tree item
086:             */
087:            public int getClassCount() {
088:                return cls.size();
089:            }
090:
091:            /** Add a class to the list of owned classes.
092:             * @param name the name of the class
093:             * @param superName the name of the super class
094:             * @param interfaceNames array with implemented interfaces
095:             */
096:            abstract public Cl addClass(String name, String super Name,
097:                    String[] interfaceNames);
098:
099:            /** Add a class to the list of owned classes.
100:             * @param name the name of the class
101:             * @param isInnerClass true if the class specifies an inner class; false else
102:             * @param superName the name of the super class
103:             * @param interfaceNames array with implemented interfaces
104:             */
105:            protected Cl addClass(String name, boolean isInnerClass,
106:                    String super Name, String[] interfaceNames) {
107:                Cl cl = getClass(name);
108:
109:                // Remove placeholder if present
110:                PlaceholderCl plClassItem = null;
111:                if (cl instanceof  PlaceholderCl) {
112:                    plClassItem = (PlaceholderCl) cl;
113:                    cls.remove(name);
114:                    cl = null;
115:                }
116:
117:                // Add the class, if not already present
118:                if (null == cl) {
119:                    cl = new Cl(this , isInnerClass, name, super Name,
120:                            interfaceNames);
121:                    cls.put(name, cl);
122:                }
123:
124:                // Copy over the inner class data from the placeholder, if any
125:                if (plClassItem != null) {
126:                    for (Iterator iter = plClassItem.getClassIterator(); iter
127:                            .hasNext();) {
128:                        Cl innerCl = (Cl) iter.next();
129:                        innerCl.setParent(cl);
130:                        cl.addClass(innerCl);
131:                    }
132:                }
133:                return cl;
134:            }
135:
136:            /** Add a placeholder class to our list of owned classes that will be replaced
137:             * later by the full class.
138:             * @param name the name of the placeholder class
139:             */
140:            abstract public Cl addPlaceholderClass(String name);
141:
142:            /** Add a placeholder class to our list of owned classes that will be replaced
143:             * later by the full class.
144:             * @param name the name of the placeholder class
145:             * @param isInnerClass true if the placeholder class specifies an inner class;
146:             * false else
147:             */
148:            protected Cl addPlaceholderClass(String name, boolean isInnerClass) {
149:                Cl cl = getClass(name);
150:                if (cl == null) {
151:                    cl = new PlaceholderCl(this , isInnerClass, name);
152:                    cls.put(name, cl);
153:                }
154:                return cl;
155:            }
156:
157:            /** Generate unique obfuscated names for this namespace.
158:             */
159:            public void generateNames() {
160:                generateNames(cls);
161:            }
162:
163:            /** Generate unique obfuscated names for a given namespace.
164:             * @param map the namespace
165:             */
166:            protected void generateNames(Map map) {
167:                Vector vec = new Vector();
168:                for (Iterator iter = map.values().iterator(); iter.hasNext();) {
169:                    TreeItem ti = (TreeItem) iter.next();
170:                    // elements that are already fixed in some way or that should be ignored
171:                    // must be excluded from the name generation step
172:                    if (ti.isFixed() || ti.canIgnoreElement()) {
173:                        vec.addElement(ti.getOutName());
174:                    }
175:                }
176:                String[] noObfNames = new String[vec.size()];
177:                for (int i = 0; i < noObfNames.length; i++) {
178:                    noObfNames[i] = (String) vec.elementAt(i);
179:                }
180:                NameMaker nm = new KeywordNameMaker(noObfNames, false, true);
181:                for (Iterator iter = map.values().iterator(); iter.hasNext();) {
182:                    TreeItem ti = (TreeItem) iter.next();
183:                    if (!ti.isFixed() && !ti.canIgnoreElement()) {
184:                        ti.setOutName(nm.nextName(null));
185:                    }
186:                }
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.