1 // Do not edit this file! It was generated by Melati POEM's DSD preprocessor.
2
3 package org.melati.poem.test.generated;
4
5
6 import org.melati.poem.AccessPoemException;
7 import org.melati.poem.Column;
8 import org.melati.poem.Field;
9 import org.melati.poem.JdbcPersistent;
10 import org.melati.poem.NoSuchRowPoemException;
11 import org.melati.poem.ValidationPoemException;
12 import org.melati.poem.test.Account;
13 import org.melati.poem.test.AccountTable;
14 import org.melati.poem.test.EverythingDatabaseTables;
15 import org.melati.poem.test.User;
16
17
18 /**
19 * Melati POEM generated abstract base class for a <code>Persistent</code>
20 * <code>Account</code> Object.
21 *
22 * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava
23 */
24 public abstract class AccountBase extends JdbcPersistent {
25
26
27 /**
28 * Retrieves the Database object.
29 *
30 * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava
31 * @return the database
32 */
33 public EverythingDatabaseTables getEverythingDatabaseTables() {
34 return (EverythingDatabaseTables)getDatabase();
35 }
36
37
38 /**
39 * Retrieves the <code>AccountTable</code> table
40 * which this <code>Persistent</code> is from.
41 *
42 * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava
43 * @return the AccountTable
44 */
45 @SuppressWarnings("unchecked")
46 public AccountTable<Account> getAccountTable() {
47 return (AccountTable<Account>)getTable();
48 }
49
50 @SuppressWarnings("unchecked")
51 private AccountTable<Account> _getAccountTable() {
52 return (AccountTable<Account>)getTable();
53 }
54
55 // Fields in this table
56 /**
57 * id
58 */
59 protected Integer id;
60 /**
61 * user - The owner
62 */
63 protected Integer user;
64 /**
65 * emailAddress - The owner's email address
66 */
67 protected String emailAddress;
68 /**
69 * name - The user's name
70 */
71 protected String name;
72
73
74 /**
75 * Retrieves the <code>Id</code> value, without locking,
76 * for this <code>Account</code> <code>Persistent</code>.
77 *
78 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
79 * @return the Integer id
80 */
81 public Integer getId_unsafe() {
82 return id;
83 }
84
85
86 /**
87 * Sets the <code>Id</code> value directly, without checking,
88 * for this Account <code>Persistent</code>.
89 *
90 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
91 * @param cooked the pre-validated value to set
92 */
93 public void setId_unsafe(Integer cooked) {
94 id = cooked;
95 }
96
97 /**
98 * Retrieves the Id value, with locking, for this
99 * <code>Account</code> <code>Persistent</code>.
100 *
101 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
102 * @throws AccessPoemException
103 * if the current <code>AccessToken</code>
104 * does not confer write access rights
105 * @return the value of the field <code>Id</code> for this
106 * <code>Account</code> <code>Persistent</code>
107 */
108
109 public Integer getId()
110 throws AccessPoemException {
111 readLock();
112 return getId_unsafe();
113 }
114
115
116 /**
117 * Sets the <code>Id</code> value, with checking, for this
118 * <code>Account</code> <code>Persistent</code>.
119 *
120 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
121 * @param cooked a validated <code>int</code>
122 * @throws AccessPoemException
123 * if the current <code>AccessToken</code>
124 * does not confer write access rights
125 * @throws ValidationPoemException
126 * if the value is not valid
127 */
128 public void setId(Integer cooked)
129 throws AccessPoemException, ValidationPoemException {
130 _getAccountTable().getIdColumn().
131 getType().assertValidCooked(cooked);
132 writeLock();
133 setId_unsafe(cooked);
134 }
135
136 /**
137 * Sets the <code>Id</code> value, with checking, for this
138 * <code>Account</code> <code>Persistent</code>.
139 *
140 * Generated by org.melati.poem.prepro.IntegerFieldDef#generateBaseMethods
141 * @param cooked a validated <code>int</code>
142 * @throws AccessPoemException
143 * if the current <code>AccessToken</code>
144 * does not confer write access rights
145 * @throws ValidationPoemException
146 * if the value is not valid
147 */
148
149 public final void setId(int cooked)
150 throws AccessPoemException, ValidationPoemException {
151 setId(new Integer(cooked));
152 }
153
154
155 /**
156 * Retrieves the <code>Id</code> value as a <code>Field</code>
157 * from this <code>Account</code> <code>Persistent</code>.
158 *
159 * see org.melati.poem.prepro.FieldDef#generateFieldCreator
160 * @throws AccessPoemException
161 * if the current <code>AccessToken</code>
162 * does not confer write access rights
163 * @return the Integer id
164 */
165 public Field<Integer> getIdField() throws AccessPoemException {
166 Column<Integer> c = _getAccountTable().getIdColumn();
167 return new Field<Integer>((Integer)c.getRaw(this), c);
168 }
169
170
171 /**
172 * Retrieves the <code>User</code> value, without locking,
173 * for this <code>Account</code> <code>Persistent</code>.
174 *
175 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
176 * @return the Integer user
177 */
178 public Integer getUser_unsafe() {
179 return user;
180 }
181
182
183 /**
184 * Sets the <code>User</code> value directly, without checking,
185 * for this Account <code>Persistent</code>.
186 *
187 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
188 * @param cooked the pre-validated value to set
189 */
190 public void setUser_unsafe(Integer cooked) {
191 user = cooked;
192 }
193
194 /**
195 * Retrieves the Table Row Object ID.
196 *
197 * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
198 * @throws AccessPoemException
199 * if the current <code>AccessToken</code>
200 * does not confer read access rights
201 * @return the TROID as an <code>Integer</code>
202 */
203
204 public Integer getUserTroid()
205 throws AccessPoemException {
206 readLock();
207 return getUser_unsafe();
208 }
209
210
211 /**
212 * Sets the Table Row Object ID.
213 *
214 * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
215 * @param raw a Table Row Object Id
216 * @throws AccessPoemException
217 * if the current <code>AccessToken</code>
218 * does not confer write access rights
219 */
220 public void setUserTroid(Integer raw)
221 throws AccessPoemException {
222 setUser(raw == null ? null :
223 (User)getEverythingDatabaseTables().getUserTable().getUserObject(raw));
224 }
225
226
227 /**
228 * Retrieves the <code>User</code> object referred to.
229 *
230 * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
231 * @throws AccessPoemException
232 * if the current <code>AccessToken</code>
233 * does not confer read access rights
234 * @throws NoSuchRowPoemException
235 * if the <code>Persistent</code> has yet to be allocated a TROID
236 * @return the <code>User</code> as a <code>User</code>
237 */
238 public User getUser()
239 throws AccessPoemException, NoSuchRowPoemException {
240 Integer troid = getUserTroid();
241 return troid == null ? null :
242 (User)getEverythingDatabaseTables().getUserTable().getUserObject(troid);
243 }
244
245
246 /**
247 * Set the User.
248 *
249 * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
250 * @param cooked a validated <code>User</code>
251 * @throws AccessPoemException
252 * if the current <code>AccessToken</code>
253 * does not confer write access rights
254 */
255 public void setUser(User cooked)
256 throws AccessPoemException {
257 _getAccountTable().
258 getUserColumn().
259 getType().assertValidCooked(cooked);
260 writeLock();
261 if (cooked == null)
262 setUser_unsafe(null);
263 else {
264 cooked.existenceLock();
265 setUser_unsafe(cooked.troid());
266 }
267 }
268
269
270 /**
271 * Retrieves the <code>User</code> value as a <code>Field</code>
272 * from this <code>Account</code> <code>Persistent</code>.
273 *
274 * see org.melati.poem.prepro.FieldDef#generateFieldCreator
275 * @throws AccessPoemException
276 * if the current <code>AccessToken</code>
277 * does not confer write access rights
278 * @return the Integer user
279 */
280 public Field<Integer> getUserField() throws AccessPoemException {
281 Column<Integer> c = _getAccountTable().getUserColumn();
282 return new Field<Integer>((Integer)c.getRaw(this), c);
283 }
284
285
286 /**
287 * Retrieves the <code>EmailAddress</code> value, without locking,
288 * for this <code>Account</code> <code>Persistent</code>.
289 *
290 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
291 * @return the String emailAddress
292 */
293 public String getEmailAddress_unsafe() {
294 return emailAddress;
295 }
296
297
298 /**
299 * Sets the <code>EmailAddress</code> value directly, without checking,
300 * for this Account <code>Persistent</code>.
301 *
302 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
303 * @param cooked the pre-validated value to set
304 */
305 public void setEmailAddress_unsafe(String cooked) {
306 emailAddress = cooked;
307 }
308
309 /**
310 * Retrieves the Table Row Object ID.
311 *
312 * Generated by org.melati.poem.prepro.StringKeyReferenceFieldDef#generateBaseMethods
313 * @throws AccessPoemException
314 * if the current <code>AccessToken</code>
315 * does not confer read access rights
316 * @return the TROID as an <code>Integer</code>
317 */
318
319 public Integer getEmailAddressTroid()
320 throws AccessPoemException {
321 String keyValue = getEmailAddress_unsafe();
322 if (keyValue == null)
323 return null;
324 else
325 return getEverythingDatabaseTables()
326 .getEverythingUserTable()
327 .getEmailColumn()
328 .firstWhereEq(keyValue)
329 .troid();
330 }
331
332
333 /**
334 * Sets persistent reference with access checking.
335 *
336 * Generated by org.melati.poem.prepro.StringKeyReferenceFieldDef#generateBaseMethods
337 * @param keyValue a String prime key
338 * @throws AccessPoemException
339 * if the current <code>AccessToken</code>
340 * does not confer write access rights
341 */
342 public void setEmailAddress(String keyValue)
343 throws AccessPoemException {
344 setEmailAddress(keyValue == null ? null :
345 (User)getEverythingDatabaseTables().getEverythingUserTable().
346 getEmailColumn().firstWhereEq(keyValue));
347 }
348
349
350 /**
351 * Retrieves the EmailAddress value, with locking, for this
352 * <code>Account</code> <code>Persistent</code>.
353 * Field description:
354 * The owner's email address
355 *
356 * Generated by org.melati.poem.prepro.StringKeyReferenceFieldDef#generateBaseMethods
357 * @throws AccessPoemException
358 * if the current <code>AccessToken</code>
359 * does not confer write access rights
360 * @return the value of the field <code>EmailAddress</code> for this
361 * <code>Account</code> <code>Persistent</code>
362 */
363
364 public String getEmailAddress()
365 throws AccessPoemException {
366 readLock();
367 return getEmailAddress_unsafe();
368 }
369
370
371 /**
372 * Retrieves the <code>User</code> object referred to.
373 *
374 * Generated by org.melati.poem.prepro.StringKeyReferenceFieldDef#generateBaseMethods
375 * @throws AccessPoemException
376 * if the current <code>AccessToken</code>
377 * does not confer read access rights
378 * @return the <code>EmailAddress</code> as a <code>User</code>
379 */
380 public User getEmailAddressReferee()
381 throws AccessPoemException, NoSuchRowPoemException {
382 String keyValue = getEmailAddress_unsafe();
383 if (keyValue == null)
384 return null;
385 else
386 return
387 (User)getEverythingDatabaseTables().getEverythingUserTable().getEmailColumn().firstWhereEq(keyValue);
388 }
389
390
391 /**
392 * Set the EmailAddress having validated it.
393 *
394 * Generated by org.melati.poem.prepro.StringKeyReferenceFieldDef#generateBaseMethods
395 * @param cooked a validated <code>User</code>
396 * @throws AccessPoemException
397 * if the current <code>AccessToken</code>
398 * does not confer write access rights
399 */
400 public void setEmailAddress(User cooked)
401 throws AccessPoemException {
402 getEverythingDatabaseTables().getEverythingUserTable().
403 getEmailColumn().
404 getType().assertValidCooked(
405 cooked == null ? null : cooked.getRaw("email"));
406 writeLock();
407 if (cooked == null)
408 setEmailAddress_unsafe(null);
409 else {
410 cooked.existenceLock();
411 setEmailAddress_unsafe(cooked.getEmail_unsafe());
412 }
413 }
414
415
416 /**
417 * Retrieves the <code>EmailAddress</code> value as a <code>Field</code>
418 * from this <code>Account</code> <code>Persistent</code>.
419 *
420 * see org.melati.poem.prepro.FieldDef#generateFieldCreator
421 * @throws AccessPoemException
422 * if the current <code>AccessToken</code>
423 * does not confer write access rights
424 * @return the String emailAddress
425 */
426 public Field<String> getEmailAddressField() throws AccessPoemException {
427 Column<String> c = _getAccountTable().getEmailAddressColumn();
428 return new Field<String>((String)c.getRaw(this), c);
429 }
430
431
432 /**
433 * Retrieves the <code>Name</code> value, without locking,
434 * for this <code>Account</code> <code>Persistent</code>.
435 *
436 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
437 * @return the String name
438 */
439 public String getName_unsafe() {
440 return name;
441 }
442
443
444 /**
445 * Sets the <code>Name</code> value directly, without checking,
446 * for this Account <code>Persistent</code>.
447 *
448 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
449 * @param cooked the pre-validated value to set
450 */
451 public void setName_unsafe(String cooked) {
452 name = cooked;
453 }
454
455 /**
456 * Retrieves the Name value, with locking, for this
457 * <code>Account</code> <code>Persistent</code>.
458 * Field description:
459 * The user's name
460 *
461 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
462 * @throws AccessPoemException
463 * if the current <code>AccessToken</code>
464 * does not confer write access rights
465 * @return the value of the field <code>Name</code> for this
466 * <code>Account</code> <code>Persistent</code>
467 */
468
469 public String getName()
470 throws AccessPoemException {
471 readLock();
472 return getName_unsafe();
473 }
474
475
476 /**
477 * Sets the <code>Name</code> value, with checking, for this
478 * <code>Account</code> <code>Persistent</code>.
479 * Field description:
480 * The user's name
481 *
482 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
483 * @param cooked a validated <code>int</code>
484 * @throws AccessPoemException
485 * if the current <code>AccessToken</code>
486 * does not confer write access rights
487 * @throws ValidationPoemException
488 * if the value is not valid
489 */
490 public void setName(String cooked)
491 throws AccessPoemException, ValidationPoemException {
492 _getAccountTable().getNameColumn().
493 getType().assertValidCooked(cooked);
494 writeLock();
495 setName_unsafe(cooked);
496 }
497
498
499 /**
500 * Retrieves the <code>Name</code> value as a <code>Field</code>
501 * from this <code>Account</code> <code>Persistent</code>.
502 *
503 * see org.melati.poem.prepro.FieldDef#generateFieldCreator
504 * @throws AccessPoemException
505 * if the current <code>AccessToken</code>
506 * does not confer write access rights
507 * @return the String name
508 */
509 public Field<String> getNameField() throws AccessPoemException {
510 Column<String> c = _getAccountTable().getNameColumn();
511 return new Field<String>((String)c.getRaw(this), c);
512 }
513
514 }
515