01: package com.db4o.f1.chapter6;
02:
03: import com.db4o.*;
04: import com.db4o.config.*;
05:
06: public class NotStorableTranslator implements ObjectConstructor {
07: public Object onStore(ObjectContainer container,
08: Object applicationObject) {
09: System.out.println("onStore for " + applicationObject);
10: NotStorable notStorable = (NotStorable) applicationObject;
11: return new Object[] { new Integer(notStorable.getId()),
12: notStorable.getName() };
13: }
14:
15: public Object onInstantiate(ObjectContainer container,
16: Object storedObject) {
17: System.out.println("onInstantiate for " + storedObject);
18: Object[] raw = (Object[]) storedObject;
19: int id = ((Integer) raw[0]).intValue();
20: String name = (String) raw[1];
21: return new NotStorable(id, name);
22: }
23:
24: public void onActivate(ObjectContainer container,
25: Object applicationObject, Object storedObject) {
26: System.out.println("onActivate for " + applicationObject
27: + " / " + storedObject);
28: }
29:
30: public Class storedClass() {
31: return Object[].class;
32: }
33: }
|