KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > VersantDetachStateManager


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo;
13
14 import com.versant.core.common.State;
15
16 import javax.jdo.PersistenceManager;
17 import javax.jdo.spi.PersistenceCapable;
18 import javax.jdo.spi.StateManager;
19
20 import com.versant.core.common.BindingSupportImpl;
21 import com.versant.core.common.OID;
22
23 /**
24  * State managed used to get at the fields of a detached instance.
25  */

26 public class VersantDetachStateManager implements VersantStateManager {
27
28     DetachStateContainer dsc;
29
30     public OID getOID() {
31         return null; //To change body of implemented methods use File | Settings | File Templates.
32
}
33
34     public PersistenceCapable getPersistenceCapable() {
35         return null; //To change body of implemented methods use File | Settings | File Templates.
36
}
37
38     public DetachStateContainer getDsc() {
39         return dsc;
40     }
41
42     public void setDsc(DetachStateContainer dsc) {
43         this.dsc = dsc;
44     }
45
46     public byte replacingFlags(PersistenceCapable persistenceCapable) {
47         return 0;
48     }
49
50     public StateManager replacingStateManager(
51             PersistenceCapable persistenceCapable, StateManager stateManager) {
52         return stateManager;
53     }
54
55     public boolean isDirty(PersistenceCapable persistenceCapable) {
56         return false;
57     }
58
59     public boolean isTransactional(PersistenceCapable persistenceCapable) {
60         return false;
61     }
62
63     public boolean isPersistent(PersistenceCapable persistenceCapable) {
64         return false;
65     }
66
67     public boolean isNew(PersistenceCapable persistenceCapable) {
68         return false;
69     }
70
71     public boolean isDeleted(PersistenceCapable persistenceCapable) {
72         return false;
73     }
74
75     public PersistenceManager getPersistenceManager(
76             PersistenceCapable persistenceCapable) {
77         return null;
78     }
79
80     public void makeDirty(PersistenceCapable persistenceCapable, String JavaDoc s) {
81         ((VersantDetachable)persistenceCapable).versantMakeDirty(s);
82     }
83
84     public Object JavaDoc getObjectId(PersistenceCapable persistenceCapable) {
85         return null;
86     }
87
88     public Object JavaDoc getTransactionalObjectId(
89             PersistenceCapable persistenceCapable) {
90         return null;
91     }
92
93     public boolean isLoaded(PersistenceCapable persistenceCapable, int i) {
94         return ((VersantDetachable)persistenceCapable).versantIsLoaded(i);
95     }
96
97     public void preSerialize(PersistenceCapable persistenceCapable) {
98
99     }
100
101     public boolean getBooleanField(PersistenceCapable persistenceCapable,
102             int i, boolean b) {
103         return b;
104     }
105
106     public char getCharField(PersistenceCapable persistenceCapable, int i,
107             char c) {
108         return c;
109     }
110
111     public byte getByteField(PersistenceCapable persistenceCapable, int i,
112             byte b) {
113         return b;
114     }
115
116     public short getShortField(PersistenceCapable persistenceCapable, int i,
117             short i1) {
118         return i1;
119     }
120
121     public int getIntField(PersistenceCapable persistenceCapable, int i,
122             int i1) {
123         return i1;
124     }
125
126     public long getLongField(PersistenceCapable persistenceCapable, int i,
127             long l) {
128         return l;
129     }
130
131     public float getFloatField(PersistenceCapable persistenceCapable, int i,
132             float v) {
133         return v;
134     }
135
136     public double getDoubleField(PersistenceCapable persistenceCapable, int i,
137             double v) {
138         return v;
139     }
140
141     public String JavaDoc getStringField(PersistenceCapable persistenceCapable, int i,
142             String JavaDoc s) {
143         return s;
144     }
145
146     public Object JavaDoc getObjectField(PersistenceCapable persistenceCapable, int i,
147             Object JavaDoc o) {
148         return o;
149     }
150
151     public void setBooleanField(PersistenceCapable persistenceCapable, int i,
152             boolean b, boolean b1) {
153
154     }
155
156     public void setCharField(PersistenceCapable persistenceCapable, int i,
157             char c, char c1) {
158     }
159
160     public void setByteField(PersistenceCapable persistenceCapable, int i,
161             byte b, byte b1) {
162
163     }
164
165     public void setShortField(PersistenceCapable persistenceCapable, int i,
166             short i1, short i2) {
167
168     }
169
170     public void setIntField(PersistenceCapable persistenceCapable, int i,
171             int i1, int i2) {
172
173     }
174
175     public void setLongField(PersistenceCapable persistenceCapable, int i,
176             long l, long l1) {
177
178     }
179
180     public void setFloatField(PersistenceCapable persistenceCapable, int i,
181             float v, float v1) {
182
183     }
184
185     public void setDoubleField(PersistenceCapable persistenceCapable, int i,
186             double v, double v1) {
187
188     }
189
190     public void setStringField(PersistenceCapable persistenceCapable, int i,
191             String JavaDoc s, String JavaDoc s1) {
192
193     }
194
195     public void setObjectField(PersistenceCapable persistenceCapable, int i,
196             Object JavaDoc o, Object JavaDoc o1) {
197
198     }
199
200     public void providedBooleanField(PersistenceCapable persistenceCapable,
201             int i, boolean b) {
202
203     }
204
205     public void providedCharField(PersistenceCapable persistenceCapable, int i,
206             char c) {
207     }
208
209     public void providedByteField(PersistenceCapable persistenceCapable, int i,
210             byte b) {
211
212     }
213
214     public void providedShortField(PersistenceCapable persistenceCapable,
215             int i, short i1) {
216
217     }
218
219     public void providedIntField(PersistenceCapable persistenceCapable, int i,
220             int i1) {
221
222     }
223
224     public void providedLongField(PersistenceCapable persistenceCapable, int i,
225             long l) {
226
227     }
228
229     public void providedFloatField(PersistenceCapable persistenceCapable,
230             int i, float v) {
231
232     }
233
234     public void providedDoubleField(PersistenceCapable persistenceCapable,
235             int i, double v) {
236
237     }
238
239     public void providedStringField(PersistenceCapable persistenceCapable,
240             int i, String JavaDoc s) {
241
242     }
243
244     public void providedObjectField(PersistenceCapable persistenceCapable,
245             int i, Object JavaDoc o) {
246
247     }
248
249     public boolean replacingBooleanField(final PersistenceCapable pc,
250             final int field) {
251         try {
252             State state = dsc.getState(pc);
253             boolean temp = state.getBooleanFieldAbs(field);
254             ((VersantDetachable)pc).versantSetLoaded(field);
255             return temp;
256         } catch (Exception JavaDoc e) {
257             handleException(e);
258         }
259         return false;
260     }
261
262     public char replacingCharField(final PersistenceCapable pc,
263             final int field) {
264         try {
265             State state = dsc.getState(pc);
266             char temp = state.getCharFieldAbs(field);
267             ((VersantDetachable)pc).versantSetLoaded(field);
268             return temp;
269         } catch (Exception JavaDoc e) {
270             handleException(e);
271         }
272         return 0;
273     }
274
275     public byte replacingByteField(final PersistenceCapable pc,
276             final int field) {
277         try {
278             State state = dsc.getState(pc);
279             byte temp = state.getByteFieldAbs(field);
280             ((VersantDetachable)pc).versantSetLoaded(field);
281             return temp;
282         } catch (Exception JavaDoc e) {
283             handleException(e);
284         }
285         return 0;
286     }
287
288     public short replacingShortField(final PersistenceCapable pc,
289             final int field) {
290         try {
291             State state = dsc.getState(pc);
292             short temp = state.getShortFieldAbs(field);
293             ((VersantDetachable)pc).versantSetLoaded(field);
294             return temp;
295         } catch (Exception JavaDoc e) {
296             handleException(e);
297         }
298         return 0;
299     }
300
301     public int replacingIntField(final PersistenceCapable pc,
302             final int field) {
303         try {
304             State state = dsc.getState(pc);
305             int temp = state.getIntFieldAbs(field);
306             ((VersantDetachable)pc).versantSetLoaded(field);
307             return temp;
308         } catch (Exception JavaDoc e) {
309             ((VersantDetachable)pc).versantSetLoaded(field);
310             handleException(e);
311         }
312         return 0;
313     }
314
315     public float replacingFloatField(final PersistenceCapable pc,
316             final int field) {
317         try {
318             State state = dsc.getState(pc);
319             float temp = state.getFloatFieldAbs(field);
320             ((VersantDetachable)pc).versantSetLoaded(field);
321             return temp;
322         } catch (Exception JavaDoc e) {
323             handleException(e);
324         }
325         return 0;
326     }
327
328     public double replacingDoubleField(final PersistenceCapable pc,
329             final int field) {
330         try {
331             State state = dsc.getState(pc);
332             double temp = state.getDoubleFieldAbs(field);
333             ((VersantDetachable)pc).versantSetLoaded(field);
334             return temp;
335         } catch (Exception JavaDoc e) {
336             handleException(e);
337         }
338         return 0;
339     }
340
341     public long replacingLongField(final PersistenceCapable pc,
342             final int field) {
343         try {
344             State state = dsc.getState(pc);
345             long temp = state.getLongFieldAbs(field);
346             ((VersantDetachable)pc).versantSetLoaded(field);
347             return temp;
348         } catch (Exception JavaDoc e) {
349             handleException(e);
350         }
351         return 0;
352     }
353
354     public String JavaDoc replacingStringField(final PersistenceCapable pc,
355             final int field) {
356         try {
357             State state = dsc.getState(pc);
358             String JavaDoc temp = state.getStringFieldAbs(field);
359             ((VersantDetachable)pc).versantSetLoaded(field);
360             return temp;
361         } catch (Exception JavaDoc e) {
362             handleException(e);
363         }
364         return null;
365     }
366
367     public Object JavaDoc replacingObjectField(final PersistenceCapable pc,
368             final int field) {
369         try {
370             VersantDetachable detachable = ((VersantDetachable)pc);
371             Object JavaDoc temp = dsc.getObjectField(detachable, field);
372             detachable.versantSetLoaded(field);
373             return temp;
374         } catch (Exception JavaDoc e) {
375             handleException(e);
376         }
377         return null;
378     }
379
380     private final void handleException(Exception JavaDoc x) {
381         if( BindingSupportImpl.getInstance().isOwnException(x) ) {
382             throw (RuntimeException JavaDoc)x;
383         } else {
384             throw BindingSupportImpl.getInstance().internal(x.getMessage(), x);
385         }
386     }
387
388     public void makeDirty(PersistenceCapable pc,
389             int managedFieldNo) {
390         ((VersantDetachable)pc).versantMakeDirty(managedFieldNo);
391     }
392
393     public void fillNewAppPKField(int fieldNo) {
394     }
395
396
397 }
398
Popular Tags