Source Code Cross Referenced for TreeItem.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: TreeItem.java,v 1.6 2002/05/24 08:55:31 glurk Exp $
025:         */package net.sf.javaguard;
026:
027:        import net.sf.javaguard.classfile.ClassFile;
028:
029:        /** Item that forms a tree structure and can represent a package level, a class,
030:         * or a method or field.
031:         *
032:         * @author <a href="mailto:markw@retrologic.com">Mark Welsh</a>
033:         * @author <a href="mailto:theit@gmx.de">Thorsten Heit</a>
034:         */
035:        public class TreeItem {
036:            /** Holds whether the method or field element is synthetic. */
037:            private boolean isSynthetic;
038:            /** Access level (interpret using java.lang.reflect.Modifier). */
039:            private int access;
040:            /** The owner of the current element. */
041:            private ClassTree classTree = null;
042:            /** The parent of the current tree element. */
043:            private TreeItem parent = null;
044:
045:            /** Holds a separator string preceeding this level's name. */
046:            private String separator = ClassFile.SEP_REGULAR;
047:            /** Original name of this item. */
048:            private String inName = null;
049:            /** Output name of this item. */
050:            private String outName = null;
051:            /** Holds whether the name has been fixed in some way. */
052:            private boolean isFixed = false;
053:            /** Holds whether this entry is constrained by a .script entry. */
054:            private boolean isFromScript = false;
055:            /** Holds whether this entry is constrained by a .script_map entry. */
056:            private boolean isFromScriptMap = false;
057:
058:            /** Holds whether the element should be ignored when generating obfuscated
059:             * names. */
060:            private boolean ignoreElement;
061:
062:            /** Holds whether the element must be obfuscated. */
063:            private boolean forceObfuscate;
064:
065:            /** Holds whether the element is matched by a script entry. */
066:            private boolean scriptEntryMatch;
067:
068:            /** Default constructor that creates a new tree item.
069:             * @param parent the parent of the tree item; may be null
070:             * @param name the name of the tree item
071:             */
072:            public TreeItem(TreeItem parent, String name) {
073:                setParent(parent);
074:                this .inName = name;
075:                if (null != getParent()) {
076:                    classTree = getParent().getClassTree();
077:                }
078:                setIgnoreElement(false);
079:                setForceObfuscate(false);
080:                setScriptEntryMatch(false);
081:            }
082:
083:            /** Sets the access modifiers.
084:             * @param access the access modifiers
085:             * @see #getModifiers
086:             */
087:            protected void setModifiers(int access) {
088:                this .access = access;
089:            }
090:
091:            /** Return the current access modifiers.
092:             * @return access modifiers
093:             * @see #setModifiers
094:             */
095:            public int getModifiers() {
096:                return access;
097:            }
098:
099:            /** Return the original name of the entry.
100:             * @return original name of the entry without the package prefix
101:             */
102:            public String getInName() {
103:                return inName;
104:            }
105:
106:            /** Construct and return the full original name of the entry.
107:             * @return full original name in the form <code>package.subpackage.class</code>
108:             */
109:            public String getFullInName() {
110:                if (null == getParent()) {
111:                    return "";
112:                } else if (null == getParent().getParent()) {
113:                    return getInName();
114:                } else {
115:                    return getParent().getFullInName() + getSeparator()
116:                            + getInName();
117:                }
118:            }
119:
120:            /** Construct and return the full obfuscated name of the entry.
121:             * @return full obfuscated name of the entry
122:             */
123:            public String getFullOutName() {
124:                if (null == getParent()) {
125:                    return "";
126:                } else if (getParent().getParent() == null) {
127:                    return getOutName();
128:                } else {
129:                    return getParent().getFullOutName() + getSeparator()
130:                            + getOutName();
131:                }
132:            }
133:
134:            /** Set the output name of the entry.
135:             * @param outName output name of the entry
136:             */
137:            public void setOutName(String outName) {
138:                this .outName = outName;
139:                isFixed = true;
140:            }
141:
142:            /** Return the output name of the entry, obfuscated or original.
143:             * @return output name of the entry without package prefix
144:             */
145:            public String getOutName() {
146:                if (null != outName) {
147:                    return outName;
148:                }
149:                return getInName();
150:            }
151:
152:            /** Return the obfuscated name of the entry.
153:             * @return obfuscated name of the entry; may be null if not yet set
154:             */
155:            public String getObfName() {
156:                return outName;
157:            }
158:
159:            /** Signals that this constraint comes from an entry in the script file.
160:             */
161:            public void setFromScript() {
162:                isFromScript = true;
163:            }
164:
165:            /** Returns whether the element is constrained by an entry in the script file.
166:             * @return true if the element is constrained by an entry in the script file;
167:             * false else
168:             */
169:            public boolean isFromScript() {
170:                return isFromScript;
171:            }
172:
173:            /** Signals that this constraint comes from a mapping directive in the script
174:             * file.
175:             */
176:            public void setFromScriptMap() {
177:                isFromScriptMap = true;
178:            }
179:
180:            /** Returns whether the element is constrained by a mapping directive in the
181:             * script file.
182:             * @return true if the element is constrained by a mapping directive in the
183:             * script file; false else
184:             */
185:            public boolean isFromScriptMap() {
186:                return isFromScriptMap;
187:            }
188:
189:            /** Returns whether the entry has been fixed already in some way.
190:             * @return true if the entry has been fixed; false else
191:             */
192:            public boolean isFixed() {
193:                return isFixed;
194:            }
195:
196:            /** Sets whether the element is synthetic.
197:             * @param synthetic true if the element is synthetic; false else
198:             * @see #isSynthetic
199:             */
200:            protected void setSynthetic(boolean synthetic) {
201:                this .isSynthetic = synthetic;
202:            }
203:
204:            /** Returns whether the element is synthetic.
205:             * @return true if the element is synthetic; false else
206:             * @see #setSynthetic
207:             */
208:            public boolean isSynthetic() {
209:                return isSynthetic;
210:            }
211:
212:            /** Set the parent element of the current one in the tree. Used when
213:             * stitching in a Cl to replace a PlaceholderCl.
214:             * @param parent the parent tree element
215:             */
216:            public void setParent(TreeItem parent) {
217:                this .parent = parent;
218:            }
219:
220:            /** Return the parent element in the tree.
221:             * @return parent tree element
222:             */
223:            public TreeItem getParent() {
224:                return parent;
225:            }
226:
227:            /** Sets whether the current element should be ignored when generating the
228:             * obfuscated name list or not.
229:             * @param ignore true if the current element should be ignored; false else
230:             * @see #canIgnoreElement
231:             */
232:            public void setIgnoreElement(boolean ignore) {
233:                this .ignoreElement = ignore;
234:            }
235:
236:            /** Returns whether the current element should be ignored when generating
237:             * obfuscated names.
238:             * @return true if the current element should be ignored; false else
239:             * @see #setIgnoreElement
240:             */
241:            public boolean canIgnoreElement() {
242:                return ignoreElement;
243:            }
244:
245:            /** Sets whether the current element must be obfuscated or not.
246:             * @param force true if the current element must be obfuscated; false else
247:             * @see #canForceObfuscate
248:             */
249:            public void setForceObfuscate(boolean force) {
250:                this .forceObfuscate = force;
251:            }
252:
253:            /** Returns whether the current element must be obfuscated.
254:             * @return true if the current element must be obfuscated; false else
255:             * @see #setForceObfuscate
256:             */
257:            public boolean canForceObfuscate() {
258:                return forceObfuscate;
259:            }
260:
261:            /** Defines the class tree the tree item belongs to.
262:             * @param ct the class tree
263:             * @see #getClassTree
264:             * @see ClassTree
265:             */
266:            protected void setClassTree(ClassTree ct) {
267:                this .classTree = ct;
268:            }
269:
270:            /** Returns the class tree the tree item belongs to.
271:             * @return class tree
272:             * @see #setClassTree
273:             * @see ClassTree
274:             */
275:            protected ClassTree getClassTree() {
276:                if (null == classTree) {
277:                    if (null != getParent()) {
278:                        setClassTree(getParent().getClassTree());
279:                    }
280:                }
281:                return classTree;
282:            }
283:
284:            /** Sets the separator string to distinguish sub-levels.
285:             * @param separator the separator string
286:             * @see #getSeparator
287:             */
288:            protected void setSeparator(String separator) {
289:                this .separator = separator;
290:            }
291:
292:            /** Returns the separator string that allows to distinguish sub-levels.
293:             * @return separator string
294:             * @see #setSeparator
295:             */
296:            public String getSeparator() {
297:                return separator;
298:            }
299:
300:            /** Sets whether the tree item is matched by a script entry.
301:             * @param match true if the item is matched by a script entry; false else
302:             * @see #isScriptEntryMatch
303:             */
304:            public void setScriptEntryMatch(boolean match) {
305:                this .scriptEntryMatch = match;
306:            }
307:
308:            /** Returns whether the tree item is matched by a script entry.
309:             * @return true if there's an entry that matches the tree item; false else
310:             */
311:            public boolean isScriptEntryMatch() {
312:                return scriptEntryMatch;
313:            }
314:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.