KickJava   Java API By Example, From Geeks To Geeks.

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


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: KeywordConflict.java,v 1.4 2003/02/26 01:39:15 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.test;
12
13 import javax.jdo.JDOHelper;
14
15
16 /**
17  * A test object using Java identifiers intentionally chosen to conflict with
18  * reserved SQL keywords.
19  *
20  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
21  * @version $Revision: 1.4 $
22  */

23
24 class KeywordConflict extends TestObject
25 {
26     private int column;
27     private int select;
28     private int where;
29     private int varchar;
30     private int decimal;
31     private int _leading;
32     private int trailing_;
33     private int _surrounding_;
34
35
36     public KeywordConflict()
37     {
38         super();
39     }
40
41
42     public int getColumn()
43     {
44         return column;
45     }
46
47
48     public int getSelect()
49     {
50         return select;
51     }
52
53
54     public int getWhere()
55     {
56         return where;
57     }
58
59
60     public int getVarchar()
61     {
62         return varchar;
63     }
64
65
66     public int getDecimal()
67     {
68         return decimal;
69     }
70
71
72     public int getLeading()
73     {
74         return _leading;
75     }
76
77
78     public int getTrailing()
79     {
80         return trailing_;
81     }
82
83
84     public int getSurrounding()
85     {
86         return _surrounding_;
87     }
88
89
90     /**
91      * Fills all of the object's fields with random data values. Any non-
92      * primitive fields (with the exception of <code>id</code>) will also be
93      * assigned <code>null</code> on a random basis.
94      */

95
96     public void fillRandom()
97     {
98         column = r.nextInt();
99         select = r.nextInt();
100         where = r.nextInt();
101         varchar = r.nextInt();
102         decimal = r.nextInt();
103         _leading = r.nextInt();
104         trailing_ = r.nextInt();
105         _surrounding_ = r.nextInt();
106     }
107
108
109     /**
110      * Indicates whether some other object is "equal to" this one. By comparing
111      * against an original copy of the object, <code>compareTo()</code> can be
112      * used to verify that the object has been written to a database and read
113      * back correctly.
114      *
115      * @param obj the reference object with which to compare
116      *
117      * @return <code>true</code> if this object is equal to the obj argument;
118      * <code>false</code> otherwise.
119      */

120
121     public boolean compareTo(Object JavaDoc obj)
122     {
123         if (obj == this)
124             return true;
125
126         if (!(obj instanceof KeywordConflict))
127             return false;
128
129         KeywordConflict kc = (KeywordConflict)obj;
130
131         return column == kc.column
132             && select == kc.select
133             && where == kc.where
134             && varchar == kc.varchar
135             && decimal == kc.decimal
136             && _leading == _leading
137             && trailing_ == trailing_
138             && _surrounding_ == _surrounding_;
139     }
140
141
142     /**
143      * Returns a string representation for this object. All of the field
144      * values are included in the string for debugging purposes.
145      *
146      * @return a string representation for this object.
147      */

148
149     public String JavaDoc toString()
150     {
151         StringBuffer JavaDoc s = new StringBuffer JavaDoc(getClass().getName() + ":");
152
153         s.append(" JVM id = ").append(System.identityHashCode(this));
154         s.append('\n');
155         s.append(" JDO id = ").append(JDOHelper.getObjectId(this));
156         s.append('\n');
157         s.append(" column = ").append(column);
158         s.append('\n');
159         s.append(" select = ").append(select);
160         s.append('\n');
161         s.append(" where = ").append(where);
162         s.append('\n');
163         s.append(" varchar = ").append(varchar);
164         s.append('\n');
165         s.append(" decimal = ").append(decimal);
166         s.append('\n');
167         s.append(" _leading = ").append(_leading);
168         s.append('\n');
169         s.append(" trailing_ = ").append(trailing_);
170         s.append('\n');
171         s.append(" _surrounding_ = ").append(_surrounding_);
172         s.append('\n');
173
174         return s.toString();
175     }
176 }
177
Popular Tags