KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > test > naming > bar > Collision


1 /*
2  * Copyright 2003 (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: Collision.java,v 1.1 2003/08/03 01:58:17 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.test.naming.bar;
12
13 import com.triactive.jdo.test.TestObject;
14 import javax.jdo.JDOHelper;
15
16
17 /**
18  * A test object whose class name is intended to collide with the same name in
19  * another package.
20  *
21  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
22  * @version $Revision: 1.1 $
23  */

24
25 public class Collision extends TestObject
26 {
27     private int dummy;
28
29
30     public Collision()
31     {
32         super();
33     }
34
35
36     public void fillRandom()
37     {
38         dummy = r.nextInt();
39     }
40
41
42     public boolean compareTo(Object JavaDoc obj)
43     {
44         if (obj == this)
45             return true;
46
47         if (!(obj instanceof Collision))
48             return false;
49
50         Collision c = (Collision)obj;
51
52         return dummy == c.dummy;
53     }
54
55
56     public String JavaDoc toString()
57     {
58         StringBuffer JavaDoc s = new StringBuffer JavaDoc(getClass().getName() + ":");
59
60         s.append(" JVM id = ").append(System.identityHashCode(this));
61         s.append('\n');
62         s.append(" JDO id = ").append(JDOHelper.getObjectId(this));
63         s.append('\n');
64         s.append(" dummy = ").append(dummy);
65         s.append('\n');
66
67         return s.toString();
68     }
69 }
70
Popular Tags