View Javadoc
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 java.util.Collections;
7   import java.util.Enumeration;
8   import java.util.List;
9   import org.melati.example.contacts.Category;
10  import org.melati.example.contacts.CategoryTable;
11  import org.melati.example.contacts.ContactCategory;
12  import org.melati.example.contacts.ContactsDatabaseTables;
13  import org.melati.poem.AccessPoemException;
14  import org.melati.poem.CachedSelection;
15  import org.melati.poem.Column;
16  import org.melati.poem.Field;
17  import org.melati.poem.JdbcPersistent;
18  import org.melati.poem.ValidationPoemException;
19  import org.melati.poem.util.EmptyEnumeration;
20  
21  
22  /**
23   * Melati POEM generated abstract base class for a <code>Persistent</code> 
24   * <code>Category</code> Object.
25   *
26   * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
27   */
28  public abstract class CategoryBase extends JdbcPersistent {
29  
30  
31   /**
32    * Retrieves the Database object.
33    * 
34    * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
35    * @return the database
36    */
37    public ContactsDatabaseTables getContactsDatabaseTables() {
38      return (ContactsDatabaseTables)getDatabase();
39    }
40  
41  
42   /**
43    * Retrieves the  <code>CategoryTable</code> table 
44    * which this <code>Persistent</code> is from.
45    * 
46    * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
47    * @return the CategoryTable
48    */
49    @SuppressWarnings("unchecked")
50    public CategoryTable<Category> getCategoryTable() {
51      return (CategoryTable<Category>)getTable();
52    }
53  
54    @SuppressWarnings("unchecked")
55    private CategoryTable<Category> _getCategoryTable() {
56      return (CategoryTable<Category>)getTable();
57    }
58  
59    // Fields in this table 
60   /**
61    * id 
62    */
63    protected Integer id;
64   /**
65    * name - Category Name 
66    */
67    protected String name;
68  
69  
70   /**
71    * Retrieves the <code>Id</code> value, without locking, 
72    * for this <code>Category</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 Category <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>Category</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>Category</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>Category</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     _getCategoryTable().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>Category</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>Category</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 = _getCategoryTable().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>Category</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 Category <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>Category</code> <code>Persistent</code>.
193   * Field description: 
194   *   Category Name 
195   * 
196   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
197   * @throws AccessPoemException 
198   *         if the current <code>AccessToken</code> 
199   *         does not confer write access rights 
200   * @return the value of the field <code>Name</code> for this 
201   *         <code>Category</code> <code>Persistent</code>  
202   */
203 
204   public String getName()
205       throws AccessPoemException {
206     readLock();
207     return getName_unsafe();
208   }
209 
210 
211  /**
212   * Sets the <code>Name</code> value, with checking, for this 
213   * <code>Category</code> <code>Persistent</code>.
214   * Field description: 
215   *   Category Name 
216   * 
217   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
218   * @param cooked  a validated <code>int</code> 
219   * @throws AccessPoemException 
220   *         if the current <code>AccessToken</code> 
221   *         does not confer write access rights
222   * @throws ValidationPoemException 
223   *         if the value is not valid
224   */
225   public void setName(String cooked)
226       throws AccessPoemException, ValidationPoemException {
227     _getCategoryTable().getNameColumn().
228       getType().assertValidCooked(cooked);
229     writeLock();
230     setName_unsafe(cooked);
231   }
232 
233 
234  /**
235   * Retrieves the <code>Name</code> value as a <code>Field</code>
236   * from this <code>Category</code> <code>Persistent</code>.
237   * 
238   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
239   * @throws AccessPoemException 
240   *         if the current <code>AccessToken</code> 
241   *         does not confer write access rights
242   * @return the String name
243   */
244   public Field<String> getNameField() throws AccessPoemException {
245     Column<String> c = _getCategoryTable().getNameColumn();
246     return new Field<String>((String)c.getRaw(this), c);
247   }
248 
249   private CachedSelection<ContactCategory> categoryContactCategorys = null;
250   /** References to this Category in the ContactCategory table via its category field.*/
251   @SuppressWarnings("unchecked")
252   public Enumeration<ContactCategory> getCategoryContactCategorys() {
253     if (getTroid() == null)
254       return new EmptyEnumeration<ContactCategory>();
255     else {
256       if (categoryContactCategorys == null)
257         categoryContactCategorys =
258           getContactsDatabaseTables().getContactCategoryTable().getCategoryColumn().cachedSelectionWhereEq(getTroid());
259       return categoryContactCategorys.objects();
260     }
261   }
262 
263 
264   /** References to this Category in the ContactCategory table via its category field, as a List.*/
265   public List<ContactCategory> getCategoryContactCategoryList() {
266     return Collections.list(getCategoryContactCategorys());
267   }
268 
269 
270 
271 }
272