Source Code Cross Referenced for PrimitiveHandler.java in  » Database-DBMS » db4o-6.4 » com » db4o » internal » handlers » 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.internal.handlers 
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.internal.handlers;
022:
023:        import com.db4o.*;
024:        import com.db4o.foundation.*;
025:        import com.db4o.internal.*;
026:        import com.db4o.internal.marshall.*;
027:        import com.db4o.marshall.*;
028:        import com.db4o.reflect.*;
029:
030:        /**
031:         * @exclude
032:         */
033:        public abstract class PrimitiveHandler implements  IndexableTypeHandler,
034:                BuiltinTypeHandler {
035:
036:            protected final ObjectContainerBase _stream;
037:
038:            protected ReflectClass _classReflector;
039:
040:            private ReflectClass _primitiveClassReflector;
041:
042:            public PrimitiveHandler(ObjectContainerBase stream) {
043:                _stream = stream;
044:            }
045:
046:            private boolean i_compareToIsNull;
047:
048:            public Object coerce(ReflectClass claxx, Object obj) {
049:                return Handlers4.handlerCanHold(this , claxx) ? obj
050:                        : No4.INSTANCE;
051:            }
052:
053:            public abstract Object defaultValue();
054:
055:            public void deleteEmbedded(MarshallerFamily mf,
056:                    StatefulBuffer a_bytes) {
057:                a_bytes.incrementOffset(linkLength());
058:            }
059:
060:            public Object indexEntryToObject(Transaction trans,
061:                    Object indexEntry) {
062:                return indexEntry;
063:            }
064:
065:            protected abstract Class primitiveJavaClass();
066:
067:            public abstract Object primitiveNull();
068:
069:            /**
070:             * 
071:             * @param mf
072:             * @param buffer
073:             * @param redirect
074:             */
075:            public Object read(
076:
077:            /* FIXME: Work in progress here, this signature should not be used */
078:            MarshallerFamily mf,
079:
080:            StatefulBuffer buffer, boolean redirect) throws CorruptionException {
081:                return read1(buffer);
082:            }
083:
084:            abstract Object read1(Buffer reader) throws CorruptionException;
085:
086:            public Object readIndexEntry(Buffer buffer) {
087:                try {
088:                    return read1(buffer);
089:                } catch (CorruptionException e) {
090:                }
091:                return null;
092:            }
093:
094:            public Object readIndexEntry(MarshallerFamily mf,
095:                    StatefulBuffer a_writer) throws CorruptionException {
096:                return read(mf, a_writer, true);
097:            }
098:
099:            public ReflectClass classReflector() {
100:                ensureClassReflectorLoaded();
101:                return _classReflector;
102:            }
103:
104:            public ReflectClass primitiveClassReflector() {
105:                ensureClassReflectorLoaded();
106:                return _primitiveClassReflector;
107:            }
108:
109:            private void ensureClassReflectorLoaded() {
110:                if (_classReflector != null) {
111:                    return;
112:                }
113:                _classReflector = _stream.reflector().forClass(
114:                        defaultValue().getClass());
115:                Class clazz = primitiveJavaClass();
116:                if (clazz != null) {
117:                    _primitiveClassReflector = _stream.reflector().forClass(
118:                            clazz);
119:                }
120:            }
121:
122:            public abstract void write(Object a_object, Buffer a_bytes);
123:
124:            public void writeIndexEntry(Buffer a_writer, Object a_object) {
125:                if (a_object == null) {
126:                    a_object = primitiveNull();
127:                }
128:                write(a_object, a_writer);
129:            }
130:
131:            public Comparable4 prepareComparison(Object obj) {
132:                if (obj == null) {
133:                    i_compareToIsNull = true;
134:                    return Null.INSTANCE;
135:                }
136:                i_compareToIsNull = false;
137:                prepareComparison1(obj);
138:                return this ;
139:            }
140:
141:            abstract void prepareComparison1(Object obj);
142:
143:            public int compareTo(Object obj) {
144:                if (i_compareToIsNull) {
145:                    if (obj == null) {
146:                        return 0;
147:                    }
148:                    return 1;
149:                }
150:                if (obj == null) {
151:                    return -1;
152:                }
153:                if (isEqual1(obj)) {
154:                    return 0;
155:                }
156:                if (isGreater1(obj)) {
157:                    return 1;
158:                }
159:                return -1;
160:            }
161:
162:            abstract boolean isEqual1(Object obj);
163:
164:            abstract boolean isGreater1(Object obj);
165:
166:            abstract boolean isSmaller1(Object obj);
167:
168:            // redundant, only added to make Sun JDK 1.2's java happy :(
169:            public abstract int linkLength();
170:
171:            public final void defrag(MarshallerFamily mf, BufferPair readers,
172:                    boolean redirect) {
173:                int linkLength = linkLength();
174:                readers.incrementOffset(linkLength);
175:            }
176:
177:            public void defragIndexEntry(BufferPair readers) {
178:                try {
179:                    read1(readers.source());
180:                    read1(readers.target());
181:                } catch (CorruptionException exc) {
182:                    Exceptions4.virtualException();
183:                }
184:            }
185:
186:            protected PrimitiveMarshaller primitiveMarshaller() {
187:                return MarshallerFamily.current()._primitive;
188:            }
189:
190:            public void write(WriteContext context, Object obj) {
191:                throw new NotImplementedException();
192:            }
193:
194:            public Object read(ReadContext context) {
195:                throw new NotImplementedException();
196:            }
197:
198:            public Object nullRepresentationInUntypedArrays() {
199:                return primitiveNull();
200:            }
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.