01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: ElementWidget.java,v 1.3 2002/10/17 21:00:59 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.test;
12:
13: import javax.jdo.JDOHelper;
14:
15: public class ElementWidget extends Widget {
16: private SetWidget owner;
17:
18: /**
19: * Default constructor required since this is a PersistenceCapable class.
20: */
21: protected ElementWidget() {
22: }
23:
24: public ElementWidget(SetWidget owner) {
25: super ();
26:
27: this .owner = owner;
28: }
29:
30: public SetWidget getOwner() {
31: return owner;
32: }
33:
34: public void setOwner(SetWidget owner) {
35: this .owner = owner;
36: }
37:
38: /**
39: * Indicates whether some other object is "equal to" this one. By comparing
40: * against an original copy of the object, <code>compareTo()</code> can be
41: * used to verify that the object has been written to a database and read
42: * back correctly.
43: *
44: * @param obj the reference object with which to compare
45: *
46: * @return <code>true</code> if this object is equal to the obj argument;
47: * <code>false</code> otherwise.
48: */
49:
50: public boolean compareTo(Object obj) {
51: if (this == obj)
52: return true;
53:
54: if (!(obj instanceof ElementWidget) || !super .compareTo(obj))
55: return false;
56: else
57: return true;
58: }
59:
60: /**
61: * Returns a string representation for this object. All of the field
62: * values are included in the string for debugging purposes.
63: *
64: * @return a string representation for this object.
65: */
66:
67: public String toString() {
68: StringBuffer s = new StringBuffer(super .toString());
69:
70: s.append(" owner = ").append(JDOHelper.getObjectId(owner));
71: s.append('\n');
72:
73: return s.toString();
74: }
75: }
|