Source Code Cross Referenced for CpInfo.java in  » Development » yguardlib » com » yworks » yguard » obf » classfile » 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 » yguardlib » com.yworks.yguard.obf.classfile 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * YGuard -- an obfuscation library for Java(TM) classfiles.
003:         *
004:         * Original Copyright (c) 1999 Mark Welsh (markw@retrologic.com)
005:         * Modifications Copyright (c) 2002 yWorks GmbH (yguard@yworks.com)
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 yguard@yworks.com 
022:         *
023:         * Java and all Java-based marks are trademarks or registered 
024:         * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
025:         */package com.yworks.yguard.obf.classfile;
026:
027:        import java.io.*;
028:        import java.util.*;
029:
030:        /**
031:         * Representation of an entry in the ConstantPool. Specific types of entry
032:         * have their representations sub-classed from this.
033:         *
034:         * @author      Mark Welsh
035:         */
036:        abstract public class CpInfo implements  ClassConstants {
037:            // Constants -------------------------------------------------------------
038:
039:            // Fields ----------------------------------------------------------------
040:            private int u1tag;
041:            private byte info[];
042:
043:            protected int refCount = 0; // Used for reference counting in Constant Pool
044:
045:            // Class Methods ---------------------------------------------------------
046:            /**
047:             * Create a new CpInfo from the data passed.
048:             *
049:             * @throws IOException if class file is corrupt or incomplete
050:             */
051:            public static CpInfo create(DataInput din)
052:                    throws java.io.IOException {
053:                if (din == null)
054:                    throw new NullPointerException(
055:                            "No input stream was provided.");
056:
057:                // Instantiate based on tag byte
058:                CpInfo ci = null;
059:                switch (din.readUnsignedByte()) {
060:                case CONSTANT_Utf8:
061:                    ci = new Utf8CpInfo();
062:                    break;
063:                case CONSTANT_Integer:
064:                    ci = new IntegerCpInfo();
065:                    break;
066:                case CONSTANT_Float:
067:                    ci = new FloatCpInfo();
068:                    break;
069:                case CONSTANT_Long:
070:                    ci = new LongCpInfo();
071:                    break;
072:                case CONSTANT_Double:
073:                    ci = new DoubleCpInfo();
074:                    break;
075:                case CONSTANT_Class:
076:                    ci = new ClassCpInfo();
077:                    break;
078:                case CONSTANT_String:
079:                    ci = new StringCpInfo();
080:                    break;
081:                case CONSTANT_Fieldref:
082:                    ci = new FieldrefCpInfo();
083:                    break;
084:                case CONSTANT_Methodref:
085:                    ci = new MethodrefCpInfo();
086:                    break;
087:                case CONSTANT_InterfaceMethodref:
088:                    ci = new InterfaceMethodrefCpInfo();
089:                    break;
090:                case CONSTANT_NameAndType:
091:                    ci = new NameAndTypeCpInfo();
092:                    break;
093:                default:
094:                    throw new IOException("Unknown tag type in constant pool.");
095:                }
096:                ci.readInfo(din);
097:                return ci;
098:            }
099:
100:            // Instance Methods ------------------------------------------------------
101:            protected CpInfo(int tag) {
102:                u1tag = tag;
103:            }
104:
105:            /** Read the 'info' data following the u1tag byte; over-ride this in sub-classes. */
106:            abstract protected void readInfo(DataInput din)
107:                    throws java.io.IOException;
108:
109:            /** Check for Utf8 references to constant pool and mark them; over-ride this in sub-classes. */
110:            protected void markUtf8Refs(ConstantPool pool) {
111:            }
112:
113:            /** Check for NameAndType references to constant pool and mark them; over-ride this in sub-classes. */
114:            protected void markNTRefs(ConstantPool pool) {
115:            }
116:
117:            /** Export the representation to a DataOutput stream. */
118:            public void write(DataOutput dout) throws java.io.IOException {
119:                if (dout == null)
120:                    throw new IOException("No output stream was provided.");
121:                dout.writeByte(u1tag);
122:                writeInfo(dout);
123:            }
124:
125:            /** Write the 'info' data following the u1tag byte; over-ride this in sub-classes. */
126:            abstract protected void writeInfo(DataOutput dout)
127:                    throws java.io.IOException;
128:
129:            /** Return the reference count. */
130:            public int getRefCount() {
131:                return refCount;
132:            }
133:
134:            /** Increment the reference count. */
135:            public void incRefCount() {
136:                refCount++;
137:            }
138:
139:            /** Decrement the reference count. */
140:            public void decRefCount() {
141:                if (refCount == 0)
142:                    throw new IllegalStateException(
143:                            "Illegal to reference count is already zero.");
144:                refCount--;
145:            }
146:
147:            /** Reset the reference count to zero. */
148:            public void resetRefCount() {
149:                refCount = 0;
150:            }
151:
152:            /** Dump the content of the class file to the specified file (used for debugging). */
153:            public void dump(PrintWriter pw, ClassFile cf, int index) {
154:                pw.println(this.getClass().getName());
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.