KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > YapClassAny


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.inside.marshall.*;
24 import com.db4o.reflect.*;
25
26
27 /**
28  * Undefined YapClass used for members of type Object.
29  */

30 final class YapClassAny extends YapClass {
31     
32     public YapClassAny(YapStream stream){
33         super(stream, stream.i_handlers.ICLASS_OBJECT);
34     }
35
36     public boolean canHold(ReflectClass claxx) {
37         return true;
38     }
39
40     public void cascadeActivation(
41         Transaction a_trans,
42         Object JavaDoc a_object,
43         int a_depth,
44         boolean a_activate) {
45         YapClass yc = forObject(a_trans, a_object, false);
46         if (yc != null) {
47             yc.cascadeActivation(a_trans, a_object, a_depth, a_activate);
48         }
49     }
50     
51     public void deleteEmbedded(MarshallerFamily mf, YapWriter reader) {
52         mf._untyped.deleteEmbedded(reader);
53     }
54     
55     public int getID() {
56         return 11;
57     }
58
59     public boolean hasField(YapStream a_stream, String JavaDoc a_path) {
60         return a_stream.classCollection().fieldExists(a_path);
61     }
62     
63     public boolean hasIndex() {
64         return false;
65     }
66     
67     public boolean hasFixedLength(){
68         return false;
69     }
70
71     public boolean holdsAnyClass() {
72         return true;
73     }
74     
75     public int isSecondClass(){
76         return YapConst.UNKNOWN;
77     }
78     
79     boolean isStrongTyped(){
80         return false;
81     }
82     
83     public void calculateLengths(Transaction trans, ObjectHeaderAttributes header, boolean topLevel, Object JavaDoc obj, boolean withIndirection) {
84         if(topLevel){
85             header.addBaseLength(YapConst.INT_LENGTH);
86         }else{
87             header.addPayLoadLength(YapConst.INT_LENGTH); // single relink
88
}
89         YapClass yc = forObject(trans, obj, true);
90         if( yc == null){
91             return;
92         }
93         header.addPayLoadLength(YapConst.INT_LENGTH); // type information int
94
yc.calculateLengths(trans, header, false, obj, false);
95     }
96     
97     public Object JavaDoc read(MarshallerFamily mf, YapWriter a_bytes, boolean redirect) throws CorruptionException{
98         if(mf._untyped.useNormalClassRead()){
99             return super.read(mf, a_bytes, redirect);
100         }
101         return mf._untyped.read(a_bytes);
102     }
103
104     public TypeHandler4 readArrayHandler(Transaction a_trans, MarshallerFamily mf, YapReader[] a_bytes) {
105         return mf._untyped.readArrayHandler(a_trans, a_bytes);
106     }
107     
108     public Object JavaDoc readQuery(Transaction trans, MarshallerFamily mf, boolean withRedirection, YapReader reader, boolean toArray) throws CorruptionException{
109         if(mf._untyped.useNormalClassRead()){
110             return super.readQuery(trans, mf, withRedirection, reader, toArray);
111         }
112         return mf._untyped.readQuery(trans, reader, toArray);
113     }
114     
115     public QCandidate readSubCandidate(MarshallerFamily mf, YapReader reader, QCandidates candidates, boolean withIndirection) {
116         if(mf._untyped.useNormalClassRead()){
117             return super.readSubCandidate(mf, reader, candidates, withIndirection);
118         }
119         return mf._untyped.readSubCandidate(reader, candidates, withIndirection);
120     }
121     
122     public boolean supportsIndex() {
123         return false;
124     }
125     
126     public Object JavaDoc writeNew(MarshallerFamily mf, Object JavaDoc obj, boolean topLevel, YapWriter writer, boolean withIndirection, boolean restoreLinkeOffset) {
127         return mf._untyped.writeNew(obj, restoreLinkeOffset, writer);
128     }
129
130     public void defrag(MarshallerFamily mf, ReaderPair readers, boolean redirect) {
131         if(mf._untyped.useNormalClassRead()){
132             super.defrag(mf,readers, redirect);
133         }
134         mf._untyped.defrag(readers);
135     }
136 }
137
Popular Tags