01: /*
02: * Copyright 2004 (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: ValueWidget.java,v 1.1 2004/01/25 20:44:34 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.test;
12:
13: import javax.jdo.JDOHelper;
14:
15: public class ValueWidget extends Widget {
16: private MapWidget owner = null;
17: private Integer key = null;
18:
19: public ValueWidget() {
20: }
21:
22: public MapWidget getOwner() {
23: return owner;
24: }
25:
26: public Integer getKey() {
27: return key;
28: }
29:
30: public void setOwner(MapWidget owner) {
31: this .owner = owner;
32: }
33:
34: public void setKey(Integer key) {
35: this .key = key;
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 ValueWidget) || !super .compareTo(obj))
55: return false;
56:
57: ValueWidget w = (ValueWidget) obj;
58:
59: return key == null ? (w.key == null) : key.equals(w.key);
60: }
61:
62: /**
63: * Returns a string representation for this object. All of the field
64: * values are included in the string for debugging purposes.
65: *
66: * @return a string representation for this object.
67: */
68:
69: public String toString() {
70: StringBuffer s = new StringBuffer(super .toString());
71:
72: s.append(" owner = ").append(JDOHelper.getObjectId(owner));
73: s.append('\n');
74: s.append(" key = ").append(key);
75: s.append('\n');
76:
77: return s.toString();
78: }
79: }
|