Source Code Cross Referenced for SelfClass.java in  » Database-DBMS » db4o-6.4 » com » db4o » reflect » self » 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 » Database DBMS » db4o 6.4 » com.db4o.reflect.self 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (C) 2004 - 2007  db4objects Inc.  http://www.db4o.com
002:
003:        This file is part of the db4o open source object database.
004:
005:        db4o is free software; you can redistribute it and/or modify it under
006:        the terms of version 2 of the GNU General Public License as published
007:        by the Free Software Foundation and as clarified by db4objects' GPL 
008:        interpretation policy, available at
009:        http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010:        Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011:        Suite 350, San Mateo, CA 94403, USA.
012:
013:        db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014:        WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:        FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:        for more details.
017:
018:        You should have received a copy of the GNU General Public License along
019:        with this program; if not, write to the Free Software Foundation, Inc.,
020:        59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */
021:        package com.db4o.reflect.self;
022:
023:        import com.db4o.reflect.*;
024:
025:        public class SelfClass implements  ReflectClass {
026:            private static final SelfField[] EMPTY_FIELDS = new SelfField[0];
027:
028:            private boolean _isAbstract;
029:
030:            private SelfField[] _fields;
031:
032:            private Reflector _parentReflector;
033:
034:            private SelfReflectionRegistry _registry;
035:
036:            private Class _class;
037:
038:            private Class _super Class;
039:
040:            // public SelfClass() {
041:            // super();
042:            // }
043:
044:            public SelfClass(Reflector parentReflector,
045:                    SelfReflectionRegistry registry, Class clazz) {
046:                _parentReflector = parentReflector;
047:                _registry = registry;
048:                _class = clazz;
049:            }
050:
051:            // TODO: Is this needed at all?
052:            public Class getJavaClass() {
053:                return _class;
054:            }
055:
056:            public Reflector reflector() {
057:                return _parentReflector;
058:            }
059:
060:            public ReflectClass getComponentType() {
061:                if (!isArray()) {
062:                    return null;
063:                }
064:                return _parentReflector.forClass(_registry
065:                        .componentType(_class));
066:            }
067:
068:            public ReflectConstructor[] getDeclaredConstructors() {
069:                if (isInterface()) {
070:                    return new SelfConstructor[0];
071:                }
072:                return new SelfConstructor[] { new SelfConstructor(_class) };
073:            }
074:
075:            public ReflectField[] getDeclaredFields() {
076:                ensureClassInfoLoaded();
077:                return _fields;
078:            }
079:
080:            private void ensureClassInfoLoaded() {
081:                if (_fields == null) {
082:                    ClassInfo classInfo = _registry.infoFor(_class);
083:                    if (classInfo == null) {
084:                        _fields = EMPTY_FIELDS;
085:                        return;
086:                    }
087:                    _super Class = classInfo.super Class();
088:                    _isAbstract = classInfo.isAbstract();
089:                    FieldInfo[] fieldInfo = classInfo.fieldInfo();
090:                    if (fieldInfo == null) {
091:                        _fields = EMPTY_FIELDS;
092:                        return;
093:                    }
094:                    _fields = new SelfField[fieldInfo.length];
095:                    for (int idx = 0; idx < fieldInfo.length; idx++) {
096:                        _fields[idx] = selfFieldFor(fieldInfo[idx]);
097:                    }
098:                }
099:            }
100:
101:            public ReflectField getDeclaredField(String name) {
102:                ensureClassInfoLoaded();
103:                for (int idx = 0; idx < _fields.length; idx++) {
104:                    if (_fields[idx].getName().equals(name)) {
105:                        return _fields[idx];
106:                    }
107:                }
108:                return null;
109:            }
110:
111:            private SelfField selfFieldFor(FieldInfo fieldInfo) {
112:                return new SelfField(fieldInfo.name(), _parentReflector
113:                        .forClass(fieldInfo.type()), this , _registry);
114:            }
115:
116:            public ReflectClass getDelegate() {
117:                return this ;
118:            }
119:
120:            public ReflectMethod getMethod(String methodName,
121:                    ReflectClass[] paramClasses) {
122:                // TODO !!!!
123:                return null;
124:            }
125:
126:            public String getName() {
127:                return _class.getName();
128:            }
129:
130:            public ReflectClass getSuperclass() {
131:                ensureClassInfoLoaded();
132:                if (_super Class == null) {
133:                    return null;
134:                }
135:                return _parentReflector.forClass(_super Class);
136:            }
137:
138:            public boolean isAbstract() {
139:                ensureClassInfoLoaded();
140:                return _isAbstract || isInterface();
141:            }
142:
143:            public boolean isArray() {
144:                return _class.isArray();
145:            }
146:
147:            public boolean isAssignableFrom(ReflectClass type) {
148:                if (!(type instanceof  SelfClass)) {
149:                    return false;
150:                }
151:                return _class.isAssignableFrom(((SelfClass) type)
152:                        .getJavaClass());
153:            }
154:
155:            public boolean isCollection() {
156:                return _parentReflector.isCollection(this );
157:            }
158:
159:            public boolean isInstance(Object obj) {
160:                return _class.isInstance(obj);
161:            }
162:
163:            public boolean isInterface() {
164:                return _class.isInterface();
165:            }
166:
167:            public boolean isPrimitive() {
168:                return _registry.isPrimitive(_class);
169:            }
170:
171:            public boolean isSecondClass() {
172:                return isPrimitive();
173:            }
174:
175:            public Object newInstance() {
176:                try {
177:                    return _class.newInstance();
178:                } catch (Exception e) {
179:                    e.printStackTrace();
180:                }
181:
182:                // Specialized exceptions break conversion to .NET
183:
184:                //           
185:                //        
186:                //            
187:                // } catch (InstantiationException e) {
188:                // e.printStackTrace();
189:                // } catch (IllegalAccessException e) {
190:                // e.printStackTrace();
191:                // }
192:
193:                return null;
194:            }
195:
196:            public boolean skipConstructor(boolean flag, boolean testConstructor) {
197:                // cannot skip constructors, only available for JDK1.4+
198:                return false;
199:            }
200:
201:            public void useConstructor(ReflectConstructor constructor,
202:                    Object[] params) {
203:                // ignore, there must be a public no-args constructor suitable for
204:                // Class.newInstance()
205:            }
206:
207:            // FIXME: remove. Reintroduced since OM depends on it - refactor OM.
208:            public Object[] toArray(Object obj) {
209:                return null;
210:            }
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.