KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > types > DeepUpdate


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.types;
22
23 import com.db4o.*;
24 import com.db4o.test.*;
25
26 /**
27  * note the special configuration for this class
28  * in Regression.openContainer()
29  */

30 public class DeepUpdate implements RTestable
31 {
32     public ObjectSimplePublic d1;
33     public DeepHelper d2;
34     public DeepHelper[] d3;
35
36
37     public DeepUpdate(){
38     }
39
40     public void compare(ObjectContainer con, Object JavaDoc obj, int ver){
41         Compare.compare(con, set(newInstance(), ver), obj,"", null);
42     }
43
44     public boolean equals(Object JavaDoc obj){
45         if(obj == null){
46             return false;
47         }
48         if(! (obj instanceof DeepUpdate) ){
49             return false;
50         }
51         DeepUpdate with = (DeepUpdate) obj;
52         if(with.d1 != null && d1 != null){
53             if(d1.equals(with.d1)){
54                 if(with.d2 != null && d2 != null){
55                     if(d2.d1.equals(with.d2.d1)){
56                         if(with.d3 != null && d3 != null){
57                             if(with.d3.length == d3.length){
58                                 if(with.d3[0].equals(d3[0])){
59                                     if(with.d3[1].equals(d3[1])){
60                                         return true;
61                                     }
62                                 }
63                             }
64                         }
65                     }
66                 }
67             }
68         }
69         return false;
70     }
71
72     public Object JavaDoc newInstance(){
73         return new DeepUpdate();
74     }
75
76
77     public Object JavaDoc set(Object JavaDoc obj, int ver){
78         ((DeepUpdate)obj).set(ver);
79         return obj;
80     }
81
82     public void set(int ver){
83         d1 = new ObjectSimplePublic();
84         d2 = new DeepHelper();
85         d3 = new DeepHelper[2];
86         d3[0] = new DeepHelper();
87         d3[1] = new DeepHelper();
88         if(ver == 1){
89             d1.name = "OneONEOneONEOneONEOneONEOneONEOneONE";
90         }else{
91             d1.name = "TwoTWOTwoTWOTwoTWOTwoTWOTwoTWO";
92         }
93         d2.set(ver);
94         d3[0].set(ver);
95         d3[1].set(ver);
96     }
97
98     public boolean jdk2(){
99         return false;
100     }
101     
102     public boolean ver3(){
103         return false;
104     }
105 }
106
Popular Tags