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


001:        /* FieldInfo Copyright (C) 1998-2002 Jochen Hoenicke.
002:         *
003:         * This program is free software; you can redistribute it and/or modify
004:         * it under the terms of the GNU Lesser General Public License as published by
005:         * the Free Software Foundation; either version 2, or (at your option)
006:         * any later version.
007:         *
008:         * This program is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011:         * GNU General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public License
014:         * along with this program; see the file COPYING.LESSER.  If not, write to
015:         * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
016:         *
017:         * $Id: FieldInfo.java,v 1.10.2.1 2002/05/28 17:34:00 hoenicke Exp $
018:         */
019:
020:        package jode.bytecode;
021:
022:        import java.io.DataInputStream;
023:        import java.io.DataOutputStream;
024:        import java.io.IOException;
025:        import java.lang.reflect.Modifier;
026:
027:        public class FieldInfo extends BinaryInfo {
028:            ClassInfo clazzInfo;
029:
030:            int modifier;
031:            String name;
032:            String typeSig;
033:
034:            Object constant;
035:            boolean syntheticFlag;
036:            boolean deprecatedFlag;
037:
038:            public FieldInfo(ClassInfo ci) {
039:                this .clazzInfo = ci;
040:            }
041:
042:            public FieldInfo(ClassInfo ci, String name, String typeSig,
043:                    int modifier) {
044:                this .clazzInfo = ci;
045:                this .name = name;
046:                this .typeSig = typeSig;
047:                this .modifier = modifier;
048:            }
049:
050:            protected void readAttribute(String name, int length,
051:                    ConstantPool cp, DataInputStream input, int howMuch)
052:                    throws IOException {
053:                if ((howMuch & KNOWNATTRIBS) != 0
054:                        && name.equals("ConstantValue")) {
055:                    if (length != 2)
056:                        throw new ClassFormatException(
057:                                "ConstantValue attribute" + " has wrong length");
058:                    int index = input.readUnsignedShort();
059:                    constant = cp.getConstant(index);
060:                } else if (name.equals("Synthetic")) {
061:                    syntheticFlag = true;
062:                    if (length != 0)
063:                        throw new ClassFormatException(
064:                                "Synthetic attribute has wrong length");
065:                } else if (name.equals("Deprecated")) {
066:                    deprecatedFlag = true;
067:                    if (length != 0)
068:                        throw new ClassFormatException(
069:                                "Deprecated attribute has wrong length");
070:                } else
071:                    super .readAttribute(name, length, cp, input, howMuch);
072:            }
073:
074:            public void read(ConstantPool constantPool, DataInputStream input,
075:                    int howMuch) throws IOException {
076:                modifier = input.readUnsignedShort();
077:                name = constantPool.getUTF8(input.readUnsignedShort());
078:                typeSig = constantPool.getUTF8(input.readUnsignedShort());
079:                readAttributes(constantPool, input, howMuch);
080:            }
081:
082:            public void reserveSmallConstants(GrowableConstantPool gcp) {
083:            }
084:
085:            public void prepareWriting(GrowableConstantPool gcp) {
086:                gcp.putUTF8(name);
087:                gcp.putUTF8(typeSig);
088:                if (constant != null) {
089:                    gcp.putUTF8("ConstantValue");
090:                    if (typeSig.charAt(0) == 'J' || typeSig.charAt(0) == 'D')
091:                        gcp.putLongConstant(constant);
092:                    else
093:                        gcp.putConstant(constant);
094:                }
095:                if (syntheticFlag)
096:                    gcp.putUTF8("Synthetic");
097:                if (deprecatedFlag)
098:                    gcp.putUTF8("Deprecated");
099:                prepareAttributes(gcp);
100:            }
101:
102:            protected int getKnownAttributeCount() {
103:                int count = 0;
104:                if (constant != null)
105:                    count++;
106:                if (syntheticFlag)
107:                    count++;
108:                if (deprecatedFlag)
109:                    count++;
110:                return count;
111:            }
112:
113:            public void writeKnownAttributes(GrowableConstantPool gcp,
114:                    DataOutputStream output) throws IOException {
115:                if (constant != null) {
116:                    output.writeShort(gcp.putUTF8("ConstantValue"));
117:                    output.writeInt(2);
118:                    int index;
119:                    if (typeSig.charAt(0) == 'J' || typeSig.charAt(0) == 'D')
120:                        index = gcp.putLongConstant(constant);
121:                    else
122:                        index = gcp.putConstant(constant);
123:                    output.writeShort(index);
124:                }
125:                if (syntheticFlag) {
126:                    output.writeShort(gcp.putUTF8("Synthetic"));
127:                    output.writeInt(0);
128:                }
129:                if (deprecatedFlag) {
130:                    output.writeShort(gcp.putUTF8("Deprecated"));
131:                    output.writeInt(0);
132:                }
133:            }
134:
135:            public void write(GrowableConstantPool constantPool,
136:                    DataOutputStream output) throws IOException {
137:                output.writeShort(modifier);
138:                output.writeShort(constantPool.putUTF8(name));
139:                output.writeShort(constantPool.putUTF8(typeSig));
140:                writeAttributes(constantPool, output);
141:            }
142:
143:            public void dropInfo(int howMuch) {
144:                if ((howMuch & KNOWNATTRIBS) != 0)
145:                    constant = null;
146:                super .dropInfo(howMuch);
147:            }
148:
149:            public String getName() {
150:                return name;
151:            }
152:
153:            public String getType() {
154:                return typeSig;
155:            }
156:
157:            public int getModifiers() {
158:                return modifier;
159:            }
160:
161:            public boolean isSynthetic() {
162:                return syntheticFlag;
163:            }
164:
165:            public boolean isDeprecated() {
166:                return deprecatedFlag;
167:            }
168:
169:            public Object getConstant() {
170:                clazzInfo.loadInfo(KNOWNATTRIBS);
171:                return constant;
172:            }
173:
174:            public void setName(String newName) {
175:                name = newName;
176:            }
177:
178:            public void setType(String newType) {
179:                typeSig = newType;
180:            }
181:
182:            public void setModifiers(int newModifier) {
183:                modifier = newModifier;
184:            }
185:
186:            public void setSynthetic(boolean flag) {
187:                syntheticFlag = flag;
188:            }
189:
190:            public void setDeprecated(boolean flag) {
191:                deprecatedFlag = flag;
192:            }
193:
194:            public void setConstant(Object newConstant) {
195:                constant = newConstant;
196:            }
197:
198:            public String toString() {
199:                return "Field " + Modifier.toString(modifier) + " " + typeSig
200:                        + " " + name;
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.