KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > UpdateDepth


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.test;
22
23 import java.io.*;
24
25 import com.db4o.*;
26 import com.db4o.config.*;
27 import com.db4o.tools.*;
28
29 public class UpdateDepth {
30     
31     String JavaDoc name;
32     UpdateDepth child;
33     UpdateDepth[] childArray;
34     
35
36     public static void main(String JavaDoc[] args) {
37         Configuration conf = Db4o.configure();
38         
39         
40         // STILL A MANUAL TEST
41

42         
43         // Play with the following two parameters and watch the output.
44
// conf.updateDepth(0);
45
conf.objectClass("com.db4o.test.UpdateDepth").updateDepth(1);
46
47
48         new File("updateDepth.yap").delete();
49         ObjectContainer con = Db4o.openFile("updateDepth.yap");
50         ObjectSet set = null;
51         UpdateDepth ud = new UpdateDepth();
52         ud.name = "Level 0";
53         ud.child = new UpdateDepth();
54         ud.child.name = "Level 1";
55         ud.child.child = new UpdateDepth();
56         ud.child.child.name = "Level 2";
57         ud.childArray = new UpdateDepth[] {new UpdateDepth()};
58         ud.childArray[0].name = "Array Level 1";
59         ud.child.childArray = new UpdateDepth[] {new UpdateDepth()};
60         ud.child.childArray[0].name = "Array Level 2";
61         con.set(ud);
62         
63         /*
64         set = con.get(null);
65         while(set.hasNext()){
66           Logger.log(con, set.next());
67         }
68         */

69         
70         
71         ud.name = "Update Level 0";
72         ud.child.name = "Update Level 1";
73         ud.child.child.name = "Update Level 2";
74         ud.childArray[0].name = "Update Array Level 1";
75         ud.child.childArray[0].name = "Update Array Level 2";
76         con.set(ud);
77         con.close();
78         con = Db4o.openFile("updateDepth.yap");
79         set = con.get(null);
80         while(set.hasNext()){
81             Logger.log(con, set.next());
82         }
83         con.close();
84     }
85 }
86
Popular Tags