1packageorg.apache.jetspeed.om.apps.email;
234import java.math.BigDecimal;
5import java.sql.Connection;
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.Date;
9import java.util.List;
1011import org.apache.commons.lang.ObjectUtils;
12import org.apache.torque.TorqueException;
13import org.apache.torque.om.BaseObject;
14import org.apache.torque.om.ComboKey;
15import org.apache.torque.om.DateKey;
16import org.apache.torque.om.NumberKey;
17import org.apache.torque.om.ObjectKey;
18import org.apache.torque.om.SimpleKey;
19import org.apache.torque.om.StringKey;
20import org.apache.torque.om.Persistent;
21import org.apache.torque.util.Criteria;
22import org.apache.torque.util.Transaction;
232425/***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 be31 * extended all references should be to EmailInbox32 */33publicabstractclassBaseEmailInboxextends BaseObject
34 {
35/*** The Peer class */36privatestaticfinalEmailInboxPeer peer =
37newEmailInboxPeer();
383940/*** The value for the emailInboxId field */41privateint emailInboxId;
4243/*** The value for the messageId field */44private String messageId;
4546/*** The value for the filename field */47private String filename;
4849/*** The value for the attachment field */50private byte[] attachment;
5152/*** The value for the readflag field */53privateint readflag;
545556/***57 * Get the EmailInboxId58 * @return int59 */60publicint getEmailInboxId()
61 {
62return emailInboxId;
63 }
646566/***67 * Set the value of EmailInboxId68 */69publicvoid setEmailInboxId(int v )
70 {
7172if (this.emailInboxId != v)
73 {
74this.emailInboxId = v;
75 setModified(true);
76 }
777879 }
808182/***83 * Get the MessageId84 * @return String85 */86public String getMessageId()
87 {
88return messageId;
89 }
909192/***93 * Set the value of MessageId94 */95publicvoid setMessageId(String v )
96 {
9798if (!ObjectUtils.equals(this.messageId, v))
99 {
100this.messageId = v;
101 setModified(true);
102 }
103104105 }
106107108/***109 * Get the Filename110 * @return String111 */112public String getFilename()
113 {
114return filename;
115 }
116117118/***119 * Set the value of Filename120 */121publicvoid setFilename(String v )
122 {
123124if (!ObjectUtils.equals(this.filename, v))
125 {
126this.filename = v;
127 setModified(true);
128 }
129130131 }
132133134/***135 * Get the Attachment136 * @return byte[]137 */138public byte[] getAttachment()
139 {
140return attachment;
141 }
142143144/***145 * Set the value of Attachment146 */147publicvoid setAttachment(byte[] v )
148 {
149150if (!ObjectUtils.equals(this.attachment, v))
151 {
152this.attachment = v;
153 setModified(true);
154 }
155156157 }
158159160/***161 * Get the Readflag162 * @return int163 */164publicint getReadflag()
165 {
166return readflag;
167 }
168169170/***171 * Set the value of Readflag172 */173publicvoid setReadflag(int v )
174 {
175176if (this.readflag != v)
177 {
178this.readflag = v;
179 setModified(true);
180 }
181182183 }
184185186187188privatestatic List fieldNames = null;
189190/***191 * Generate a list of field names.192 */193publicstaticsynchronized List getFieldNames()
194 {
195if (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 }
205return fieldNames;
206 }
207208/***209 * Retrieves a field from the object by name passed in210 * as a String.211 */212public Object getByName(String name)
213 {
214if (name.equals("EmailInboxId"))
215 {
216returnnew Integer(getEmailInboxId());
217 }
218if (name.equals("MessageId"))
219 {
220return getMessageId();
221 }
222if (name.equals("Filename"))
223 {
224return getFilename();
225 }
226if (name.equals("Attachment"))
227 {
228return getAttachment();
229 }
230if (name.equals("Readflag"))
231 {
232returnnew Integer(getReadflag());
233 }
234returnnull;
235 }
236237/***238 * Retrieves a field from the object by name passed in239 * as a String. The String must be one of the static240 * Strings defined in this Class' Peer.241 */242public Object getByPeerName(String name)
243 {
244if (name.equals(EmailInboxPeer.EMAIL_INBOX_ID ))
245 {
246returnnew Integer(getEmailInboxId());
247 }
248if (name.equals(EmailInboxPeer.MESSAGE_ID ))
249 {
250return getMessageId();
251 }
252if (name.equals(EmailInboxPeer.FILENAME ))
253 {
254return getFilename();
255 }
256if (name.equals(EmailInboxPeer.ATTACHMENT ))
257 {
258return getAttachment();
259 }
260if (name.equals(EmailInboxPeer.READFLAG ))
261 {
262returnnew Integer(getReadflag());
263 }
264returnnull;
265 }
266267/***268 * Retrieves a field from the object by Position as specified269 * in the xml schema. Zero-based.270 */271public Object getByPosition(int pos)
272 {
273if ( pos == 0 )
274 {
275returnnew Integer(getEmailInboxId());
276 }
277if ( pos == 1 )
278 {
279return getMessageId();
280 }
281if ( pos == 2 )
282 {
283return getFilename();
284 }
285if ( pos == 3 )
286 {
287return getAttachment();
288 }
289if ( pos == 4 )
290 {
291returnnew Integer(getReadflag());
292 }
293returnnull;
294 }
295296/***297 * Stores the object in the database. If the object is new,298 * it inserts it; otherwise an update is performed.299 */300publicvoid save() throws Exception
301 {
302 save(EmailInboxPeer.getMapBuilder()
303 .getDatabaseMap().getName());
304 }
305306/***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 is310 * auto-generated conditionally and therefore needs to be311 * in this file instead of in the super class, BaseObject.312 */313publicvoid save(String dbName) throws TorqueException
314 {
315 Connection con = null;
316try317 {
318 con = Transaction.begin(dbName);
319 save(con);
320 Transaction.commit(con);
321 }
322catch(TorqueException e)
323 {
324 Transaction.safeRollback(con);
325throw e;
326 }
327 }
328329/*** flag to prevent endless save loop, if this object is referenced330 by another object which falls in this transaction. */331privateboolean 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 method335 * is meant to be used as part of a transaction, otherwise use336 * the save() method and the connection details will be handled337 * internally338 */339publicvoid save(Connection con) throws TorqueException
340 {
341if (!alreadyInSave)
342 {
343 alreadyInSave = true;
344345346347// If this object has been modified, then save it to the database.348if (isModified())
349 {
350if (isNew())
351 {
352 EmailInboxPeer.doInsert((EmailInbox)this, con);
353 setNew(false);
354 }
355else356 {
357 EmailInboxPeer.doUpdate((EmailInbox)this, con);
358 }
359360if (isCacheOnSave())
361 {
362 EmailInboxManager.putInstance(this);
363 }
364 }
365366 alreadyInSave = false;
367 }
368 }
369370/***371 * Specify whether to cache the object after saving to the db.372 * This method returns false373 */374protectedboolean isCacheOnSave()
375 {
376returntrue;
377 }
378379380/***381 * Set the PrimaryKey using ObjectKey.382 *383 * @param ObjectKey emailInboxId384 */385publicvoid setPrimaryKey(ObjectKey emailInboxId)
386 {
387 setEmailInboxId(((NumberKey)emailInboxId).intValue());
388 }
389390/***391 * Set the PrimaryKey using a String.392 */393publicvoid setPrimaryKey(String key)
394 {
395 setEmailInboxId(Integer.parseInt(key));
396 }
397398399/***400 * returns an id that differentiates this object from others401 * of its class.402 */403public ObjectKey getPrimaryKey()
404 {
405return SimpleKey.keyFor(getEmailInboxId());
406 }
407408409/***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 */414publicEmailInbox copy() throws TorqueException
415 {
416EmailInbox copyObj = newEmailInbox();
417 copyObj.setEmailInboxId(emailInboxId);
418 copyObj.setMessageId(messageId);
419 copyObj.setFilename(filename);
420 copyObj.setAttachment(attachment);
421 copyObj.setReadflag(readflag);
422423 copyObj.setEmailInboxId(0);
424425return copyObj;
426 }
427428/***429 * returns a peer instance associated with this om. Since Peer classes430 * are not to have any instance attributes, this method returns the431 * same instance for all member of this class. The method could therefore432 * be static, but this would prevent one from overriding the behavior.433 */434publicEmailInboxPeer getPeer()
435 {
436return peer;
437 }
438 }