1 // Do not edit this file! It was generated by Melati POEM's DSD preprocessor.
2
3 package org.melati.example.contacts.generated;
4
5
6 import org.melati.example.contacts.Category;
7 import org.melati.example.contacts.Contact;
8 import org.melati.example.contacts.ContactCategoryTable;
9 import org.melati.example.contacts.ContactsDatabaseTables;
10 import org.melati.poem.AccessPoemException;
11 import org.melati.poem.Column;
12 import org.melati.poem.Field;
13 import org.melati.poem.JdbcPersistent;
14 import org.melati.poem.NoSuchRowPoemException;
15 import org.melati.poem.ValidationPoemException;
16
17
18 /**
19 * Melati POEM generated abstract base class for a <code>Persistent</code>
20 * <code>ContactCategory</code> Object.
21 *
22 * @generator org.melati.poem.prepro.TableDef#generatePersistentBaseJava
23 */
24 public abstract class ContactCategoryBase extends JdbcPersistent {
25
26
27 /**
28 * Retrieves the Database object.
29 *
30 * @generator org.melati.poem.prepro.TableDef#generatePersistentBaseJava
31 * @return the database
32 */
33 public ContactsDatabaseTables getContactsDatabaseTables() {
34 return (ContactsDatabaseTables)getDatabase();
35 }
36
37
38 /**
39 * Retrieves the <code>ContactCategoryTable</code> table
40 * which this <code>Persistent</code> is from.
41 *
42 * @generator org.melati.poem.prepro.TableDef#generatePersistentBaseJava
43 * @return the ContactCategoryTable
44 */
45 public ContactCategoryTable getContactCategoryTable() {
46 return (ContactCategoryTable)getTable();
47 }
48
49 private ContactCategoryTable _getContactCategoryTable() {
50 return (ContactCategoryTable)getTable();
51 }
52
53 // Fields in this table
54 /**
55 * id
56 */
57 protected Integer id;
58 /**
59 * category - Category
60 */
61 protected Integer category;
62 /**
63 * contact - Contact
64 */
65 protected Integer contact;
66
67
68 /**
69 * Retrieves the <code>Id</code> value, without locking,
70 * for this <code>ContactCategory</code> <code>Persistent</code>.
71 *
72 * @generator org.melati.poem.prepro.FieldDef#generateBaseMethods
73 * @return the Integer id
74 */
75 public Integer getId_unsafe() {
76 return id;
77 }
78
79
80 /**
81 * Sets the <code>Id</code> value directly, without checking,
82 * for this ContactCategory <code>Persistent</code>.
83 *
84 * @generator org.melati.poem.prepro.FieldDef#generateBaseMethods
85 * @param cooked the pre-validated value to set
86 */
87 public void setId_unsafe(Integer cooked) {
88 id = cooked;
89 }
90
91 /**
92 * Retrieves the Id value, with locking, for this
93 * <code>ContactCategory</code> <code>Persistent</code>.
94 *
95 * @generator org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
96 * @throws AccessPoemException
97 * if the current <code>AccessToken</code>
98 * does not confer write access rights
99 * @return the value of the field <code>Id</code> for this
100 * <code>ContactCategory</code> <code>Persistent</code>
101 */
102
103 public Integer getId()
104 throws AccessPoemException {
105 readLock();
106 return getId_unsafe();
107 }
108
109
110 /**
111 * Sets the <code>Id</code> value, with checking, for this
112 * <code>ContactCategory</code> <code>Persistent</code>.
113 *
114 * @generator org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
115 * @param cooked a validated <code>int</code>
116 * @throws AccessPoemException
117 * if the current <code>AccessToken</code>
118 * does not confer write access rights
119 * @throws ValidationPoemException
120 * if the value is not valid
121 */
122 public void setId(Integer cooked)
123 throws AccessPoemException, ValidationPoemException {
124 _getContactCategoryTable().getIdColumn().
125 getType().assertValidCooked(cooked);
126 writeLock();
127 setId_unsafe(cooked);
128 }
129
130 /**
131 * Sets the <code>Id</code> value, with checking, for this
132 * <code>ContactCategory</code> <code>Persistent</code>.
133 *
134 * @generator org.melati.poem.prepro.IntegerFieldDef#generateBaseMethods
135 * @param cooked a validated <code>int</code>
136 * @throws AccessPoemException
137 * if the current <code>AccessToken</code>
138 * does not confer write access rights
139 * @throws ValidationPoemException
140 * if the value is not valid
141 */
142
143 public final void setId(int cooked)
144 throws AccessPoemException, ValidationPoemException {
145 setId(new Integer(cooked));
146 }
147
148
149 /**
150 * Retrieves the <code>Id</code> value as a <code>Field</code>
151 * from this <code>ContactCategory</code> <code>Persistent</code>.
152 *
153 * @generator org.melati.poem.prepro.FieldDef#generateFieldCreator
154 * @throws AccessPoemException
155 * if the current <code>AccessToken</code>
156 * does not confer write access rights
157 * @return the Integer id
158 */
159 public Field getIdField() throws AccessPoemException {
160 Column c = _getContactCategoryTable().getIdColumn();
161 return new Field(c.getRaw(this), c);
162 }
163
164
165 /**
166 * Retrieves the <code>Category</code> value, without locking,
167 * for this <code>ContactCategory</code> <code>Persistent</code>.
168 *
169 * @generator org.melati.poem.prepro.FieldDef#generateBaseMethods
170 * @return the Integer category
171 */
172 public Integer getCategory_unsafe() {
173 return category;
174 }
175
176
177 /**
178 * Sets the <code>Category</code> value directly, without checking,
179 * for this ContactCategory <code>Persistent</code>.
180 *
181 * @generator org.melati.poem.prepro.FieldDef#generateBaseMethods
182 * @param cooked the pre-validated value to set
183 */
184 public void setCategory_unsafe(Integer cooked) {
185 category = cooked;
186 }
187
188 /**
189 * Retrieves the Table Row Object ID.
190 *
191 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
192 * @throws AccessPoemException
193 * if the current <code>AccessToken</code>
194 * does not confer read access rights
195 * @return the TROID as an <code>Integer</code>
196 */
197
198 public Integer getCategoryTroid()
199 throws AccessPoemException {
200 readLock();
201 return getCategory_unsafe();
202 }
203
204
205 /**
206 * Sets the Table Row Object ID.
207 *
208 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
209 * @param raw a Table Row Object Id
210 * @throws AccessPoemException
211 * if the current <code>AccessToken</code>
212 * does not confer write access rights
213 */
214 public void setCategoryTroid(Integer raw)
215 throws AccessPoemException {
216 setCategory(raw == null ? null :
217 getContactsDatabaseTables().getCategoryTable().getCategoryObject(raw));
218 }
219
220
221 /**
222 * Retrieves the <code>Category</code> object referred to.
223 *
224 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
225 * @throws AccessPoemException
226 * if the current <code>AccessToken</code>
227 * does not confer read access rights
228 * @throws NoSuchRowPoemException
229 * if the <code>Persistent</code> has yet to be allocated a TROID
230 * @return the <code>Category</code> as a <code>Category</code>
231 */
232 public Category getCategory()
233 throws AccessPoemException, NoSuchRowPoemException {
234 Integer troid = getCategoryTroid();
235 return troid == null ? null :
236 getContactsDatabaseTables().getCategoryTable().getCategoryObject(troid);
237 }
238
239
240 /**
241 * Set the Category.
242 *
243 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
244 * @param cooked a validated <code>Category</code>
245 * @throws AccessPoemException
246 * if the current <code>AccessToken</code>
247 * does not confer write access rights
248 */
249 public void setCategory(Category cooked)
250 throws AccessPoemException {
251 _getContactCategoryTable().
252 getCategoryColumn().
253 getType().assertValidCooked(cooked);
254 writeLock();
255 if (cooked == null)
256 setCategory_unsafe(null);
257 else {
258 cooked.existenceLock();
259 setCategory_unsafe(cooked.troid());
260 }
261 }
262
263
264 /**
265 * Retrieves the <code>Category</code> value as a <code>Field</code>
266 * from this <code>ContactCategory</code> <code>Persistent</code>.
267 *
268 * @generator org.melati.poem.prepro.FieldDef#generateFieldCreator
269 * @throws AccessPoemException
270 * if the current <code>AccessToken</code>
271 * does not confer write access rights
272 * @return the Integer category
273 */
274 public Field getCategoryField() throws AccessPoemException {
275 Column c = _getContactCategoryTable().getCategoryColumn();
276 return new Field(c.getRaw(this), c);
277 }
278
279
280 /**
281 * Retrieves the <code>Contact</code> value, without locking,
282 * for this <code>ContactCategory</code> <code>Persistent</code>.
283 *
284 * @generator org.melati.poem.prepro.FieldDef#generateBaseMethods
285 * @return the Integer contact
286 */
287 public Integer getContact_unsafe() {
288 return contact;
289 }
290
291
292 /**
293 * Sets the <code>Contact</code> value directly, without checking,
294 * for this ContactCategory <code>Persistent</code>.
295 *
296 * @generator org.melati.poem.prepro.FieldDef#generateBaseMethods
297 * @param cooked the pre-validated value to set
298 */
299 public void setContact_unsafe(Integer cooked) {
300 contact = cooked;
301 }
302
303 /**
304 * Retrieves the Table Row Object ID.
305 *
306 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
307 * @throws AccessPoemException
308 * if the current <code>AccessToken</code>
309 * does not confer read access rights
310 * @return the TROID as an <code>Integer</code>
311 */
312
313 public Integer getContactTroid()
314 throws AccessPoemException {
315 readLock();
316 return getContact_unsafe();
317 }
318
319
320 /**
321 * Sets the Table Row Object ID.
322 *
323 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
324 * @param raw a Table Row Object Id
325 * @throws AccessPoemException
326 * if the current <code>AccessToken</code>
327 * does not confer write access rights
328 */
329 public void setContactTroid(Integer raw)
330 throws AccessPoemException {
331 setContact(raw == null ? null :
332 getContactsDatabaseTables().getContactTable().getContactObject(raw));
333 }
334
335
336 /**
337 * Retrieves the <code>Contact</code> object referred to.
338 *
339 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
340 * @throws AccessPoemException
341 * if the current <code>AccessToken</code>
342 * does not confer read access rights
343 * @throws NoSuchRowPoemException
344 * if the <code>Persistent</code> has yet to be allocated a TROID
345 * @return the <code>Contact</code> as a <code>Contact</code>
346 */
347 public Contact getContact()
348 throws AccessPoemException, NoSuchRowPoemException {
349 Integer troid = getContactTroid();
350 return troid == null ? null :
351 getContactsDatabaseTables().getContactTable().getContactObject(troid);
352 }
353
354
355 /**
356 * Set the Contact.
357 *
358 * @generator org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods
359 * @param cooked a validated <code>Contact</code>
360 * @throws AccessPoemException
361 * if the current <code>AccessToken</code>
362 * does not confer write access rights
363 */
364 public void setContact(Contact cooked)
365 throws AccessPoemException {
366 _getContactCategoryTable().
367 getContactColumn().
368 getType().assertValidCooked(cooked);
369 writeLock();
370 if (cooked == null)
371 setContact_unsafe(null);
372 else {
373 cooked.existenceLock();
374 setContact_unsafe(cooked.troid());
375 }
376 }
377
378
379 /**
380 * Retrieves the <code>Contact</code> value as a <code>Field</code>
381 * from this <code>ContactCategory</code> <code>Persistent</code>.
382 *
383 * @generator org.melati.poem.prepro.FieldDef#generateFieldCreator
384 * @throws AccessPoemException
385 * if the current <code>AccessToken</code>
386 * does not confer write access rights
387 * @return the Integer contact
388 */
389 public Field getContactField() throws AccessPoemException {
390 Column c = _getContactCategoryTable().getContactColumn();
391 return new Field(c.getRaw(this), c);
392 }
393 }
394