View Javadoc
1   // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
2   
3   package org.melati.example.odmg.generated;
4   
5   
6   import org.melati.example.odmg.Child;
7   import org.melati.example.odmg.ChildTable;
8   import org.melati.example.odmg.OdmgDatabaseTables;
9   import org.melati.example.odmg.Parent;
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>Child</code> Object.
21   *
22   * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
23   */
24  public abstract class ChildBase 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 OdmgDatabaseTables getOdmgDatabaseTables() {
34      return (OdmgDatabaseTables)getDatabase();
35    }
36  
37  
38   /**
39    * Retrieves the  <code>ChildTable</code> table 
40    * which this <code>Persistent</code> is from.
41    * 
42    * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
43    * @return the ChildTable
44    */
45    @SuppressWarnings("unchecked")
46    public ChildTable<Child> getChildTable() {
47      return (ChildTable<Child>)getTable();
48    }
49  
50    @SuppressWarnings("unchecked")
51    private ChildTable<Child> _getChildTable() {
52      return (ChildTable<Child>)getTable();
53    }
54  
55    // Fields in this table 
56   /**
57    * id 
58    */
59    protected Integer id;
60   /**
61    * name 
62    */
63    protected String name;
64   /**
65    * parent 
66    */
67    protected Integer parent;
68  
69  
70   /**
71    * Retrieves the <code>Id</code> value, without locking, 
72    * for this <code>Child</code> <code>Persistent</code>.
73    *
74    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
75    * @return the Integer id
76    */
77    public Integer getId_unsafe() {
78      return id;
79    }
80  
81  
82   /**
83    * Sets the <code>Id</code> value directly, without checking, 
84    * for this Child <code>Persistent</code>.
85    * 
86    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
87    * @param cooked  the pre-validated value to set
88    */
89    public void setId_unsafe(Integer cooked) {
90      id = cooked;
91    }
92  
93   /**
94    * Retrieves the Id value, with locking, for this 
95    * <code>Child</code> <code>Persistent</code>.
96    * 
97    * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
98    * @throws AccessPoemException 
99    *         if the current <code>AccessToken</code> 
100   *         does not confer write access rights 
101   * @return the value of the field <code>Id</code> for this 
102   *         <code>Child</code> <code>Persistent</code>  
103   */
104 
105   public Integer getId()
106       throws AccessPoemException {
107     readLock();
108     return getId_unsafe();
109   }
110 
111 
112  /**
113   * Sets the <code>Id</code> value, with checking, for this 
114   * <code>Child</code> <code>Persistent</code>.
115   * 
116   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
117   * @param cooked  a validated <code>int</code> 
118   * @throws AccessPoemException 
119   *         if the current <code>AccessToken</code> 
120   *         does not confer write access rights
121   * @throws ValidationPoemException 
122   *         if the value is not valid
123   */
124   public void setId(Integer cooked)
125       throws AccessPoemException, ValidationPoemException {
126     _getChildTable().getIdColumn().
127       getType().assertValidCooked(cooked);
128     writeLock();
129     setId_unsafe(cooked);
130   }
131 
132  /**
133   * Sets the <code>Id</code> value, with checking, for this 
134   * <code>Child</code> <code>Persistent</code>.
135   * 
136   * Generated by org.melati.poem.prepro.IntegerFieldDef#generateBaseMethods 
137   * @param cooked  a validated <code>int</code>
138   * @throws AccessPoemException 
139   *         if the current <code>AccessToken</code> 
140   *         does not confer write access rights
141   * @throws ValidationPoemException 
142   *         if the value is not valid
143   */
144 
145   public final void setId(int cooked)
146       throws AccessPoemException, ValidationPoemException {
147     setId(new Integer(cooked));
148   }
149 
150 
151  /**
152   * Retrieves the <code>Id</code> value as a <code>Field</code>
153   * from this <code>Child</code> <code>Persistent</code>.
154   * 
155   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
156   * @throws AccessPoemException 
157   *         if the current <code>AccessToken</code> 
158   *         does not confer write access rights
159   * @return the Integer id
160   */
161   public Field<Integer> getIdField() throws AccessPoemException {
162     Column<Integer> c = _getChildTable().getIdColumn();
163     return new Field<Integer>((Integer)c.getRaw(this), c);
164   }
165 
166 
167  /**
168   * Retrieves the <code>Name</code> value, without locking, 
169   * for this <code>Child</code> <code>Persistent</code>.
170   *
171   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
172   * @return the String name
173   */
174   public String getName_unsafe() {
175     return name;
176   }
177 
178 
179  /**
180   * Sets the <code>Name</code> value directly, without checking, 
181   * for this Child <code>Persistent</code>.
182   * 
183   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
184   * @param cooked  the pre-validated value to set
185   */
186   public void setName_unsafe(String cooked) {
187     name = cooked;
188   }
189 
190  /**
191   * Retrieves the Name value, with locking, for this 
192   * <code>Child</code> <code>Persistent</code>.
193   * 
194   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
195   * @throws AccessPoemException 
196   *         if the current <code>AccessToken</code> 
197   *         does not confer write access rights 
198   * @return the value of the field <code>Name</code> for this 
199   *         <code>Child</code> <code>Persistent</code>  
200   */
201 
202   public String getName()
203       throws AccessPoemException {
204     readLock();
205     return getName_unsafe();
206   }
207 
208 
209  /**
210   * Sets the <code>Name</code> value, with checking, for this 
211   * <code>Child</code> <code>Persistent</code>.
212   * 
213   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
214   * @param cooked  a validated <code>int</code> 
215   * @throws AccessPoemException 
216   *         if the current <code>AccessToken</code> 
217   *         does not confer write access rights
218   * @throws ValidationPoemException 
219   *         if the value is not valid
220   */
221   public void setName(String cooked)
222       throws AccessPoemException, ValidationPoemException {
223     _getChildTable().getNameColumn().
224       getType().assertValidCooked(cooked);
225     writeLock();
226     setName_unsafe(cooked);
227   }
228 
229 
230  /**
231   * Retrieves the <code>Name</code> value as a <code>Field</code>
232   * from this <code>Child</code> <code>Persistent</code>.
233   * 
234   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
235   * @throws AccessPoemException 
236   *         if the current <code>AccessToken</code> 
237   *         does not confer write access rights
238   * @return the String name
239   */
240   public Field<String> getNameField() throws AccessPoemException {
241     Column<String> c = _getChildTable().getNameColumn();
242     return new Field<String>((String)c.getRaw(this), c);
243   }
244 
245 
246  /**
247   * Retrieves the <code>Parent</code> value, without locking, 
248   * for this <code>Child</code> <code>Persistent</code>.
249   *
250   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
251   * @return the Integer parent
252   */
253   public Integer getParent_unsafe() {
254     return parent;
255   }
256 
257 
258  /**
259   * Sets the <code>Parent</code> value directly, without checking, 
260   * for this Child <code>Persistent</code>.
261   * 
262   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
263   * @param cooked  the pre-validated value to set
264   */
265   public void setParent_unsafe(Integer cooked) {
266     parent = cooked;
267   }
268 
269  /**
270   * Retrieves the Table Row Object ID. 
271   *
272   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
273   * @throws AccessPoemException  
274   *         if the current <code>AccessToken</code> 
275   *         does not confer read access rights 
276   * @return the TROID as an <code>Integer</code> 
277   */
278 
279   public Integer getParentTroid()
280       throws AccessPoemException {
281     readLock();
282     return getParent_unsafe();
283   }
284 
285 
286  /**
287   * Sets the Table Row Object ID. 
288   * 
289   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
290   * @param raw  a Table Row Object Id 
291   * @throws AccessPoemException  
292   *         if the current <code>AccessToken</code> 
293   *         does not confer write access rights
294   */
295   public void setParentTroid(Integer raw)
296       throws AccessPoemException {
297     setParent(raw == null ? null : 
298         getOdmgDatabaseTables().getParentTable().getParentObject(raw));
299   }
300 
301 
302  /**
303   * Retrieves the <code>Parent</code> object referred to.
304   *  
305   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
306   * @throws AccessPoemException  
307   *         if the current <code>AccessToken</code> 
308   *         does not confer read access rights 
309   * @throws NoSuchRowPoemException  
310   *         if the <code>Persistent</code> has yet to be allocated a TROID 
311   * @return the <code>Parent</code> as a <code>Parent</code> 
312   */
313   public Parent getParent()
314       throws AccessPoemException, NoSuchRowPoemException {
315     Integer troid = getParentTroid();
316     return troid == null ? null :
317         getOdmgDatabaseTables().getParentTable().getParentObject(troid);
318   }
319 
320 
321  /**
322   * Set the Parent.
323   * 
324   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
325   * @param cooked  a validated <code>Parent</code>
326   * @throws AccessPoemException  
327   *         if the current <code>AccessToken</code> 
328   *         does not confer write access rights 
329   */
330   public void setParent(Parent cooked)
331       throws AccessPoemException {
332     _getChildTable().
333       getParentColumn().
334         getType().assertValidCooked(cooked);
335     writeLock();
336     if (cooked == null)
337       setParent_unsafe(null);
338     else {
339       cooked.existenceLock();
340       setParent_unsafe(cooked.troid());
341     }
342   }
343 
344 
345  /**
346   * Retrieves the <code>Parent</code> value as a <code>Field</code>
347   * from this <code>Child</code> <code>Persistent</code>.
348   * 
349   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
350   * @throws AccessPoemException 
351   *         if the current <code>AccessToken</code> 
352   *         does not confer write access rights
353   * @return the Integer parent
354   */
355   public Field<Integer> getParentField() throws AccessPoemException {
356     Column<Integer> c = _getChildTable().getParentColumn();
357     return new Field<Integer>((Integer)c.getRaw(this), c);
358   }
359 
360 }
361