KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > test > ValueWidget


1 /*
2  * Copyright 2004 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: ValueWidget.java,v 1.1 2004/01/25 20:44:34 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.test;
12
13 import javax.jdo.JDOHelper;
14
15
16 public class ValueWidget extends Widget
17 {
18     private MapWidget owner = null;
19     private Integer JavaDoc key = null;
20
21
22     public ValueWidget()
23     {
24     }
25
26
27     public MapWidget getOwner()
28     {
29         return owner;
30     }
31
32
33     public Integer JavaDoc getKey()
34     {
35         return key;
36     }
37
38
39     public void setOwner(MapWidget owner)
40     {
41         this.owner = owner;
42     }
43
44
45     public void setKey(Integer JavaDoc key)
46     {
47         this.key = key;
48     }
49
50
51     /**
52      * Indicates whether some other object is "equal to" this one. By comparing
53      * against an original copy of the object, <code>compareTo()</code> can be
54      * used to verify that the object has been written to a database and read
55      * back correctly.
56      *
57      * @param obj the reference object with which to compare
58      *
59      * @return <code>true</code> if this object is equal to the obj argument;
60      * <code>false</code> otherwise.
61      */

62
63     public boolean compareTo(Object JavaDoc obj)
64     {
65         if (this == obj)
66             return true;
67
68         if (!(obj instanceof ValueWidget) || !super.compareTo(obj))
69             return false;
70
71         ValueWidget w = (ValueWidget)obj;
72
73         return key == null ? (w.key == null) : key.equals(w.key);
74     }
75
76
77     /**
78      * Returns a string representation for this object. All of the field
79      * values are included in the string for debugging purposes.
80      *
81      * @return a string representation for this object.
82      */

83
84     public String JavaDoc toString()
85     {
86         StringBuffer JavaDoc s = new StringBuffer JavaDoc(super.toString());
87
88         s.append(" owner = ").append(JDOHelper.getObjectId(owner));
89         s.append('\n');
90         s.append(" key = ").append(key);
91         s.append('\n');
92
93         return s.toString();
94     }
95 }
96
Popular Tags