001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.test.types;
022:
023: import com.db4o.*;
024: import com.db4o.test.*;
025:
026: /**
027: * note the special configuration for this class
028: * in Regression.openContainer()
029: */
030: public class DeepUpdate implements RTestable {
031: public ObjectSimplePublic d1;
032: public DeepHelper d2;
033: public DeepHelper[] d3;
034:
035: public DeepUpdate() {
036: }
037:
038: public void compare(ObjectContainer con, Object obj, int ver) {
039: Compare.compare(con, set(newInstance(), ver), obj, "", null);
040: }
041:
042: public boolean equals(Object obj) {
043: if (obj == null) {
044: return false;
045: }
046: if (!(obj instanceof DeepUpdate)) {
047: return false;
048: }
049: DeepUpdate with = (DeepUpdate) obj;
050: if (with.d1 != null && d1 != null) {
051: if (d1.equals(with.d1)) {
052: if (with.d2 != null && d2 != null) {
053: if (d2.d1.equals(with.d2.d1)) {
054: if (with.d3 != null && d3 != null) {
055: if (with.d3.length == d3.length) {
056: if (with.d3[0].equals(d3[0])) {
057: if (with.d3[1].equals(d3[1])) {
058: return true;
059: }
060: }
061: }
062: }
063: }
064: }
065: }
066: }
067: return false;
068: }
069:
070: public Object newInstance() {
071: return new DeepUpdate();
072: }
073:
074: public Object set(Object obj, int ver) {
075: ((DeepUpdate) obj).set(ver);
076: return obj;
077: }
078:
079: public void set(int ver) {
080: d1 = new ObjectSimplePublic();
081: d2 = new DeepHelper();
082: d3 = new DeepHelper[2];
083: d3[0] = new DeepHelper();
084: d3[1] = new DeepHelper();
085: if (ver == 1) {
086: d1.name = "OneONEOneONEOneONEOneONEOneONEOneONE";
087: } else {
088: d1.name = "TwoTWOTwoTWOTwoTWOTwoTWOTwoTWO";
089: }
090: d2.set(ver);
091: d3[0].set(ver);
092: d3[1].set(ver);
093: }
094:
095: public boolean jdk2() {
096: return false;
097: }
098:
099: public boolean ver3() {
100: return false;
101: }
102: }
|