KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > om > BaseInboxAttachment


1 package org.campware.cream.om;
2
3
4 import java.math.BigDecimal JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Collections JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.turbine.om.Retrievable;
13 import org.apache.torque.TorqueException;
14 import org.apache.torque.om.BaseObject;
15 import org.apache.torque.om.ComboKey;
16 import org.apache.torque.om.DateKey;
17 import org.apache.torque.om.NumberKey;
18 import org.apache.torque.om.ObjectKey;
19 import org.apache.torque.om.SimpleKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.Persistent;
22 import org.apache.torque.util.Criteria;
23 import org.apache.torque.util.Transaction;
24
25   
26   
27 /**
28  * This class was autogenerated by Torque on:
29  *
30  * [Wed May 04 09:10:56 CEST 2005]
31  *
32  * You should not use this class directly. It should not even be
33  * extended all references should be to InboxAttachment
34  */

35 public abstract class BaseInboxAttachment extends BaseObject
36     implements org.apache.turbine.om.Retrievable
37 {
38     /** The Peer class */
39     private static final InboxAttachmentPeer peer =
40         new InboxAttachmentPeer();
41
42         
43     /** The value for the inboxAttachmentId field */
44     private int inboxAttachmentId;
45                                           
46     /** The value for the inboxEventId field */
47     private int inboxEventId = 1000;
48       
49     /** The value for the contentType field */
50     private String JavaDoc contentType;
51       
52     /** The value for the contentDisposition field */
53     private String JavaDoc contentDisposition;
54       
55     /** The value for the contentId field */
56     private String JavaDoc contentId;
57       
58     /** The value for the fileName field */
59     private String JavaDoc fileName;
60       
61     /** The value for the content field */
62     private String JavaDoc content;
63   
64     
65     /**
66      * Get the InboxAttachmentId
67      *
68      * @return int
69      */

70     public int getInboxAttachmentId()
71     {
72         return inboxAttachmentId;
73     }
74
75                         
76     /**
77      * Set the value of InboxAttachmentId
78      *
79      * @param v new value
80      */

81     public void setInboxAttachmentId(int v)
82     {
83     
84                   if (this.inboxAttachmentId != v)
85               {
86             this.inboxAttachmentId = v;
87             setModified(true);
88         }
89     
90           
91               }
92   
93     /**
94      * Get the InboxEventId
95      *
96      * @return int
97      */

98     public int getInboxEventId()
99     {
100         return inboxEventId;
101     }
102
103                               
104     /**
105      * Set the value of InboxEventId
106      *
107      * @param v new value
108      */

109     public void setInboxEventId(int v) throws TorqueException
110     {
111     
112                   if (this.inboxEventId != v)
113               {
114             this.inboxEventId = v;
115             setModified(true);
116         }
117     
118                           
119                 if (aInboxEvent != null && !(aInboxEvent.getInboxEventId() == v))
120                 {
121             aInboxEvent = null;
122         }
123       
124               }
125   
126     /**
127      * Get the ContentType
128      *
129      * @return String
130      */

131     public String JavaDoc getContentType()
132     {
133         return contentType;
134     }
135
136                         
137     /**
138      * Set the value of ContentType
139      *
140      * @param v new value
141      */

142     public void setContentType(String JavaDoc v)
143     {
144     
145                   if (!ObjectUtils.equals(this.contentType, v))
146               {
147             this.contentType = v;
148             setModified(true);
149         }
150     
151           
152               }
153   
154     /**
155      * Get the ContentDisposition
156      *
157      * @return String
158      */

159     public String JavaDoc getContentDisposition()
160     {
161         return contentDisposition;
162     }
163
164                         
165     /**
166      * Set the value of ContentDisposition
167      *
168      * @param v new value
169      */

170     public void setContentDisposition(String JavaDoc v)
171     {
172     
173                   if (!ObjectUtils.equals(this.contentDisposition, v))
174               {
175             this.contentDisposition = v;
176             setModified(true);
177         }
178     
179           
180               }
181   
182     /**
183      * Get the ContentId
184      *
185      * @return String
186      */

187     public String JavaDoc getContentId()
188     {
189         return contentId;
190     }
191
192                         
193     /**
194      * Set the value of ContentId
195      *
196      * @param v new value
197      */

198     public void setContentId(String JavaDoc v)
199     {
200     
201                   if (!ObjectUtils.equals(this.contentId, v))
202               {
203             this.contentId = v;
204             setModified(true);
205         }
206     
207           
208               }
209   
210     /**
211      * Get the FileName
212      *
213      * @return String
214      */

215     public String JavaDoc getFileName()
216     {
217         return fileName;
218     }
219
220                         
221     /**
222      * Set the value of FileName
223      *
224      * @param v new value
225      */

226     public void setFileName(String JavaDoc v)
227     {
228     
229                   if (!ObjectUtils.equals(this.fileName, v))
230               {
231             this.fileName = v;
232             setModified(true);
233         }
234     
235           
236               }
237   
238     /**
239      * Get the Content
240      *
241      * @return String
242      */

243     public String JavaDoc getContent()
244     {
245         return content;
246     }
247
248                         
249     /**
250      * Set the value of Content
251      *
252      * @param v new value
253      */

254     public void setContent(String JavaDoc v)
255     {
256     
257                   if (!ObjectUtils.equals(this.content, v))
258               {
259             this.content = v;
260             setModified(true);
261         }
262     
263           
264               }
265   
266       
267     
268                   
269     
270         private InboxEvent aInboxEvent;
271
272     /**
273      * Declares an association between this object and a InboxEvent object
274      *
275      * @param v InboxEvent
276      * @throws TorqueException
277      */

278     public void setInboxEvent(InboxEvent v) throws TorqueException
279     {
280             if (v == null)
281         {
282                           setInboxEventId( 1000);
283               }
284         else
285         {
286             setInboxEventId(v.getInboxEventId());
287         }
288             aInboxEvent = v;
289     }
290
291                                             
292     /**
293      * Get the associated InboxEvent object
294      *
295      * @return the associated InboxEvent object
296      * @throws TorqueException
297      */

298     public InboxEvent getInboxEvent() throws TorqueException
299     {
300         if (aInboxEvent == null && (this.inboxEventId != 0))
301         {
302                           aInboxEvent = InboxEventPeer.retrieveByPK(SimpleKey.keyFor(this.inboxEventId));
303               
304             /* The following can be used instead of the line above to
305                guarantee the related object contains a reference
306                to this object, but this level of coupling
307                may be undesirable in many circumstances.
308                As it can lead to a db query with many results that may
309                never be used.
310                InboxEvent obj = InboxEventPeer.retrieveByPK(this.inboxEventId);
311                obj.addInboxAttachments(this);
312             */

313         }
314         return aInboxEvent;
315     }
316
317     /**
318      * Provides convenient way to set a relationship based on a
319      * ObjectKey, for example
320      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
321      *
322          */

323     public void setInboxEventKey(ObjectKey key) throws TorqueException
324     {
325       
326                         setInboxEventId(((NumberKey) key).intValue());
327                   }
328        
329                 
330     private static List JavaDoc fieldNames = null;
331
332     /**
333      * Generate a list of field names.
334      *
335      * @return a list of field names
336      */

337     public static synchronized List JavaDoc getFieldNames()
338     {
339         if (fieldNames == null)
340         {
341             fieldNames = new ArrayList JavaDoc();
342               fieldNames.add("InboxAttachmentId");
343               fieldNames.add("InboxEventId");
344               fieldNames.add("ContentType");
345               fieldNames.add("ContentDisposition");
346               fieldNames.add("ContentId");
347               fieldNames.add("FileName");
348               fieldNames.add("Content");
349               fieldNames = Collections.unmodifiableList(fieldNames);
350         }
351         return fieldNames;
352     }
353
354     /**
355      * Retrieves a field from the object by name passed in as a String.
356      *
357      * @param name field name
358      * @return value
359      */

360     public Object JavaDoc getByName(String JavaDoc name)
361     {
362           if (name.equals("InboxAttachmentId"))
363         {
364                 return new Integer JavaDoc(getInboxAttachmentId());
365             }
366           if (name.equals("InboxEventId"))
367         {
368                 return new Integer JavaDoc(getInboxEventId());
369             }
370           if (name.equals("ContentType"))
371         {
372                 return getContentType();
373             }
374           if (name.equals("ContentDisposition"))
375         {
376                 return getContentDisposition();
377             }
378           if (name.equals("ContentId"))
379         {
380                 return getContentId();
381             }
382           if (name.equals("FileName"))
383         {
384                 return getFileName();
385             }
386           if (name.equals("Content"))
387         {
388                 return getContent();
389             }
390           return null;
391     }
392     
393     /**
394      * Retrieves a field from the object by name passed in
395      * as a String. The String must be one of the static
396      * Strings defined in this Class' Peer.
397      *
398      * @param name peer name
399      * @return value
400      */

401     public Object JavaDoc getByPeerName(String JavaDoc name)
402     {
403           if (name.equals(InboxAttachmentPeer.INBOX_ATTACHMENT_ID))
404         {
405                 return new Integer JavaDoc(getInboxAttachmentId());
406             }
407           if (name.equals(InboxAttachmentPeer.INBOX_EVENT_ID))
408         {
409                 return new Integer JavaDoc(getInboxEventId());
410             }
411           if (name.equals(InboxAttachmentPeer.CONTENT_TYPE))
412         {
413                 return getContentType();
414             }
415           if (name.equals(InboxAttachmentPeer.CONTENT_DISPOSITION))
416         {
417                 return getContentDisposition();
418             }
419           if (name.equals(InboxAttachmentPeer.CONTENT_ID))
420         {
421                 return getContentId();
422             }
423           if (name.equals(InboxAttachmentPeer.FILE_NAME))
424         {
425                 return getFileName();
426             }
427           if (name.equals(InboxAttachmentPeer.CONTENT))
428         {
429                 return getContent();
430             }
431           return null;
432     }
433
434     /**
435      * Retrieves a field from the object by Position as specified
436      * in the xml schema. Zero-based.
437      *
438      * @param pos position in xml schema
439      * @return value
440      */

441     public Object JavaDoc getByPosition(int pos)
442     {
443             if (pos == 0)
444         {
445                 return new Integer JavaDoc(getInboxAttachmentId());
446             }
447               if (pos == 1)
448         {
449                 return new Integer JavaDoc(getInboxEventId());
450             }
451               if (pos == 2)
452         {
453                 return getContentType();
454             }
455               if (pos == 3)
456         {
457                 return getContentDisposition();
458             }
459               if (pos == 4)
460         {
461                 return getContentId();
462             }
463               if (pos == 5)
464         {
465                 return getFileName();
466             }
467               if (pos == 6)
468         {
469                 return getContent();
470             }
471               return null;
472     }
473      
474     /**
475      * Stores the object in the database. If the object is new,
476      * it inserts it; otherwise an update is performed.
477      *
478      * @throws Exception
479      */

480     public void save() throws Exception JavaDoc
481     {
482           save(InboxAttachmentPeer.getMapBuilder()
483                 .getDatabaseMap().getName());
484       }
485
486     /**
487      * Stores the object in the database. If the object is new,
488      * it inserts it; otherwise an update is performed.
489        * Note: this code is here because the method body is
490      * auto-generated conditionally and therefore needs to be
491      * in this file instead of in the super class, BaseObject.
492        *
493      * @param dbName
494      * @throws TorqueException
495      */

496     public void save(String JavaDoc dbName) throws TorqueException
497     {
498         Connection JavaDoc con = null;
499           try
500         {
501             con = Transaction.begin(dbName);
502             save(con);
503             Transaction.commit(con);
504         }
505         catch(TorqueException e)
506         {
507             Transaction.safeRollback(con);
508             throw e;
509         }
510       }
511
512       /** flag to prevent endless save loop, if this object is referenced
513         by another object which falls in this transaction. */

514     private boolean alreadyInSave = false;
515       /**
516      * Stores the object in the database. If the object is new,
517      * it inserts it; otherwise an update is performed. This method
518      * is meant to be used as part of a transaction, otherwise use
519      * the save() method and the connection details will be handled
520      * internally
521      *
522      * @param con
523      * @throws TorqueException
524      */

525     public void save(Connection JavaDoc con) throws TorqueException
526     {
527           if (!alreadyInSave)
528         {
529             alreadyInSave = true;
530
531
532   
533             // If this object has been modified, then save it to the database.
534
if (isModified())
535             {
536                 if (isNew())
537                 {
538                     InboxAttachmentPeer.doInsert((InboxAttachment) this, con);
539                     setNew(false);
540                 }
541                 else
542                 {
543                     InboxAttachmentPeer.doUpdate((InboxAttachment) this, con);
544                 }
545             }
546
547                       alreadyInSave = false;
548         }
549       }
550
551                   
552       /**
553      * Set the PrimaryKey using ObjectKey.
554      *
555      * @param key inboxAttachmentId ObjectKey
556      */

557     public void setPrimaryKey(ObjectKey key)
558         
559     {
560             setInboxAttachmentId(((NumberKey) key).intValue());
561         }
562
563     /**
564      * Set the PrimaryKey using a String.
565      *
566      * @param key
567      */

568     public void setPrimaryKey(String JavaDoc key)
569     {
570             setInboxAttachmentId(Integer.parseInt(key));
571         }
572
573   
574     /**
575      * returns an id that differentiates this object from others
576      * of its class.
577      */

578     public ObjectKey getPrimaryKey()
579     {
580           return SimpleKey.keyFor(getInboxAttachmentId());
581       }
582  
583     /**
584      * get an id that differentiates this object from others
585      * of its class.
586      */

587     public String JavaDoc getQueryKey()
588     {
589         if (getPrimaryKey() == null)
590         {
591             return "";
592         }
593         else
594         {
595             return getPrimaryKey().toString();
596         }
597     }
598
599     /**
600      * set an id that differentiates this object from others
601      * of its class.
602      */

603     public void setQueryKey(String JavaDoc key)
604         throws TorqueException
605     {
606         setPrimaryKey(key);
607     }
608
609     /**
610      * Makes a copy of this object.
611      * It creates a new object filling in the simple attributes.
612        * It then fills all the association collections and sets the
613      * related objects to isNew=true.
614        */

615       public InboxAttachment copy() throws TorqueException
616     {
617         return copyInto(new InboxAttachment());
618     }
619   
620     protected InboxAttachment copyInto(InboxAttachment copyObj) throws TorqueException
621     {
622           copyObj.setInboxAttachmentId(inboxAttachmentId);
623           copyObj.setInboxEventId(inboxEventId);
624           copyObj.setContentType(contentType);
625           copyObj.setContentDisposition(contentDisposition);
626           copyObj.setContentId(contentId);
627           copyObj.setFileName(fileName);
628           copyObj.setContent(content);
629   
630                             copyObj.setInboxAttachmentId( 0);
631                                                 
632                 return copyObj;
633     }
634
635     /**
636      * returns a peer instance associated with this om. Since Peer classes
637      * are not to have any instance attributes, this method returns the
638      * same instance for all member of this class. The method could therefore
639      * be static, but this would prevent one from overriding the behavior.
640      */

641     public InboxAttachmentPeer getPeer()
642     {
643         return peer;
644     }
645
646     public String JavaDoc toString()
647     {
648         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
649         str.append("InboxAttachment:\n");
650         str.append("InboxAttachmentId = ")
651                .append(getInboxAttachmentId())
652              .append("\n");
653         str.append("InboxEventId = ")
654                .append(getInboxEventId())
655              .append("\n");
656         str.append("ContentType = ")
657                .append(getContentType())
658              .append("\n");
659         str.append("ContentDisposition = ")
660                .append(getContentDisposition())
661              .append("\n");
662         str.append("ContentId = ")
663                .append(getContentId())
664              .append("\n");
665         str.append("FileName = ")
666                .append(getFileName())
667              .append("\n");
668         str.append("Content = ")
669                .append(getContent())
670              .append("\n");
671         return(str.toString());
672     }
673 }
674
Popular Tags