Source Code Cross Referenced for UnsafeFieldAccessorFactory.java in  » 6.0-JDK-Modules-sun » reflect » sun » reflect » 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 » 6.0 JDK Modules sun » reflect » sun.reflect 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2004 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package sun.reflect;
027:
028:        import java.lang.reflect.Field;
029:        import java.lang.reflect.Modifier;
030:
031:        class UnsafeFieldAccessorFactory {
032:            static FieldAccessor newFieldAccessor(Field field, boolean override) {
033:                Class type = field.getType();
034:                boolean isStatic = Modifier.isStatic(field.getModifiers());
035:                boolean isFinal = Modifier.isFinal(field.getModifiers());
036:                boolean isVolatile = Modifier.isVolatile(field.getModifiers());
037:                boolean isQualified = isFinal || isVolatile;
038:                boolean isReadOnly = isFinal && (isStatic || !override);
039:                if (isStatic) {
040:                    // This code path does not guarantee that the field's
041:                    // declaring class has been initialized, but it must be
042:                    // before performing reflective operations.
043:                    UnsafeFieldAccessorImpl.unsafe.ensureClassInitialized(field
044:                            .getDeclaringClass());
045:
046:                    if (!isQualified) {
047:                        if (type == Boolean.TYPE) {
048:                            return new UnsafeStaticBooleanFieldAccessorImpl(
049:                                    field);
050:                        } else if (type == Byte.TYPE) {
051:                            return new UnsafeStaticByteFieldAccessorImpl(field);
052:                        } else if (type == Short.TYPE) {
053:                            return new UnsafeStaticShortFieldAccessorImpl(field);
054:                        } else if (type == Character.TYPE) {
055:                            return new UnsafeStaticCharacterFieldAccessorImpl(
056:                                    field);
057:                        } else if (type == Integer.TYPE) {
058:                            return new UnsafeStaticIntegerFieldAccessorImpl(
059:                                    field);
060:                        } else if (type == Long.TYPE) {
061:                            return new UnsafeStaticLongFieldAccessorImpl(field);
062:                        } else if (type == Float.TYPE) {
063:                            return new UnsafeStaticFloatFieldAccessorImpl(field);
064:                        } else if (type == Double.TYPE) {
065:                            return new UnsafeStaticDoubleFieldAccessorImpl(
066:                                    field);
067:                        } else {
068:                            return new UnsafeStaticObjectFieldAccessorImpl(
069:                                    field);
070:                        }
071:                    } else {
072:                        if (type == Boolean.TYPE) {
073:                            return new UnsafeQualifiedStaticBooleanFieldAccessorImpl(
074:                                    field, isReadOnly);
075:                        } else if (type == Byte.TYPE) {
076:                            return new UnsafeQualifiedStaticByteFieldAccessorImpl(
077:                                    field, isReadOnly);
078:                        } else if (type == Short.TYPE) {
079:                            return new UnsafeQualifiedStaticShortFieldAccessorImpl(
080:                                    field, isReadOnly);
081:                        } else if (type == Character.TYPE) {
082:                            return new UnsafeQualifiedStaticCharacterFieldAccessorImpl(
083:                                    field, isReadOnly);
084:                        } else if (type == Integer.TYPE) {
085:                            return new UnsafeQualifiedStaticIntegerFieldAccessorImpl(
086:                                    field, isReadOnly);
087:                        } else if (type == Long.TYPE) {
088:                            return new UnsafeQualifiedStaticLongFieldAccessorImpl(
089:                                    field, isReadOnly);
090:                        } else if (type == Float.TYPE) {
091:                            return new UnsafeQualifiedStaticFloatFieldAccessorImpl(
092:                                    field, isReadOnly);
093:                        } else if (type == Double.TYPE) {
094:                            return new UnsafeQualifiedStaticDoubleFieldAccessorImpl(
095:                                    field, isReadOnly);
096:                        } else {
097:                            return new UnsafeQualifiedStaticObjectFieldAccessorImpl(
098:                                    field, isReadOnly);
099:                        }
100:                    }
101:                } else {
102:                    if (!isQualified) {
103:                        if (type == Boolean.TYPE) {
104:                            return new UnsafeBooleanFieldAccessorImpl(field);
105:                        } else if (type == Byte.TYPE) {
106:                            return new UnsafeByteFieldAccessorImpl(field);
107:                        } else if (type == Short.TYPE) {
108:                            return new UnsafeShortFieldAccessorImpl(field);
109:                        } else if (type == Character.TYPE) {
110:                            return new UnsafeCharacterFieldAccessorImpl(field);
111:                        } else if (type == Integer.TYPE) {
112:                            return new UnsafeIntegerFieldAccessorImpl(field);
113:                        } else if (type == Long.TYPE) {
114:                            return new UnsafeLongFieldAccessorImpl(field);
115:                        } else if (type == Float.TYPE) {
116:                            return new UnsafeFloatFieldAccessorImpl(field);
117:                        } else if (type == Double.TYPE) {
118:                            return new UnsafeDoubleFieldAccessorImpl(field);
119:                        } else {
120:                            return new UnsafeObjectFieldAccessorImpl(field);
121:                        }
122:                    } else {
123:                        if (type == Boolean.TYPE) {
124:                            return new UnsafeQualifiedBooleanFieldAccessorImpl(
125:                                    field, isReadOnly);
126:                        } else if (type == Byte.TYPE) {
127:                            return new UnsafeQualifiedByteFieldAccessorImpl(
128:                                    field, isReadOnly);
129:                        } else if (type == Short.TYPE) {
130:                            return new UnsafeQualifiedShortFieldAccessorImpl(
131:                                    field, isReadOnly);
132:                        } else if (type == Character.TYPE) {
133:                            return new UnsafeQualifiedCharacterFieldAccessorImpl(
134:                                    field, isReadOnly);
135:                        } else if (type == Integer.TYPE) {
136:                            return new UnsafeQualifiedIntegerFieldAccessorImpl(
137:                                    field, isReadOnly);
138:                        } else if (type == Long.TYPE) {
139:                            return new UnsafeQualifiedLongFieldAccessorImpl(
140:                                    field, isReadOnly);
141:                        } else if (type == Float.TYPE) {
142:                            return new UnsafeQualifiedFloatFieldAccessorImpl(
143:                                    field, isReadOnly);
144:                        } else if (type == Double.TYPE) {
145:                            return new UnsafeQualifiedDoubleFieldAccessorImpl(
146:                                    field, isReadOnly);
147:                        } else {
148:                            return new UnsafeQualifiedObjectFieldAccessorImpl(
149:                                    field, isReadOnly);
150:                        }
151:                    }
152:                }
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.