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