1 package org.apache.jetspeed.om.apps.email;
2
3
4 import java.math.BigDecimal;
5 import java.sql.Connection;
6 import java.util.ArrayList;
7 import java.util.Collections;
8 import java.util.Date;
9 import java.util.List;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.torque.TorqueException;
13 import org.apache.torque.om.BaseObject;
14 import org.apache.torque.om.ComboKey;
15 import org.apache.torque.om.DateKey;
16 import org.apache.torque.om.NumberKey;
17 import org.apache.torque.om.ObjectKey;
18 import org.apache.torque.om.SimpleKey;
19 import org.apache.torque.om.StringKey;
20 import org.apache.torque.om.Persistent;
21 import org.apache.torque.util.Criteria;
22 import org.apache.torque.util.Transaction;
23
24
25 /***
26 * This class was autogenerated by Torque on:
27 *
28 * [Thu Apr 22 23:12:36 EDT 2004]
29 *
30 * You should not use this class directly. It should not even be
31 * extended all references should be to EmailInbox
32 */
33 public abstract class BaseEmailInbox extends BaseObject
34 {
35 /*** The Peer class */
36 private static final EmailInboxPeer peer =
37 new EmailInboxPeer();
38
39
40 /*** The value for the emailInboxId field */
41 private int emailInboxId;
42
43 /*** The value for the messageId field */
44 private String messageId;
45
46 /*** The value for the filename field */
47 private String filename;
48
49 /*** The value for the attachment field */
50 private byte[] attachment;
51
52 /*** The value for the readflag field */
53 private int readflag;
54
55
56 /***
57 * Get the EmailInboxId
58 * @return int
59 */
60 public int getEmailInboxId()
61 {
62 return emailInboxId;
63 }
64
65
66 /***
67 * Set the value of EmailInboxId
68 */
69 public void setEmailInboxId(int v )
70 {
71
72 if (this.emailInboxId != v)
73 {
74 this.emailInboxId = v;
75 setModified(true);
76 }
77
78
79 }
80
81
82 /***
83 * Get the MessageId
84 * @return String
85 */
86 public String getMessageId()
87 {
88 return messageId;
89 }
90
91
92 /***
93 * Set the value of MessageId
94 */
95 public void setMessageId(String v )
96 {
97
98 if (!ObjectUtils.equals(this.messageId, v))
99 {
100 this.messageId = v;
101 setModified(true);
102 }
103
104
105 }
106
107
108 /***
109 * Get the Filename
110 * @return String
111 */
112 public String getFilename()
113 {
114 return filename;
115 }
116
117
118 /***
119 * Set the value of Filename
120 */
121 public void setFilename(String v )
122 {
123
124 if (!ObjectUtils.equals(this.filename, v))
125 {
126 this.filename = v;
127 setModified(true);
128 }
129
130
131 }
132
133
134 /***
135 * Get the Attachment
136 * @return byte[]
137 */
138 public byte[] getAttachment()
139 {
140 return attachment;
141 }
142
143
144 /***
145 * Set the value of Attachment
146 */
147 public void setAttachment(byte[] v )
148 {
149
150 if (!ObjectUtils.equals(this.attachment, v))
151 {
152 this.attachment = v;
153 setModified(true);
154 }
155
156
157 }
158
159
160 /***
161 * Get the Readflag
162 * @return int
163 */
164 public int getReadflag()
165 {
166 return readflag;
167 }
168
169
170 /***
171 * Set the value of Readflag
172 */
173 public void setReadflag(int v )
174 {
175
176 if (this.readflag != v)
177 {
178 this.readflag = v;
179 setModified(true);
180 }
181
182
183 }
184
185
186
187
188 private static List fieldNames = null;
189
190 /***
191 * Generate a list of field names.
192 */
193 public static synchronized List getFieldNames()
194 {
195 if (fieldNames == null)
196 {
197 fieldNames = new ArrayList();
198 fieldNames.add("EmailInboxId");
199 fieldNames.add("MessageId");
200 fieldNames.add("Filename");
201 fieldNames.add("Attachment");
202 fieldNames.add("Readflag");
203 fieldNames = Collections.unmodifiableList(fieldNames);
204 }
205 return fieldNames;
206 }
207
208 /***
209 * Retrieves a field from the object by name passed in
210 * as a String.
211 */
212 public Object getByName(String name)
213 {
214 if (name.equals("EmailInboxId"))
215 {
216 return new Integer(getEmailInboxId());
217 }
218 if (name.equals("MessageId"))
219 {
220 return getMessageId();
221 }
222 if (name.equals("Filename"))
223 {
224 return getFilename();
225 }
226 if (name.equals("Attachment"))
227 {
228 return getAttachment();
229 }
230 if (name.equals("Readflag"))
231 {
232 return new Integer(getReadflag());
233 }
234 return null;
235 }
236
237 /***
238 * Retrieves a field from the object by name passed in
239 * as a String. The String must be one of the static
240 * Strings defined in this Class' Peer.
241 */
242 public Object getByPeerName(String name)
243 {
244 if (name.equals(EmailInboxPeer.EMAIL_INBOX_ID ))
245 {
246 return new Integer(getEmailInboxId());
247 }
248 if (name.equals(EmailInboxPeer.MESSAGE_ID ))
249 {
250 return getMessageId();
251 }
252 if (name.equals(EmailInboxPeer.FILENAME ))
253 {
254 return getFilename();
255 }
256 if (name.equals(EmailInboxPeer.ATTACHMENT ))
257 {
258 return getAttachment();
259 }
260 if (name.equals(EmailInboxPeer.READFLAG ))
261 {
262 return new Integer(getReadflag());
263 }
264 return null;
265 }
266
267 /***
268 * Retrieves a field from the object by Position as specified
269 * in the xml schema. Zero-based.
270 */
271 public Object getByPosition(int pos)
272 {
273 if ( pos == 0 )
274 {
275 return new Integer(getEmailInboxId());
276 }
277 if ( pos == 1 )
278 {
279 return getMessageId();
280 }
281 if ( pos == 2 )
282 {
283 return getFilename();
284 }
285 if ( pos == 3 )
286 {
287 return getAttachment();
288 }
289 if ( pos == 4 )
290 {
291 return new Integer(getReadflag());
292 }
293 return null;
294 }
295
296 /***
297 * Stores the object in the database. If the object is new,
298 * it inserts it; otherwise an update is performed.
299 */
300 public void save() throws Exception
301 {
302 save(EmailInboxPeer.getMapBuilder()
303 .getDatabaseMap().getName());
304 }
305
306 /***
307 * Stores the object in the database. If the object is new,
308 * it inserts it; otherwise an update is performed.
309 * Note: this code is here because the method body is
310 * auto-generated conditionally and therefore needs to be
311 * in this file instead of in the super class, BaseObject.
312 */
313 public void save(String dbName) throws TorqueException
314 {
315 Connection con = null;
316 try
317 {
318 con = Transaction.begin(dbName);
319 save(con);
320 Transaction.commit(con);
321 }
322 catch(TorqueException e)
323 {
324 Transaction.safeRollback(con);
325 throw e;
326 }
327 }
328
329 /*** flag to prevent endless save loop, if this object is referenced
330 by another object which falls in this transaction. */
331 private boolean alreadyInSave = false;
332 /***
333 * Stores the object in the database. If the object is new,
334 * it inserts it; otherwise an update is performed. This method
335 * is meant to be used as part of a transaction, otherwise use
336 * the save() method and the connection details will be handled
337 * internally
338 */
339 public void save(Connection con) throws TorqueException
340 {
341 if (!alreadyInSave)
342 {
343 alreadyInSave = true;
344
345
346
347
348 if (isModified())
349 {
350 if (isNew())
351 {
352 EmailInboxPeer.doInsert((EmailInbox)this, con);
353 setNew(false);
354 }
355 else
356 {
357 EmailInboxPeer.doUpdate((EmailInbox)this, con);
358 }
359
360 if (isCacheOnSave())
361 {
362 EmailInboxManager.putInstance(this);
363 }
364 }
365
366 alreadyInSave = false;
367 }
368 }
369
370 /***
371 * Specify whether to cache the object after saving to the db.
372 * This method returns false
373 */
374 protected boolean isCacheOnSave()
375 {
376 return true;
377 }
378
379
380 /***
381 * Set the PrimaryKey using ObjectKey.
382 *
383 * @param ObjectKey emailInboxId
384 */
385 public void setPrimaryKey(ObjectKey emailInboxId)
386 {
387 setEmailInboxId(((NumberKey)emailInboxId).intValue());
388 }
389
390 /***
391 * Set the PrimaryKey using a String.
392 */
393 public void setPrimaryKey(String key)
394 {
395 setEmailInboxId(Integer.parseInt(key));
396 }
397
398
399 /***
400 * returns an id that differentiates this object from others
401 * of its class.
402 */
403 public ObjectKey getPrimaryKey()
404 {
405 return SimpleKey.keyFor(getEmailInboxId());
406 }
407
408
409 /***
410 * Makes a copy of this object.
411 * It creates a new object filling in the simple attributes.
412 * It then fills all the association collections.
413 */
414 public EmailInbox copy() throws TorqueException
415 {
416 EmailInbox copyObj = new EmailInbox();
417 copyObj.setEmailInboxId(emailInboxId);
418 copyObj.setMessageId(messageId);
419 copyObj.setFilename(filename);
420 copyObj.setAttachment(attachment);
421 copyObj.setReadflag(readflag);
422
423 copyObj.setEmailInboxId(0);
424
425 return copyObj;
426 }
427
428 /***
429 * returns a peer instance associated with this om. Since Peer classes
430 * are not to have any instance attributes, this method returns the
431 * same instance for all member of this class. The method could therefore
432 * be static, but this would prevent one from overriding the behavior.
433 */
434 public EmailInboxPeer getPeer()
435 {
436 return peer;
437 }
438 }