001: /*
002: * Copyright (c) 1998 - 2005 Versant Corporation
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * Versant Corporation - initial API and implementation
010: */
011: package com.versant.core.jdo;
012:
013: import com.versant.core.common.State;
014:
015: import javax.jdo.PersistenceManager;
016: import javax.jdo.spi.PersistenceCapable;
017: import javax.jdo.spi.StateManager;
018:
019: import com.versant.core.common.BindingSupportImpl;
020: import com.versant.core.common.OID;
021:
022: /**
023: * State managed used to get at the fields of a detached instance.
024: */
025: public class VersantDetachStateManager implements VersantStateManager {
026:
027: DetachStateContainer dsc;
028:
029: public OID getOID() {
030: return null; //To change body of implemented methods use File | Settings | File Templates.
031: }
032:
033: public PersistenceCapable getPersistenceCapable() {
034: return null; //To change body of implemented methods use File | Settings | File Templates.
035: }
036:
037: public DetachStateContainer getDsc() {
038: return dsc;
039: }
040:
041: public void setDsc(DetachStateContainer dsc) {
042: this .dsc = dsc;
043: }
044:
045: public byte replacingFlags(PersistenceCapable persistenceCapable) {
046: return 0;
047: }
048:
049: public StateManager replacingStateManager(
050: PersistenceCapable persistenceCapable,
051: StateManager stateManager) {
052: return stateManager;
053: }
054:
055: public boolean isDirty(PersistenceCapable persistenceCapable) {
056: return false;
057: }
058:
059: public boolean isTransactional(PersistenceCapable persistenceCapable) {
060: return false;
061: }
062:
063: public boolean isPersistent(PersistenceCapable persistenceCapable) {
064: return false;
065: }
066:
067: public boolean isNew(PersistenceCapable persistenceCapable) {
068: return false;
069: }
070:
071: public boolean isDeleted(PersistenceCapable persistenceCapable) {
072: return false;
073: }
074:
075: public PersistenceManager getPersistenceManager(
076: PersistenceCapable persistenceCapable) {
077: return null;
078: }
079:
080: public void makeDirty(PersistenceCapable persistenceCapable,
081: String s) {
082: ((VersantDetachable) persistenceCapable).versantMakeDirty(s);
083: }
084:
085: public Object getObjectId(PersistenceCapable persistenceCapable) {
086: return null;
087: }
088:
089: public Object getTransactionalObjectId(
090: PersistenceCapable persistenceCapable) {
091: return null;
092: }
093:
094: public boolean isLoaded(PersistenceCapable persistenceCapable, int i) {
095: return ((VersantDetachable) persistenceCapable)
096: .versantIsLoaded(i);
097: }
098:
099: public void preSerialize(PersistenceCapable persistenceCapable) {
100:
101: }
102:
103: public boolean getBooleanField(
104: PersistenceCapable persistenceCapable, int i, boolean b) {
105: return b;
106: }
107:
108: public char getCharField(PersistenceCapable persistenceCapable,
109: int i, char c) {
110: return c;
111: }
112:
113: public byte getByteField(PersistenceCapable persistenceCapable,
114: int i, byte b) {
115: return b;
116: }
117:
118: public short getShortField(PersistenceCapable persistenceCapable,
119: int i, short i1) {
120: return i1;
121: }
122:
123: public int getIntField(PersistenceCapable persistenceCapable,
124: int i, int i1) {
125: return i1;
126: }
127:
128: public long getLongField(PersistenceCapable persistenceCapable,
129: int i, long l) {
130: return l;
131: }
132:
133: public float getFloatField(PersistenceCapable persistenceCapable,
134: int i, float v) {
135: return v;
136: }
137:
138: public double getDoubleField(PersistenceCapable persistenceCapable,
139: int i, double v) {
140: return v;
141: }
142:
143: public String getStringField(PersistenceCapable persistenceCapable,
144: int i, String s) {
145: return s;
146: }
147:
148: public Object getObjectField(PersistenceCapable persistenceCapable,
149: int i, Object o) {
150: return o;
151: }
152:
153: public void setBooleanField(PersistenceCapable persistenceCapable,
154: int i, boolean b, boolean b1) {
155:
156: }
157:
158: public void setCharField(PersistenceCapable persistenceCapable,
159: int i, char c, char c1) {
160: }
161:
162: public void setByteField(PersistenceCapable persistenceCapable,
163: int i, byte b, byte b1) {
164:
165: }
166:
167: public void setShortField(PersistenceCapable persistenceCapable,
168: int i, short i1, short i2) {
169:
170: }
171:
172: public void setIntField(PersistenceCapable persistenceCapable,
173: int i, int i1, int i2) {
174:
175: }
176:
177: public void setLongField(PersistenceCapable persistenceCapable,
178: int i, long l, long l1) {
179:
180: }
181:
182: public void setFloatField(PersistenceCapable persistenceCapable,
183: int i, float v, float v1) {
184:
185: }
186:
187: public void setDoubleField(PersistenceCapable persistenceCapable,
188: int i, double v, double v1) {
189:
190: }
191:
192: public void setStringField(PersistenceCapable persistenceCapable,
193: int i, String s, String s1) {
194:
195: }
196:
197: public void setObjectField(PersistenceCapable persistenceCapable,
198: int i, Object o, Object o1) {
199:
200: }
201:
202: public void providedBooleanField(
203: PersistenceCapable persistenceCapable, int i, boolean b) {
204:
205: }
206:
207: public void providedCharField(
208: PersistenceCapable persistenceCapable, int i, char c) {
209: }
210:
211: public void providedByteField(
212: PersistenceCapable persistenceCapable, int i, byte b) {
213:
214: }
215:
216: public void providedShortField(
217: PersistenceCapable persistenceCapable, int i, short i1) {
218:
219: }
220:
221: public void providedIntField(PersistenceCapable persistenceCapable,
222: int i, int i1) {
223:
224: }
225:
226: public void providedLongField(
227: PersistenceCapable persistenceCapable, int i, long l) {
228:
229: }
230:
231: public void providedFloatField(
232: PersistenceCapable persistenceCapable, int i, float v) {
233:
234: }
235:
236: public void providedDoubleField(
237: PersistenceCapable persistenceCapable, int i, double v) {
238:
239: }
240:
241: public void providedStringField(
242: PersistenceCapable persistenceCapable, int i, String s) {
243:
244: }
245:
246: public void providedObjectField(
247: PersistenceCapable persistenceCapable, int i, Object o) {
248:
249: }
250:
251: public boolean replacingBooleanField(final PersistenceCapable pc,
252: final int field) {
253: try {
254: State state = dsc.getState(pc);
255: boolean temp = state.getBooleanFieldAbs(field);
256: ((VersantDetachable) pc).versantSetLoaded(field);
257: return temp;
258: } catch (Exception e) {
259: handleException(e);
260: }
261: return false;
262: }
263:
264: public char replacingCharField(final PersistenceCapable pc,
265: final int field) {
266: try {
267: State state = dsc.getState(pc);
268: char temp = state.getCharFieldAbs(field);
269: ((VersantDetachable) pc).versantSetLoaded(field);
270: return temp;
271: } catch (Exception e) {
272: handleException(e);
273: }
274: return 0;
275: }
276:
277: public byte replacingByteField(final PersistenceCapable pc,
278: final int field) {
279: try {
280: State state = dsc.getState(pc);
281: byte temp = state.getByteFieldAbs(field);
282: ((VersantDetachable) pc).versantSetLoaded(field);
283: return temp;
284: } catch (Exception e) {
285: handleException(e);
286: }
287: return 0;
288: }
289:
290: public short replacingShortField(final PersistenceCapable pc,
291: final int field) {
292: try {
293: State state = dsc.getState(pc);
294: short temp = state.getShortFieldAbs(field);
295: ((VersantDetachable) pc).versantSetLoaded(field);
296: return temp;
297: } catch (Exception e) {
298: handleException(e);
299: }
300: return 0;
301: }
302:
303: public int replacingIntField(final PersistenceCapable pc,
304: final int field) {
305: try {
306: State state = dsc.getState(pc);
307: int temp = state.getIntFieldAbs(field);
308: ((VersantDetachable) pc).versantSetLoaded(field);
309: return temp;
310: } catch (Exception e) {
311: ((VersantDetachable) pc).versantSetLoaded(field);
312: handleException(e);
313: }
314: return 0;
315: }
316:
317: public float replacingFloatField(final PersistenceCapable pc,
318: final int field) {
319: try {
320: State state = dsc.getState(pc);
321: float temp = state.getFloatFieldAbs(field);
322: ((VersantDetachable) pc).versantSetLoaded(field);
323: return temp;
324: } catch (Exception e) {
325: handleException(e);
326: }
327: return 0;
328: }
329:
330: public double replacingDoubleField(final PersistenceCapable pc,
331: final int field) {
332: try {
333: State state = dsc.getState(pc);
334: double temp = state.getDoubleFieldAbs(field);
335: ((VersantDetachable) pc).versantSetLoaded(field);
336: return temp;
337: } catch (Exception e) {
338: handleException(e);
339: }
340: return 0;
341: }
342:
343: public long replacingLongField(final PersistenceCapable pc,
344: final int field) {
345: try {
346: State state = dsc.getState(pc);
347: long temp = state.getLongFieldAbs(field);
348: ((VersantDetachable) pc).versantSetLoaded(field);
349: return temp;
350: } catch (Exception e) {
351: handleException(e);
352: }
353: return 0;
354: }
355:
356: public String replacingStringField(final PersistenceCapable pc,
357: final int field) {
358: try {
359: State state = dsc.getState(pc);
360: String temp = state.getStringFieldAbs(field);
361: ((VersantDetachable) pc).versantSetLoaded(field);
362: return temp;
363: } catch (Exception e) {
364: handleException(e);
365: }
366: return null;
367: }
368:
369: public Object replacingObjectField(final PersistenceCapable pc,
370: final int field) {
371: try {
372: VersantDetachable detachable = ((VersantDetachable) pc);
373: Object temp = dsc.getObjectField(detachable, field);
374: detachable.versantSetLoaded(field);
375: return temp;
376: } catch (Exception e) {
377: handleException(e);
378: }
379: return null;
380: }
381:
382: private final void handleException(Exception x) {
383: if (BindingSupportImpl.getInstance().isOwnException(x)) {
384: throw (RuntimeException) x;
385: } else {
386: throw BindingSupportImpl.getInstance().internal(
387: x.getMessage(), x);
388: }
389: }
390:
391: public void makeDirty(PersistenceCapable pc, int managedFieldNo) {
392: ((VersantDetachable) pc).versantMakeDirty(managedFieldNo);
393: }
394:
395: public void fillNewAppPKField(int fieldNo) {
396: }
397:
398: }
|