KickJava   Java API By Example, From Geeks To Geeks.

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


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  * This class was autogenerated by Torque on:
28  *
29  * [Wed May 04 09:10:56 CEST 2005]
30  *
31  * You should not use this class directly. It should not even be
32  * extended all references should be to TurbineScheduledJob
33  */

34 public abstract class BaseTurbineScheduledJob extends BaseObject
35     implements org.apache.turbine.om.Retrievable
36 {
37     /** The Peer class */
38     private static final TurbineScheduledJobPeer peer =
39         new TurbineScheduledJobPeer();
40
41         
42     /** The value for the jobId field */
43     private int jobId;
44                                           
45     /** The value for the second field */
46     private int second = -1;
47                                           
48     /** The value for the minute field */
49     private int minute = -1;
50                                           
51     /** The value for the hour field */
52     private int hour = -1;
53                                           
54     /** The value for the weekDay field */
55     private int weekDay = -1;
56                                           
57     /** The value for the dayOfMonth field */
58     private int dayOfMonth = -1;
59       
60     /** The value for the task field */
61     private String JavaDoc task;
62       
63     /** The value for the email field */
64     private String JavaDoc email;
65       
66     /** The value for the property field */
67     private byte[] property;
68   
69     
70     /**
71      * Get the JobId
72      *
73      * @return int
74      */

75     public int getJobId()
76     {
77         return jobId;
78     }
79
80                         
81     /**
82      * Set the value of JobId
83      *
84      * @param v new value
85      */

86     public void setJobId(int v)
87     {
88     
89                   if (this.jobId != v)
90               {
91             this.jobId = v;
92             setModified(true);
93         }
94     
95           
96               }
97   
98     /**
99      * Get the Second
100      *
101      * @return int
102      */

103     public int getSecond()
104     {
105         return second;
106     }
107
108                         
109     /**
110      * Set the value of Second
111      *
112      * @param v new value
113      */

114     public void setSecond(int v)
115     {
116     
117                   if (this.second != v)
118               {
119             this.second = v;
120             setModified(true);
121         }
122     
123           
124               }
125   
126     /**
127      * Get the Minute
128      *
129      * @return int
130      */

131     public int getMinute()
132     {
133         return minute;
134     }
135
136                         
137     /**
138      * Set the value of Minute
139      *
140      * @param v new value
141      */

142     public void setMinute(int v)
143     {
144     
145                   if (this.minute != v)
146               {
147             this.minute = v;
148             setModified(true);
149         }
150     
151           
152               }
153   
154     /**
155      * Get the Hour
156      *
157      * @return int
158      */

159     public int getHour()
160     {
161         return hour;
162     }
163
164                         
165     /**
166      * Set the value of Hour
167      *
168      * @param v new value
169      */

170     public void setHour(int v)
171     {
172     
173                   if (this.hour != v)
174               {
175             this.hour = v;
176             setModified(true);
177         }
178     
179           
180               }
181   
182     /**
183      * Get the WeekDay
184      *
185      * @return int
186      */

187     public int getWeekDay()
188     {
189         return weekDay;
190     }
191
192                         
193     /**
194      * Set the value of WeekDay
195      *
196      * @param v new value
197      */

198     public void setWeekDay(int v)
199     {
200     
201                   if (this.weekDay != v)
202               {
203             this.weekDay = v;
204             setModified(true);
205         }
206     
207           
208               }
209   
210     /**
211      * Get the DayOfMonth
212      *
213      * @return int
214      */

215     public int getDayOfMonth()
216     {
217         return dayOfMonth;
218     }
219
220                         
221     /**
222      * Set the value of DayOfMonth
223      *
224      * @param v new value
225      */

226     public void setDayOfMonth(int v)
227     {
228     
229                   if (this.dayOfMonth != v)
230               {
231             this.dayOfMonth = v;
232             setModified(true);
233         }
234     
235           
236               }
237   
238     /**
239      * Get the Task
240      *
241      * @return String
242      */

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

254     public void setTask(String JavaDoc v)
255     {
256     
257                   if (!ObjectUtils.equals(this.task, v))
258               {
259             this.task = v;
260             setModified(true);
261         }
262     
263           
264               }
265   
266     /**
267      * Get the Email
268      *
269      * @return String
270      */

271     public String JavaDoc getEmail()
272     {
273         return email;
274     }
275
276                         
277     /**
278      * Set the value of Email
279      *
280      * @param v new value
281      */

282     public void setEmail(String JavaDoc v)
283     {
284     
285                   if (!ObjectUtils.equals(this.email, v))
286               {
287             this.email = v;
288             setModified(true);
289         }
290     
291           
292               }
293   
294     /**
295      * Get the Property
296      *
297      * @return byte[]
298      */

299     public byte[] getProperty()
300     {
301         return property;
302     }
303
304                         
305     /**
306      * Set the value of Property
307      *
308      * @param v new value
309      */

310     public void setProperty(byte[] v)
311     {
312     
313                   if (!ObjectUtils.equals(this.property, v))
314               {
315             this.property = v;
316             setModified(true);
317         }
318     
319           
320               }
321   
322          
323                 
324     private static List JavaDoc fieldNames = null;
325
326     /**
327      * Generate a list of field names.
328      *
329      * @return a list of field names
330      */

331     public static synchronized List JavaDoc getFieldNames()
332     {
333         if (fieldNames == null)
334         {
335             fieldNames = new ArrayList JavaDoc();
336               fieldNames.add("JobId");
337               fieldNames.add("Second");
338               fieldNames.add("Minute");
339               fieldNames.add("Hour");
340               fieldNames.add("WeekDay");
341               fieldNames.add("DayOfMonth");
342               fieldNames.add("Task");
343               fieldNames.add("Email");
344               fieldNames.add("Property");
345               fieldNames = Collections.unmodifiableList(fieldNames);
346         }
347         return fieldNames;
348     }
349
350     /**
351      * Retrieves a field from the object by name passed in as a String.
352      *
353      * @param name field name
354      * @return value
355      */

356     public Object JavaDoc getByName(String JavaDoc name)
357     {
358           if (name.equals("JobId"))
359         {
360                 return new Integer JavaDoc(getJobId());
361             }
362           if (name.equals("Second"))
363         {
364                 return new Integer JavaDoc(getSecond());
365             }
366           if (name.equals("Minute"))
367         {
368                 return new Integer JavaDoc(getMinute());
369             }
370           if (name.equals("Hour"))
371         {
372                 return new Integer JavaDoc(getHour());
373             }
374           if (name.equals("WeekDay"))
375         {
376                 return new Integer JavaDoc(getWeekDay());
377             }
378           if (name.equals("DayOfMonth"))
379         {
380                 return new Integer JavaDoc(getDayOfMonth());
381             }
382           if (name.equals("Task"))
383         {
384                 return getTask();
385             }
386           if (name.equals("Email"))
387         {
388                 return getEmail();
389             }
390           if (name.equals("Property"))
391         {
392                 return getProperty();
393             }
394           return null;
395     }
396     
397     /**
398      * Retrieves a field from the object by name passed in
399      * as a String. The String must be one of the static
400      * Strings defined in this Class' Peer.
401      *
402      * @param name peer name
403      * @return value
404      */

405     public Object JavaDoc getByPeerName(String JavaDoc name)
406     {
407           if (name.equals(TurbineScheduledJobPeer.JOB_ID))
408         {
409                 return new Integer JavaDoc(getJobId());
410             }
411           if (name.equals(TurbineScheduledJobPeer.SECOND))
412         {
413                 return new Integer JavaDoc(getSecond());
414             }
415           if (name.equals(TurbineScheduledJobPeer.MINUTE))
416         {
417                 return new Integer JavaDoc(getMinute());
418             }
419           if (name.equals(TurbineScheduledJobPeer.HOUR))
420         {
421                 return new Integer JavaDoc(getHour());
422             }
423           if (name.equals(TurbineScheduledJobPeer.WEEK_DAY))
424         {
425                 return new Integer JavaDoc(getWeekDay());
426             }
427           if (name.equals(TurbineScheduledJobPeer.DAY_OF_MONTH))
428         {
429                 return new Integer JavaDoc(getDayOfMonth());
430             }
431           if (name.equals(TurbineScheduledJobPeer.TASK))
432         {
433                 return getTask();
434             }
435           if (name.equals(TurbineScheduledJobPeer.EMAIL))
436         {
437                 return getEmail();
438             }
439           if (name.equals(TurbineScheduledJobPeer.PROPERTY))
440         {
441                 return getProperty();
442             }
443           return null;
444     }
445
446     /**
447      * Retrieves a field from the object by Position as specified
448      * in the xml schema. Zero-based.
449      *
450      * @param pos position in xml schema
451      * @return value
452      */

453     public Object JavaDoc getByPosition(int pos)
454     {
455             if (pos == 0)
456         {
457                 return new Integer JavaDoc(getJobId());
458             }
459               if (pos == 1)
460         {
461                 return new Integer JavaDoc(getSecond());
462             }
463               if (pos == 2)
464         {
465                 return new Integer JavaDoc(getMinute());
466             }
467               if (pos == 3)
468         {
469                 return new Integer JavaDoc(getHour());
470             }
471               if (pos == 4)
472         {
473                 return new Integer JavaDoc(getWeekDay());
474             }
475               if (pos == 5)
476         {
477                 return new Integer JavaDoc(getDayOfMonth());
478             }
479               if (pos == 6)
480         {
481                 return getTask();
482             }
483               if (pos == 7)
484         {
485                 return getEmail();
486             }
487               if (pos == 8)
488         {
489                 return getProperty();
490             }
491               return null;
492     }
493      
494     /**
495      * Stores the object in the database. If the object is new,
496      * it inserts it; otherwise an update is performed.
497      *
498      * @throws Exception
499      */

500     public void save() throws Exception JavaDoc
501     {
502           save(TurbineScheduledJobPeer.getMapBuilder()
503                 .getDatabaseMap().getName());
504       }
505
506     /**
507      * Stores the object in the database. If the object is new,
508      * it inserts it; otherwise an update is performed.
509        * Note: this code is here because the method body is
510      * auto-generated conditionally and therefore needs to be
511      * in this file instead of in the super class, BaseObject.
512        *
513      * @param dbName
514      * @throws TorqueException
515      */

516     public void save(String JavaDoc dbName) throws TorqueException
517     {
518         Connection JavaDoc con = null;
519           try
520         {
521             con = Transaction.begin(dbName);
522             save(con);
523             Transaction.commit(con);
524         }
525         catch(TorqueException e)
526         {
527             Transaction.safeRollback(con);
528             throw e;
529         }
530       }
531
532       /** flag to prevent endless save loop, if this object is referenced
533         by another object which falls in this transaction. */

534     private boolean alreadyInSave = false;
535       /**
536      * Stores the object in the database. If the object is new,
537      * it inserts it; otherwise an update is performed. This method
538      * is meant to be used as part of a transaction, otherwise use
539      * the save() method and the connection details will be handled
540      * internally
541      *
542      * @param con
543      * @throws TorqueException
544      */

545     public void save(Connection JavaDoc con) throws TorqueException
546     {
547           if (!alreadyInSave)
548         {
549             alreadyInSave = true;
550
551
552   
553             // If this object has been modified, then save it to the database.
554
if (isModified())
555             {
556                 if (isNew())
557                 {
558                     TurbineScheduledJobPeer.doInsert((TurbineScheduledJob) this, con);
559                     setNew(false);
560                 }
561                 else
562                 {
563                     TurbineScheduledJobPeer.doUpdate((TurbineScheduledJob) this, con);
564                 }
565             }
566
567                       alreadyInSave = false;
568         }
569       }
570
571                   
572       /**
573      * Set the PrimaryKey using ObjectKey.
574      *
575      * @param key jobId ObjectKey
576      */

577     public void setPrimaryKey(ObjectKey key)
578         
579     {
580             setJobId(((NumberKey) key).intValue());
581         }
582
583     /**
584      * Set the PrimaryKey using a String.
585      *
586      * @param key
587      */

588     public void setPrimaryKey(String JavaDoc key)
589     {
590             setJobId(Integer.parseInt(key));
591         }
592
593   
594     /**
595      * returns an id that differentiates this object from others
596      * of its class.
597      */

598     public ObjectKey getPrimaryKey()
599     {
600           return SimpleKey.keyFor(getJobId());
601       }
602  
603     /**
604      * get an id that differentiates this object from others
605      * of its class.
606      */

607     public String JavaDoc getQueryKey()
608     {
609         if (getPrimaryKey() == null)
610         {
611             return "";
612         }
613         else
614         {
615             return getPrimaryKey().toString();
616         }
617     }
618
619     /**
620      * set an id that differentiates this object from others
621      * of its class.
622      */

623     public void setQueryKey(String JavaDoc key)
624         throws TorqueException
625     {
626         setPrimaryKey(key);
627     }
628
629     /**
630      * Makes a copy of this object.
631      * It creates a new object filling in the simple attributes.
632        * It then fills all the association collections and sets the
633      * related objects to isNew=true.
634        */

635       public TurbineScheduledJob copy() throws TorqueException
636     {
637         return copyInto(new TurbineScheduledJob());
638     }
639   
640     protected TurbineScheduledJob copyInto(TurbineScheduledJob copyObj) throws TorqueException
641     {
642           copyObj.setJobId(jobId);
643           copyObj.setSecond(second);
644           copyObj.setMinute(minute);
645           copyObj.setHour(hour);
646           copyObj.setWeekDay(weekDay);
647           copyObj.setDayOfMonth(dayOfMonth);
648           copyObj.setTask(task);
649           copyObj.setEmail(email);
650           copyObj.setProperty(property);
651   
652                             copyObj.setJobId( 0);
653                                                             
654                 return copyObj;
655     }
656
657     /**
658      * returns a peer instance associated with this om. Since Peer classes
659      * are not to have any instance attributes, this method returns the
660      * same instance for all member of this class. The method could therefore
661      * be static, but this would prevent one from overriding the behavior.
662      */

663     public TurbineScheduledJobPeer getPeer()
664     {
665         return peer;
666     }
667
668     public String JavaDoc toString()
669     {
670         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
671         str.append("TurbineScheduledJob:\n");
672         str.append("JobId = ")
673                .append(getJobId())
674              .append("\n");
675         str.append("Second = ")
676                .append(getSecond())
677              .append("\n");
678         str.append("Minute = ")
679                .append(getMinute())
680              .append("\n");
681         str.append("Hour = ")
682                .append(getHour())
683              .append("\n");
684         str.append("WeekDay = ")
685                .append(getWeekDay())
686              .append("\n");
687         str.append("DayOfMonth = ")
688                .append(getDayOfMonth())
689              .append("\n");
690         str.append("Task = ")
691                .append(getTask())
692              .append("\n");
693         str.append("Email = ")
694                .append(getEmail())
695              .append("\n");
696         str.append("Property = ")
697                .append("<binary>")
698              .append("\n");
699         return(str.toString());
700     }
701 }
702
Popular Tags