KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > YapIndependantType


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o;
22
23 import com.db4o.foundation.*;
24 import com.db4o.inside.marshall.*;
25 import com.db4o.reflect.*;
26
27
28 /**
29  * Common base class for YapString and YapArray:
30  * There is one indirection in the database file to this.
31  *
32  * @exclude
33  */

34 public abstract class YapIndependantType implements TypeHandler4 {
35     final YapStream _stream;
36     
37     public YapIndependantType(YapStream stream) {
38         _stream = stream;
39     }
40     
41     
42     public Object JavaDoc coerce(ReflectClass claxx, Object JavaDoc obj) {
43         return canHold(claxx) ? obj : No4.INSTANCE;
44     }
45     
46     public final void copyValue(Object JavaDoc a_from, Object JavaDoc a_to){
47         // do nothing
48
}
49     
50     public abstract void deleteEmbedded(MarshallerFamily mf, YapWriter a_bytes);
51     
52     public boolean hasFixedLength(){
53         return false;
54     }
55     
56     public final int linkLength(){
57         
58         // TODO: Now that array and string are embedded into their parent
59
// object from marshaller family 1 on, the length part is no
60
// longer needed. To stay compatible with marshaller family 0
61
// it was considered a bad idea to change this value.
62

63         return YapConst.INT_LENGTH + YapConst.ID_LENGTH;
64     }
65     
66     public final ReflectClass primitiveClassReflector(){
67         return null;
68     }
69     
70     public boolean readArray(Object JavaDoc array, YapReader reader) {
71         return false;
72     }
73     
74     public Object JavaDoc readIndexEntry(MarshallerFamily mf, YapWriter a_writer) throws CorruptionException{
75         return read(mf, a_writer, true);
76     }
77     
78     public boolean writeArray(Object JavaDoc array, YapReader reader) {
79         return false;
80     }
81     
82     // redundant, only added to make Sun JDK 1.2's java happy :(
83
public abstract boolean isGreater(Object JavaDoc obj);
84     public abstract YapComparable prepareComparison(Object JavaDoc obj);
85     public abstract int compareTo(Object JavaDoc obj);
86     public abstract boolean isEqual(Object JavaDoc obj);
87     public abstract boolean isSmaller(Object JavaDoc obj);
88     
89     public abstract Object JavaDoc comparableObject(Transaction trans, Object JavaDoc indexEntry);
90     public abstract Object JavaDoc readIndexEntry(YapReader a_reader);
91     public abstract void writeIndexEntry(YapReader a_writer, Object JavaDoc a_object);
92     
93     public abstract void defrag(MarshallerFamily mf, ReaderPair readers, boolean redirect);
94 }
95
Popular Tags