KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002 (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: ElementWidget.java,v 1.3 2002/10/17 21:00:59 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.test;
12
13 import javax.jdo.JDOHelper;
14
15
16 public class ElementWidget extends Widget
17 {
18     private SetWidget owner;
19
20
21     /**
22      * Default constructor required since this is a PersistenceCapable class.
23      */

24     protected ElementWidget() {}
25
26     public ElementWidget(SetWidget owner)
27     {
28         super();
29
30         this.owner = owner;
31     }
32
33
34     public SetWidget getOwner()
35     {
36         return owner;
37     }
38
39
40     public void setOwner(SetWidget owner)
41     {
42         this.owner = owner;
43     }
44
45
46     /**
47      * Indicates whether some other object is "equal to" this one. By comparing
48      * against an original copy of the object, <code>compareTo()</code> can be
49      * used to verify that the object has been written to a database and read
50      * back correctly.
51      *
52      * @param obj the reference object with which to compare
53      *
54      * @return <code>true</code> if this object is equal to the obj argument;
55      * <code>false</code> otherwise.
56      */

57
58     public boolean compareTo(Object JavaDoc obj)
59     {
60         if (this == obj)
61             return true;
62
63         if (!(obj instanceof ElementWidget) || !super.compareTo(obj))
64             return false;
65         else
66             return true;
67     }
68
69
70     /**
71      * Returns a string representation for this object. All of the field
72      * values are included in the string for debugging purposes.
73      *
74      * @return a string representation for this object.
75      */

76
77     public String JavaDoc toString()
78     {
79         StringBuffer JavaDoc s = new StringBuffer JavaDoc(super.toString());
80
81         s.append(" owner = ").append(JDOHelper.getObjectId(owner));
82         s.append('\n');
83
84         return s.toString();
85     }
86 }
87
Popular Tags