KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > om > dbpsml > BaseJetspeedUserProfile


1 package org.apache.jetspeed.om.dbpsml;
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.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 15:30:48 PDT 2004]
29  *
30  * You should not use this class directly. It should not even be
31  * extended all references should be to JetspeedUserProfile
32  */

33 public abstract class BaseJetspeedUserProfile extends BaseObject
34 {
35     /** The Peer class */
36     private static final JetspeedUserProfilePeer peer =
37         new JetspeedUserProfilePeer();
38
39       
40     /** The value for the psmlId field */
41     private int psmlId;
42       
43     /** The value for the userName field */
44     private String JavaDoc userName;
45       
46     /** The value for the mediaType field */
47     private String JavaDoc mediaType;
48       
49     /** The value for the language field */
50     private String JavaDoc language;
51       
52     /** The value for the country field */
53     private String JavaDoc country;
54       
55     /** The value for the page field */
56     private String JavaDoc page;
57       
58     /** The value for the profile field */
59     private byte[] profile;
60   
61   
62     /**
63      * Get the PsmlId
64      * @return int
65      */

66     public int getPsmlId()
67     {
68         return psmlId;
69     }
70
71                         
72     /**
73      * Set the value of PsmlId
74      */

75     public void setPsmlId(int v )
76     {
77     
78                   if (this.psmlId != v)
79               {
80             this.psmlId = v;
81             setModified(true);
82         }
83     
84           
85               }
86
87   
88     /**
89      * Get the UserName
90      * @return String
91      */

92     public String JavaDoc getUserName()
93     {
94         return userName;
95     }
96
97                         
98     /**
99      * Set the value of UserName
100      */

101     public void setUserName(String JavaDoc v )
102     {
103     
104                   if (!ObjectUtils.equals(this.userName, v))
105               {
106             this.userName = v;
107             setModified(true);
108         }
109     
110           
111               }
112
113   
114     /**
115      * Get the MediaType
116      * @return String
117      */

118     public String JavaDoc getMediaType()
119     {
120         return mediaType;
121     }
122
123                         
124     /**
125      * Set the value of MediaType
126      */

127     public void setMediaType(String JavaDoc v )
128     {
129     
130                   if (!ObjectUtils.equals(this.mediaType, v))
131               {
132             this.mediaType = v;
133             setModified(true);
134         }
135     
136           
137               }
138
139   
140     /**
141      * Get the Language
142      * @return String
143      */

144     public String JavaDoc getLanguage()
145     {
146         return language;
147     }
148
149                         
150     /**
151      * Set the value of Language
152      */

153     public void setLanguage(String JavaDoc v )
154     {
155     
156                   if (!ObjectUtils.equals(this.language, v))
157               {
158             this.language = v;
159             setModified(true);
160         }
161     
162           
163               }
164
165   
166     /**
167      * Get the Country
168      * @return String
169      */

170     public String JavaDoc getCountry()
171     {
172         return country;
173     }
174
175                         
176     /**
177      * Set the value of Country
178      */

179     public void setCountry(String JavaDoc v )
180     {
181     
182                   if (!ObjectUtils.equals(this.country, v))
183               {
184             this.country = v;
185             setModified(true);
186         }
187     
188           
189               }
190
191   
192     /**
193      * Get the Page
194      * @return String
195      */

196     public String JavaDoc getPage()
197     {
198         return page;
199     }
200
201                         
202     /**
203      * Set the value of Page
204      */

205     public void setPage(String JavaDoc v )
206     {
207     
208                   if (!ObjectUtils.equals(this.page, v))
209               {
210             this.page = v;
211             setModified(true);
212         }
213     
214           
215               }
216
217   
218     /**
219      * Get the Profile
220      * @return byte[]
221      */

222     public byte[] getProfile()
223     {
224         return profile;
225     }
226
227                         
228     /**
229      * Set the value of Profile
230      */

231     public void setProfile(byte[] v )
232     {
233     
234                   if (!ObjectUtils.equals(this.profile, v))
235               {
236             this.profile = v;
237             setModified(true);
238         }
239     
240           
241               }
242
243   
244          
245                 
246     private static List JavaDoc fieldNames = null;
247
248     /**
249      * Generate a list of field names.
250      */

251     public static synchronized List JavaDoc getFieldNames()
252     {
253         if (fieldNames == null)
254         {
255             fieldNames = new ArrayList JavaDoc();
256               fieldNames.add("PsmlId");
257               fieldNames.add("UserName");
258               fieldNames.add("MediaType");
259               fieldNames.add("Language");
260               fieldNames.add("Country");
261               fieldNames.add("Page");
262               fieldNames.add("Profile");
263               fieldNames = Collections.unmodifiableList(fieldNames);
264         }
265         return fieldNames;
266     }
267
268     /**
269      * Retrieves a field from the object by name passed in
270      * as a String.
271      */

272     public Object JavaDoc getByName(String JavaDoc name)
273     {
274           if (name.equals("PsmlId"))
275         {
276                 return new Integer JavaDoc(getPsmlId());
277             }
278           if (name.equals("UserName"))
279         {
280                 return getUserName();
281             }
282           if (name.equals("MediaType"))
283         {
284                 return getMediaType();
285             }
286           if (name.equals("Language"))
287         {
288                 return getLanguage();
289             }
290           if (name.equals("Country"))
291         {
292                 return getCountry();
293             }
294           if (name.equals("Page"))
295         {
296                 return getPage();
297             }
298           if (name.equals("Profile"))
299         {
300                 return getProfile();
301             }
302           return null;
303     }
304     
305     /**
306      * Retrieves a field from the object by name passed in
307      * as a String. The String must be one of the static
308      * Strings defined in this Class' Peer.
309      */

310     public Object JavaDoc getByPeerName(String JavaDoc name)
311     {
312           if (name.equals(JetspeedUserProfilePeer.PSML_ID ))
313         {
314                 return new Integer JavaDoc(getPsmlId());
315             }
316           if (name.equals(JetspeedUserProfilePeer.USER_NAME ))
317         {
318                 return getUserName();
319             }
320           if (name.equals(JetspeedUserProfilePeer.MEDIA_TYPE ))
321         {
322                 return getMediaType();
323             }
324           if (name.equals(JetspeedUserProfilePeer.LANGUAGE ))
325         {
326                 return getLanguage();
327             }
328           if (name.equals(JetspeedUserProfilePeer.COUNTRY ))
329         {
330                 return getCountry();
331             }
332           if (name.equals(JetspeedUserProfilePeer.PAGE ))
333         {
334                 return getPage();
335             }
336           if (name.equals(JetspeedUserProfilePeer.PROFILE ))
337         {
338                 return getProfile();
339             }
340           return null;
341     }
342
343     /**
344      * Retrieves a field from the object by Position as specified
345      * in the xml schema. Zero-based.
346      */

347     public Object JavaDoc getByPosition(int pos)
348     {
349             if ( pos == 0 )
350         {
351                 return new Integer JavaDoc(getPsmlId());
352             }
353               if ( pos == 1 )
354         {
355                 return getUserName();
356             }
357               if ( pos == 2 )
358         {
359                 return getMediaType();
360             }
361               if ( pos == 3 )
362         {
363                 return getLanguage();
364             }
365               if ( pos == 4 )
366         {
367                 return getCountry();
368             }
369               if ( pos == 5 )
370         {
371                 return getPage();
372             }
373               if ( pos == 6 )
374         {
375                 return getProfile();
376             }
377               return null;
378     }
379      
380     /**
381      * Stores the object in the database. If the object is new,
382      * it inserts it; otherwise an update is performed.
383      */

384     public void save() throws Exception JavaDoc
385     {
386           save(JetspeedUserProfilePeer.getMapBuilder()
387                 .getDatabaseMap().getName());
388       }
389
390     /**
391      * Stores the object in the database. If the object is new,
392      * it inserts it; otherwise an update is performed.
393        * Note: this code is here because the method body is
394      * auto-generated conditionally and therefore needs to be
395      * in this file instead of in the super class, BaseObject.
396        */

397     public void save(String JavaDoc dbName) throws TorqueException
398     {
399         Connection JavaDoc con = null;
400           try
401         {
402             con = Transaction.begin(dbName);
403             save(con);
404             Transaction.commit(con);
405         }
406         catch(TorqueException e)
407         {
408             Transaction.safeRollback(con);
409             throw e;
410         }
411       }
412
413       /** flag to prevent endless save loop, if this object is referenced
414         by another object which falls in this transaction. */

415     private boolean alreadyInSave = false;
416       /**
417      * Stores the object in the database. If the object is new,
418      * it inserts it; otherwise an update is performed. This method
419      * is meant to be used as part of a transaction, otherwise use
420      * the save() method and the connection details will be handled
421      * internally
422      */

423     public void save(Connection JavaDoc con) throws TorqueException
424     {
425           if (!alreadyInSave)
426         {
427             alreadyInSave = true;
428
429
430   
431             // If this object has been modified, then save it to the database.
432
if (isModified())
433             {
434                 if (isNew())
435                 {
436                     JetspeedUserProfilePeer.doInsert((JetspeedUserProfile)this, con);
437                     setNew(false);
438                 }
439                 else
440                 {
441                     JetspeedUserProfilePeer.doUpdate((JetspeedUserProfile)this, con);
442                 }
443
444                       if (isCacheOnSave())
445                 {
446                     JetspeedUserProfileManager.putInstance(this);
447                 }
448               }
449
450                       alreadyInSave = false;
451         }
452       }
453
454     /**
455      * Specify whether to cache the object after saving to the db.
456      * This method returns false
457      */

458     protected boolean isCacheOnSave()
459     {
460         return true;
461     }
462
463                   
464       /**
465      * Set the PrimaryKey using ObjectKey.
466      *
467      * @param ObjectKey psmlId
468      */

469     public void setPrimaryKey(ObjectKey psmlId)
470          {
471             setPsmlId(((NumberKey)psmlId).intValue());
472         }
473
474     /**
475      * Set the PrimaryKey using a String.
476      */

477     public void setPrimaryKey(String JavaDoc key)
478     {
479             setPsmlId(Integer.parseInt(key));
480         }
481
482   
483     /**
484      * returns an id that differentiates this object from others
485      * of its class.
486      */

487     public ObjectKey getPrimaryKey()
488     {
489           return SimpleKey.keyFor(getPsmlId());
490       }
491  
492
493     /**
494      * Makes a copy of this object.
495      * It creates a new object filling in the simple attributes.
496        * It then fills all the association collections.
497        */

498       public JetspeedUserProfile copy() throws TorqueException
499     {
500         JetspeedUserProfile copyObj = new JetspeedUserProfile();
501             copyObj.setPsmlId(psmlId);
502           copyObj.setUserName(userName);
503           copyObj.setMediaType(mediaType);
504           copyObj.setLanguage(language);
505           copyObj.setCountry(country);
506           copyObj.setPage(page);
507           copyObj.setProfile(profile);
508   
509                       copyObj.setPsmlId(0);
510                                                 
511                 return copyObj;
512     }
513
514     /**
515      * returns a peer instance associated with this om. Since Peer classes
516      * are not to have any instance attributes, this method returns the
517      * same instance for all member of this class. The method could therefore
518      * be static, but this would prevent one from overriding the behavior.
519      */

520     public JetspeedUserProfilePeer getPeer()
521     {
522         return peer;
523     }
524 }
525
Popular Tags