Source Code Cross Referenced for Field.java in  » Scripting » Kawa » gnu » 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 » Scripting » Kawa » gnu.bytecode 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 1997  Per M.A. Bothner.
002:        // This is free software;  for terms and warranty disclaimer see ./COPYING.
003:
004:        package gnu.bytecode;
005:
006:        import java.io.*;
007:
008:        public class Field extends Location implements  AttrContainer, Member {
009:            int flags;
010:            Field next;
011:
012:            Attribute attributes;
013:
014:            public final Attribute getAttributes() {
015:                return attributes;
016:            }
017:
018:            public final void setAttributes(Attribute attributes) {
019:                this .attributes = attributes;
020:            }
021:
022:            /** The class that contains this field. */
023:            ClassType owner;
024:
025:            /** If non-null, the interned source-file (unmangled) name of the field. */
026:            String sourceName;
027:
028:            /** If non-null, a cached version of the Field for reflectivion. */
029:            java.lang.reflect.Field rfield;
030:
031:            /** Add a new Field to a ClassType. */
032:            public Field(ClassType ctype) {
033:                if (ctype.last_field == null)
034:                    ctype.fields = this ;
035:                else
036:                    ctype.last_field.next = this ;
037:                ctype.last_field = this ;
038:                ctype.fields_count++;
039:                owner = ctype;
040:            }
041:
042:            public final ClassType getDeclaringClass() {
043:                return owner;
044:            }
045:
046:            public final void setStaticFlag(boolean is_static) {
047:                if (is_static)
048:                    flags |= Access.STATIC;
049:                else
050:                    flags ^= ~Access.STATIC;
051:            }
052:
053:            public final boolean getStaticFlag() {
054:                return (flags & Access.STATIC) != 0;
055:            }
056:
057:            public final int getFlags() {
058:                return flags;
059:            }
060:
061:            public final int getModifiers() {
062:                return flags;
063:            }
064:
065:            void write(DataOutputStream dstr, ClassType classfile)
066:                    throws java.io.IOException {
067:                dstr.writeShort(flags);
068:                dstr.writeShort(name_index);
069:                dstr.writeShort(signature_index);
070:
071:                Attribute.writeAll(this , dstr);
072:            }
073:
074:            void assign_constants(ClassType classfile) {
075:                ConstantPool constants = classfile.constants;
076:                if (name_index == 0 && name != null)
077:                    name_index = constants.addUtf8(name).index;
078:                if (signature_index == 0 && type != null)
079:                    signature_index = constants.addUtf8(type.signature).index;
080:                Attribute.assignConstants(this , classfile);
081:            }
082:
083:            public java.lang.reflect.Field getReflectField()
084:                    throws java.lang.NoSuchFieldException {
085:                if (rfield == null)
086:                    rfield = owner.getReflectClass()
087:                            .getDeclaredField(getName());
088:                return rfield;
089:            }
090:
091:            public void setSourceName(String name) {
092:                sourceName = name;
093:            }
094:
095:            public String getSourceName() {
096:                if (sourceName == null)
097:                    sourceName = getName().intern();
098:                return sourceName;
099:            }
100:
101:            /** Find a field with the given name.
102:             * @param fields list of fields to search
103:             * @param name (interned source) name of field to look for
104:             */
105:            public static Field searchField(Field fields, String name) {
106:                for (; fields != null; fields = fields.next) {
107:                    if (fields.getSourceName() == name)
108:                        return fields;
109:                }
110:                return null;
111:            }
112:
113:            public final Field getNext() {
114:                return next;
115:            }
116:
117:            /** Set the ConstantValue attribute for this field.
118:             * @param value the value to use for the ConstantValue attribute
119:             *   of this field
120:             * @param ctype the class that contains this field
121:             * This field's type is used to determine the kind of constant.
122:             */
123:            public final void setConstantValue(Object value, ClassType ctype) {
124:                ConstantPool cpool = ctype.constants;
125:                if (cpool == null)
126:                    ctype.constants = cpool = new ConstantPool();
127:                char sig1 = getType().getSignature().charAt(0);
128:                CpoolEntry entry;
129:                switch (sig1) {
130:                case 'Z':
131:                    entry = cpool.addInt(PrimType.booleanValue(value) ? 1 : 0);
132:                    break;
133:                case 'C':
134:                    if (value instanceof  Character) {
135:                        entry = cpool.addInt(((Character) value).charValue());
136:                        break;
137:                    }
138:                    /// else fall through ...
139:                case 'B':
140:                case 'S':
141:                case 'I':
142:                    entry = cpool.addInt(((Number) value).intValue());
143:                    break;
144:                case 'J':
145:                    entry = cpool.addLong(((Number) value).longValue());
146:                    break;
147:                case 'F':
148:                    entry = cpool.addFloat(((Number) value).floatValue());
149:                    break;
150:                case 'D':
151:                    entry = cpool.addDouble(((Number) value).doubleValue());
152:                    break;
153:                default:
154:                    entry = cpool.addString(value.toString());
155:                    break;
156:                }
157:                ConstantValueAttr attr = new ConstantValueAttr(entry.getIndex());
158:                attr.addToFrontOf(this );
159:            }
160:
161:            public String toString() {
162:                StringBuffer sbuf = new StringBuffer(100);
163:                sbuf.append("Field:");
164:                sbuf.append(getDeclaringClass().getName());
165:                sbuf.append('.');
166:                sbuf.append(name);
167:                return sbuf.toString();
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.