1 package org.hibernate.test.legacy; 3 4 import java.io.Serializable ; 5 import java.sql.Timestamp ; 6 import java.util.Calendar ; 7 import java.util.Date ; 8 import java.util.Locale ; 9 10 import org.hibernate.CallbackException; 11 import org.hibernate.Session; 12 import org.hibernate.classic.Lifecycle; 13 14 public class Foo implements Lifecycle, FooProxy, Serializable { 15 16 private static int count=0; 17 18 public static class Struct implements java.io.Serializable { 19 String name; 20 int count; 21 public boolean equals(Object other) { 22 Struct s = (Struct) other; 23 return ( s.name==name || s.name.equals(name) ) && s.count==count; 24 } 25 public int hashCode() { 26 return count; 27 } 28 } 29 30 38 39 String key; 40 FooProxy _foo; 41 String _string; 42 Date _date; 43 Date _timestamp; 44 Integer _integer; 45 Long _long; 46 Short _short; 47 Float _float; 48 Double _double; 49 Boolean _boolean; 50 Byte _byte; 51 Integer _null; 52 int _int; 53 boolean _bool; 54 float _zero; 55 byte[] _bytes; 56 boolean yesno; 57 java.io.Serializable blob; 58 java.io.Serializable nullBlob; 59 byte[] binary; 60 String [] custom; 61 FooComponent component; 62 char _char; 63 Fee dependent; 64 Locale theLocale; 65 private int version; 66 private Timestamp versionTimestamp; 67 private Calendar versionCalendar; 68 private float formula; 69 private String joinedProp; 70 71 private int x; 72 73 public int getX() { 74 return x; 75 } 76 public void setX(int x) { 77 this.x = x; 78 } 79 80 public Foo() { 81 } 82 83 public Foo(int x) { 84 this.x=x; 85 } 86 87 public boolean onSave(Session db) throws CallbackException { 88 _string = "a string"; 89 _date = new Date (123); 90 _timestamp = new Date ( System.currentTimeMillis() ); 91 _integer = new Integer ( -666 ); 92 _long = new Long ( 696969696969696969l - count++ ); 93 _short = new Short ("42"); 94 _float = new Float ( 6666.66f ); 95 _double = new Double ( 1.12e-36 ); 97 _boolean = new Boolean (true); 98 _byte = new Byte ( (byte) 127 ); 99 _int = 2; 100 _char = '@'; 101 _bytes = _string.getBytes(); 102 Struct s = new Struct(); 103 s.name="name"; 104 s.count = 69; 105 blob = s; 106 binary = ( _string + "yada yada yada" ).getBytes(); 107 custom = new String [] { "foo", "bar" }; 108 component = new FooComponent("foo", 12, new Date [] { _date, _timestamp, null, new Date () }, new FooComponent("bar", 666, new Date [] { new Date (123456l), null }, null ) ); 109 component.setGlarch( new Glarch() ); 110 dependent = new Fee(); 111 dependent.setFi( "belongs to foo # " + getKey() ); 112 theLocale = Locale.getDefault(); 113 return NO_VETO; 114 } 115 116 public boolean onDelete(Session db) throws CallbackException { 117 return NO_VETO; 118 } 119 public boolean onUpdate(Session db) throws CallbackException { 120 return NO_VETO; 121 } 122 123 public void onLoad(Session db, Serializable id) { 124 } 125 126 public String getKey() { 127 return key; 128 } 129 public void setKey(String key) { 130 this.key = key; 131 } 132 133 public FooProxy getFoo() { 134 return _foo; 135 } 136 public void setFoo(FooProxy foo) { 137 _foo = foo; 138 } 139 140 public String getString() { 141 return _string; 142 } 143 public void setString(String string) { 144 _string = string; 145 } 147 148 public java.util.Date getDate() { 149 return _date; 150 } 151 public void setDate(java.util.Date date) { 152 _date = date; 153 } 154 155 public java.util.Date getTimestamp() { 156 return _timestamp; 157 } 158 public void setTimestamp(java.util.Date timestamp) { 159 _timestamp = timestamp; 160 } 161 162 public Integer getInteger() { 163 return _integer; 164 } 165 public void setInteger(Integer iinteger) { 166 _integer = iinteger; 167 } 168 public Long getLong() { 169 return _long; 170 } 171 public void setLong(Long llong) { 172 _long = llong; 173 } 174 175 176 public Short getShort() { 177 return _short; 178 } 179 public void setShort(Short sshort) { 180 _short = sshort; 181 } 182 public Float getFloat() { 183 return _float; 184 } 185 public void setFloat(Float ffloat) { 186 _float = ffloat; 187 } 188 public Double getDouble() { 189 return _double; 190 } 191 public void setDouble(Double ddouble) { 192 _double = ddouble; 193 } 194 public Boolean getBoolean() { 195 return _boolean; 196 } 197 public void setBoolean(Boolean bboolean) { 198 _boolean = bboolean; 199 } 200 public byte[] getBytes() { 201 return _bytes; 202 } 203 public void setBytes(byte[] bytes) { 204 _bytes = bytes; 205 } 206 public float getZero() { 207 return _zero; 208 } 209 public void setZero(float zero) { 210 _zero = zero; 211 } 212 public boolean getBool() { 213 return _bool; 214 } 215 public void setBool(boolean bool) { 216 _bool = bool; 217 } 218 219 public int getInt() { 220 return _int; 221 } 222 public void setInt(int iint) { 223 _int = iint; 224 } 225 226 public Integer getNull() { 227 return _null; 228 } 229 public void setNull(Integer nnull) { 230 _null = nnull; 231 } 232 233 public Byte getByte() { 234 return _byte; 235 } 236 237 public void setByte(Byte bbyte) { 238 _byte = bbyte; 239 } 240 241 public String toString() { 242 return this.getClass().getName() + ": " + key; 243 } 244 245 public void disconnect() { 246 if ( _foo!=null) _foo.disconnect(); 247 _foo=null; 248 } 249 250 public boolean equalsFoo(Foo other) { 251 if ( _bytes!=other._bytes ) { 252 if ( _bytes==null || other._bytes==null ) return false; 253 if ( _bytes.length!=other._bytes.length ) return false; 254 for ( int i=0; i< _bytes.length; i++) { 255 if ( _bytes[i] != other._bytes[i] ) return false; 256 } 257 } 258 259 return ( this._bool == other._bool ) 260 && ( ( this._boolean == other._boolean ) || ( this._boolean.equals(other._boolean) ) ) 261 && ( ( this._byte == other._byte ) || ( this._byte.equals(other._byte) ) ) 262 && ( ( this._double == other._double ) || ( this._double.equals(other._double) ) ) 264 && ( ( this._float == other._float ) || ( this._float.equals(other._float) ) ) 265 && ( this._int == other._int ) 266 && ( ( this._integer == other._integer ) || ( this._integer.equals(other._integer) ) ) 267 && ( ( this._long == other._long ) || ( this._long.equals(other._long) ) ) 268 && ( this._null == other._null ) 269 && ( ( this._short == other._short ) || ( this._short.equals(other._short) ) ) 270 && ( ( this._string == other._string) || ( this._string.equals(other._string) ) ) 271 && ( this._zero == other._zero ) 273 && ( ( this._foo == other._foo ) || ( this._foo.getKey().equals( other._foo.getKey() ) ) ) 274 && ( ( this.blob == other.blob ) || ( this.blob.equals(other.blob) ) ) 275 && ( this.yesno == other.yesno ) 276 && ( ( this.binary == other.binary ) || java.util.Arrays.equals(this.binary, other.binary) ) 277 && ( this.key.equals(other.key) ) 278 && ( this.theLocale.equals(other.theLocale) ) 279 && ( ( this.custom == other.custom ) || ( this.custom[0].equals(other.custom[0]) && this.custom[1].equals(other.custom[1]) ) ); 280 281 } 282 283 public boolean getYesno() { 284 return yesno; 285 } 286 287 public void setYesno(boolean yesno) { 288 this.yesno = yesno; 289 } 290 291 public java.io.Serializable getBlob() { 292 return blob; 293 } 294 295 public void setBlob(java.io.Serializable blob) { 296 this.blob = blob; 297 } 298 299 public java.io.Serializable getNullBlob() { 300 return nullBlob; 301 } 302 303 public void setNullBlob(java.io.Serializable nullBlob) { 304 this.nullBlob = nullBlob; 305 } 306 307 public byte[] getBinary() { 308 return binary; 309 } 310 public void setBinary(byte[] binary) { 311 this.binary = binary; 312 } 313 314 public String [] getCustom() { 315 return custom; 316 } 317 318 public void setCustom(String [] custom) { 319 this.custom = custom; 320 } 321 322 public FooComponent getComponent() { 323 return component; 324 } 325 public void setComponent(FooComponent component) { 326 this.component = component; 327 } 328 329 public FooComponent getNullComponent() { 330 return null; 331 } 332 public void setNullComponent(FooComponent fc) throws Exception { 333 if (fc!=null) throw new Exception ("Null component"); 334 } 335 336 public Character getChar() { 337 return new Character (_char); 338 } 339 340 public void setChar(Character _char) { 341 this._char = _char.charValue(); 342 } 343 344 public Fee getDependent() { 345 return dependent; 346 } 347 348 public void setDependent(Fee dependent) { 349 this.dependent = dependent; 350 } 351 352 356 public Locale getLocale() { 357 return theLocale; 358 } 359 360 364 public void setLocale(Locale locale) { 365 this.theLocale = locale; 366 } 367 368 372 public int getVersion() { 373 return version; 374 } 375 376 380 public void setVersion(int version) { 381 this.version = version; 382 } 383 384 388 public Timestamp getVersionTimestamp() { 389 return versionTimestamp; 390 } 391 392 396 public void setVersionTimestamp(Timestamp versionTimestamp) { 397 this.versionTimestamp = versionTimestamp; 398 } 399 400 public void finalize() { } 401 402 public Calendar getVersionCalendar() { 403 return versionCalendar; 404 } 405 406 public void setVersionCalendar(Calendar calendar) { 407 versionCalendar = calendar; 408 } 409 410 public float getFormula() { 411 return formula; 412 } 413 414 public void setFormula(float f) { 415 formula = f; 416 } 417 418 421 public String getJoinedProp() { 422 return joinedProp; 423 } 424 425 428 public void setJoinedProp(String joinedProp) { 429 this.joinedProp = joinedProp; 430 } 431 432 } 433 434 435 436 437 438 | Popular Tags |