001: /*
002: * Copyright 2002 (C) TJDO.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the TJDO License version 1.0.
006: * See the terms of the TJDO License in the documentation provided with this software.
007: *
008: * $Id: KeywordConflict.java,v 1.4 2003/02/26 01:39:15 jackknifebarber Exp $
009: */
010:
011: package com.triactive.jdo.test;
012:
013: import javax.jdo.JDOHelper;
014:
015: /**
016: * A test object using Java identifiers intentionally chosen to conflict with
017: * reserved SQL keywords.
018: *
019: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
020: * @version $Revision: 1.4 $
021: */
022:
023: class KeywordConflict extends TestObject {
024: private int column;
025: private int select;
026: private int where;
027: private int varchar;
028: private int decimal;
029: private int _leading;
030: private int trailing_;
031: private int _surrounding_;
032:
033: public KeywordConflict() {
034: super ();
035: }
036:
037: public int getColumn() {
038: return column;
039: }
040:
041: public int getSelect() {
042: return select;
043: }
044:
045: public int getWhere() {
046: return where;
047: }
048:
049: public int getVarchar() {
050: return varchar;
051: }
052:
053: public int getDecimal() {
054: return decimal;
055: }
056:
057: public int getLeading() {
058: return _leading;
059: }
060:
061: public int getTrailing() {
062: return trailing_;
063: }
064:
065: public int getSurrounding() {
066: return _surrounding_;
067: }
068:
069: /**
070: * Fills all of the object's fields with random data values. Any non-
071: * primitive fields (with the exception of <code>id</code>) will also be
072: * assigned <code>null</code> on a random basis.
073: */
074:
075: public void fillRandom() {
076: column = r.nextInt();
077: select = r.nextInt();
078: where = r.nextInt();
079: varchar = r.nextInt();
080: decimal = r.nextInt();
081: _leading = r.nextInt();
082: trailing_ = r.nextInt();
083: _surrounding_ = r.nextInt();
084: }
085:
086: /**
087: * Indicates whether some other object is "equal to" this one. By comparing
088: * against an original copy of the object, <code>compareTo()</code> can be
089: * used to verify that the object has been written to a database and read
090: * back correctly.
091: *
092: * @param obj the reference object with which to compare
093: *
094: * @return <code>true</code> if this object is equal to the obj argument;
095: * <code>false</code> otherwise.
096: */
097:
098: public boolean compareTo(Object obj) {
099: if (obj == this )
100: return true;
101:
102: if (!(obj instanceof KeywordConflict))
103: return false;
104:
105: KeywordConflict kc = (KeywordConflict) obj;
106:
107: return column == kc.column && select == kc.select
108: && where == kc.where && varchar == kc.varchar
109: && decimal == kc.decimal && _leading == _leading
110: && trailing_ == trailing_
111: && _surrounding_ == _surrounding_;
112: }
113:
114: /**
115: * Returns a string representation for this object. All of the field
116: * values are included in the string for debugging purposes.
117: *
118: * @return a string representation for this object.
119: */
120:
121: public String toString() {
122: StringBuffer s = new StringBuffer(getClass().getName() + ":");
123:
124: s.append(" JVM id = ").append(System.identityHashCode(this ));
125: s.append('\n');
126: s.append(" JDO id = ").append(JDOHelper.getObjectId(this ));
127: s.append('\n');
128: s.append(" column = ").append(column);
129: s.append('\n');
130: s.append(" select = ").append(select);
131: s.append('\n');
132: s.append(" where = ").append(where);
133: s.append('\n');
134: s.append(" varchar = ").append(varchar);
135: s.append('\n');
136: s.append(" decimal = ").append(decimal);
137: s.append('\n');
138: s.append(" _leading = ").append(_leading);
139: s.append('\n');
140: s.append(" trailing_ = ").append(trailing_);
141: s.append('\n');
142: s.append(" _surrounding_ = ").append(_surrounding_);
143: s.append('\n');
144:
145: return s.toString();
146: }
147: }
|