View Javadoc

1   package olr.om;
2   
3   
4   import java.sql.Connection;
5   import java.util.ArrayList;
6   import java.util.Collections;
7   import java.util.Date;
8   import java.util.List;
9   
10  import org.apache.commons.lang.ObjectUtils;
11  import org.apache.torque.TorqueException;
12  import org.apache.torque.om.BaseObject;
13  import org.apache.torque.om.NumberKey;
14  import org.apache.torque.om.ObjectKey;
15  import org.apache.torque.om.SimpleKey;
16  import org.apache.torque.util.Criteria;
17  import org.apache.torque.util.Transaction;
18  
19    
20    
21  /***
22   * This class was autogenerated by Torque on:
23   *
24   * [Tue Jul 13 14:47:47 CEST 2004]
25   *
26   * You should not use this class directly.  It should not even be
27   * extended all references should be to RdfNamespace
28   */
29  public abstract class BaseRdfNamespace extends BaseObject
30  {
31      /*** The Peer class */
32      private static final RdfNamespacePeer peer =
33          new RdfNamespacePeer();
34  
35          
36      /*** The value for the id field */
37      private int id;
38        
39      /*** The value for the nsName field */
40      private String nsName;
41        
42      /*** The value for the usr field */
43      private int usr;
44        
45      /*** The value for the modified field */
46      private Date modified;
47                                            
48      /*** The value for the garbage field */
49      private int garbage = 0;
50    
51      
52      /***
53       * Get the Id
54       *
55       * @return int
56       */
57      public int getId()
58      {
59          return id;
60      }
61  
62                                                
63      /***
64       * Set the value of Id
65       *
66       * @param v new value
67       */
68      public void setId(int v) throws TorqueException
69      {
70      
71                    if (this.id != v)
72                {
73              this.id = v;
74              setModified(true);
75          }
76      
77            
78                                    
79          // update associated RdfResource
80          if (collRdfResources != null)
81          {
82              for (int i = 0; i < collRdfResources.size(); i++)
83              {
84                  ((RdfResource) collRdfResources.get(i))
85                      .setNs(v);
86              }
87          }
88                                            
89          // update associated RdfSchema
90          if (collRdfSchemas != null)
91          {
92              for (int i = 0; i < collRdfSchemas.size(); i++)
93              {
94                  ((RdfSchema) collRdfSchemas.get(i))
95                      .setNsId(v);
96              }
97          }
98                        }
99    
100     /***
101      * Get the NsName
102      *
103      * @return String
104      */
105     public String getNsName()
106     {
107         return nsName;
108     }
109 
110                         
111     /***
112      * Set the value of NsName
113      *
114      * @param v new value
115      */
116     public void setNsName(String v) 
117     {
118     
119                   if (!ObjectUtils.equals(this.nsName, v))
120               {
121             this.nsName = v;
122             setModified(true);
123         }
124     
125           
126               }
127   
128     /***
129      * Get the Usr
130      *
131      * @return int
132      */
133     public int getUsr()
134     {
135         return usr;
136     }
137 
138                               
139     /***
140      * Set the value of Usr
141      *
142      * @param v new value
143      */
144     public void setUsr(int v) throws TorqueException
145     {
146     
147                   if (this.usr != v)
148               {
149             this.usr = v;
150             setModified(true);
151         }
152     
153                           
154                 if (aRdfUser != null && !(aRdfUser.getId() == v))
155                 {
156             aRdfUser = null;
157         }
158       
159               }
160   
161     /***
162      * Get the Modified
163      *
164      * @return Date
165      */
166     public Date getModified()
167     {
168         return modified;
169     }
170 
171                         
172     /***
173      * Set the value of Modified
174      *
175      * @param v new value
176      */
177     public void setModified(Date v) 
178     {
179     
180                   if (!ObjectUtils.equals(this.modified, v))
181               {
182             this.modified = v;
183             setModified(true);
184         }
185     
186           
187               }
188   
189     /***
190      * Get the Garbage
191      *
192      * @return int
193      */
194     public int getGarbage()
195     {
196         return garbage;
197     }
198 
199                         
200     /***
201      * Set the value of Garbage
202      *
203      * @param v new value
204      */
205     public void setGarbage(int v) 
206     {
207     
208                   if (this.garbage != v)
209               {
210             this.garbage = v;
211             setModified(true);
212         }
213     
214           
215               }
216   
217       
218     
219                   
220     
221         private RdfUser aRdfUser;
222 
223     /***
224      * Declares an association between this object and a RdfUser object
225      *
226      * @param v RdfUser
227      * @throws TorqueException
228      */
229     public void setRdfUser(RdfUser v) throws TorqueException
230     {
231             if (v == null)
232         {
233                     setUsr(0);
234                   }
235         else
236         {
237             setUsr(v.getId());
238         }
239                 aRdfUser = v;
240     }
241 
242                                             
243     /***
244      * Get the associated RdfUser object
245      *
246      * @return the associated RdfUser object
247      * @throws TorqueException
248      */
249     public RdfUser getRdfUser() throws TorqueException
250     {
251         if (aRdfUser == null && (this.usr > 0))
252         {
253                           aRdfUser = RdfUserPeer.retrieveByPK(SimpleKey.keyFor(this.usr));
254               
255             /* The following can be used instead of the line above to
256                guarantee the related object contains a reference
257                to this object, but this level of coupling
258                may be undesirable in many circumstances.
259                As it can lead to a db query with many results that may
260                never be used.
261                RdfUser obj = RdfUserPeer.retrieveByPK(this.usr);
262                obj.addRdfNamespaces(this);
263             */
264         }
265         return aRdfUser;
266     }
267 
268     /***
269      * Provides convenient way to set a relationship based on a
270      * ObjectKey.  e.g.
271      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
272      *
273            */
274     public void setRdfUserKey(ObjectKey key) throws TorqueException
275     {
276       
277                         setUsr(((NumberKey) key).intValue());
278                   }
279        
280                                 
281             
282     /***
283      * Collection to store aggregation of collRdfResources
284      */
285     protected List collRdfResources;
286 
287     /***
288      * Temporary storage of collRdfResources to save a possible db hit in
289      * the event objects are add to the collection, but the
290      * complete collection is never requested.
291      */
292     protected void initRdfResources()
293     {
294         if (collRdfResources == null)
295         {
296             collRdfResources = new ArrayList();
297         }
298     }
299 
300     /***
301      * Method called to associate a RdfResource object to this object
302      * through the RdfResource foreign key attribute
303      *
304      * @param l RdfResource
305      * @throws TorqueException
306      */
307     public void addRdfResource(RdfResource l) throws TorqueException
308     {
309         getRdfResources().add(l);
310         l.setRdfNamespace((RdfNamespace) this);
311     }
312 
313     /***
314      * The criteria used to select the current contents of collRdfResources
315      */
316     private Criteria lastRdfResourcesCriteria = null;
317 
318     /***
319      * If this collection has already been initialized, returns
320      * the collection. Otherwise returns the results of
321      * getRdfResources(new Criteria())
322      *
323      * @throws TorqueException
324      */
325     public List getRdfResources() throws TorqueException
326     {
327         if (collRdfResources == null)
328         {
329             collRdfResources = getRdfResources(new Criteria(10));
330         }
331         return collRdfResources;
332     }
333 
334     /***
335      * If this collection has already been initialized with
336      * an identical criteria, it returns the collection.
337      * Otherwise if this RdfNamespace has previously
338      * been saved, it will retrieve related RdfResources from storage.
339      * If this RdfNamespace is new, it will return
340      * an empty collection or the current collection, the criteria
341      * is ignored on a new object.
342      *
343      * @throws TorqueException
344      */
345     public List getRdfResources(Criteria criteria) throws TorqueException
346     {
347         if (collRdfResources == null)
348         {
349             if (isNew())
350             {
351                collRdfResources = new ArrayList();
352             }
353             else
354             {
355                       criteria.add(RdfResourcePeer.NS, getId() );
356                       collRdfResources = RdfResourcePeer.doSelect(criteria);
357             }
358         }
359         else
360         {
361             // criteria has no effect for a new object
362             if (!isNew())
363             {
364                 // the following code is to determine if a new query is
365                 // called for.  If the criteria is the same as the last
366                 // one, just return the collection.
367                       criteria.add(RdfResourcePeer.NS, getId());
368                       if (!lastRdfResourcesCriteria.equals(criteria))
369                 {
370                     collRdfResources = RdfResourcePeer.doSelect(criteria);
371                 }
372             }
373         }
374         lastRdfResourcesCriteria = criteria;
375 
376         return collRdfResources;
377     }
378 
379     /***
380      * If this collection has already been initialized, returns
381      * the collection. Otherwise returns the results of
382      * getRdfResources(new Criteria(),Connection)
383      * This method takes in the Connection also as input so that
384      * referenced objects can also be obtained using a Connection
385      * that is taken as input
386      */
387     public List getRdfResources(Connection con) throws TorqueException
388     {
389         if (collRdfResources == null)
390         {
391             collRdfResources = getRdfResources(new Criteria(10), con);
392         }
393         return collRdfResources;
394     }
395 
396     /***
397      * If this collection has already been initialized with
398      * an identical criteria, it returns the collection.
399      * Otherwise if this RdfNamespace has previously
400      * been saved, it will retrieve related RdfResources from storage.
401      * If this RdfNamespace is new, it will return
402      * an empty collection or the current collection, the criteria
403      * is ignored on a new object.
404      * This method takes in the Connection also as input so that
405      * referenced objects can also be obtained using a Connection
406      * that is taken as input
407      */
408     public List getRdfResources(Criteria criteria, Connection con)
409             throws TorqueException
410     {
411         if (collRdfResources == null)
412         {
413             if (isNew())
414             {
415                collRdfResources = new ArrayList();
416             }
417             else
418             {
419                        criteria.add(RdfResourcePeer.NS, getId());
420                        collRdfResources = RdfResourcePeer.doSelect(criteria, con);
421              }
422          }
423          else
424          {
425              // criteria has no effect for a new object
426              if (!isNew())
427              {
428                  // the following code is to determine if a new query is
429                  // called for.  If the criteria is the same as the last
430                  // one, just return the collection.
431                        criteria.add(RdfResourcePeer.NS, getId());
432                        if (!lastRdfResourcesCriteria.equals(criteria))
433                  {
434                      collRdfResources = RdfResourcePeer.doSelect(criteria, con);
435                  }
436              }
437          }
438          lastRdfResourcesCriteria = criteria;
439 
440          return collRdfResources;
441      }
442 
443                         
444               
445                     
446                               
447                                 
448                                                               
449                                         
450                     
451                     
452           
453     /***
454      * If this collection has already been initialized with
455      * an identical criteria, it returns the collection.
456      * Otherwise if this RdfNamespace is new, it will return
457      * an empty collection; or if this RdfNamespace has previously
458      * been saved, it will retrieve related RdfResources from storage.
459      *
460      * This method is protected by default in order to keep the public
461      * api reasonable.  You can provide public methods for those you
462      * actually need in RdfNamespace.
463      */
464     protected List getRdfResourcesJoinRdfNamespace(Criteria criteria)
465         throws TorqueException
466     {
467         if (collRdfResources == null)
468         {
469             if (isNew())
470             {
471                collRdfResources = new ArrayList();
472             }
473             else
474             {
475                             criteria.add(RdfResourcePeer.NS, getId());
476                             collRdfResources = RdfResourcePeer.doSelectJoinRdfNamespace(criteria);
477             }
478         }
479         else
480         {
481             // the following code is to determine if a new query is
482             // called for.  If the criteria is the same as the last
483             // one, just return the collection.
484             boolean newCriteria = true;
485                         criteria.add(RdfResourcePeer.NS, getId());
486                         if (!lastRdfResourcesCriteria.equals(criteria))
487             {
488                 collRdfResources = RdfResourcePeer.doSelectJoinRdfNamespace(criteria);
489             }
490         }
491         lastRdfResourcesCriteria = criteria;
492 
493         return collRdfResources;
494     }
495                   
496                     
497                     
498                                 
499                                                               
500                                         
501                     
502                     
503           
504     /***
505      * If this collection has already been initialized with
506      * an identical criteria, it returns the collection.
507      * Otherwise if this RdfNamespace is new, it will return
508      * an empty collection; or if this RdfNamespace has previously
509      * been saved, it will retrieve related RdfResources from storage.
510      *
511      * This method is protected by default in order to keep the public
512      * api reasonable.  You can provide public methods for those you
513      * actually need in RdfNamespace.
514      */
515     protected List getRdfResourcesJoinRdfUser(Criteria criteria)
516         throws TorqueException
517     {
518         if (collRdfResources == null)
519         {
520             if (isNew())
521             {
522                collRdfResources = new ArrayList();
523             }
524             else
525             {
526                             criteria.add(RdfResourcePeer.NS, getId());
527                             collRdfResources = RdfResourcePeer.doSelectJoinRdfUser(criteria);
528             }
529         }
530         else
531         {
532             // the following code is to determine if a new query is
533             // called for.  If the criteria is the same as the last
534             // one, just return the collection.
535             boolean newCriteria = true;
536                         criteria.add(RdfResourcePeer.NS, getId());
537                         if (!lastRdfResourcesCriteria.equals(criteria))
538             {
539                 collRdfResources = RdfResourcePeer.doSelectJoinRdfUser(criteria);
540             }
541         }
542         lastRdfResourcesCriteria = criteria;
543 
544         return collRdfResources;
545     }
546                             
547 
548 
549                           
550             
551     /***
552      * Collection to store aggregation of collRdfSchemas
553      */
554     protected List collRdfSchemas;
555 
556     /***
557      * Temporary storage of collRdfSchemas to save a possible db hit in
558      * the event objects are add to the collection, but the
559      * complete collection is never requested.
560      */
561     protected void initRdfSchemas()
562     {
563         if (collRdfSchemas == null)
564         {
565             collRdfSchemas = new ArrayList();
566         }
567     }
568 
569     /***
570      * Method called to associate a RdfSchema object to this object
571      * through the RdfSchema foreign key attribute
572      *
573      * @param l RdfSchema
574      * @throws TorqueException
575      */
576     public void addRdfSchema(RdfSchema l) throws TorqueException
577     {
578         getRdfSchemas().add(l);
579         l.setRdfNamespace((RdfNamespace) this);
580     }
581 
582     /***
583      * The criteria used to select the current contents of collRdfSchemas
584      */
585     private Criteria lastRdfSchemasCriteria = null;
586 
587     /***
588      * If this collection has already been initialized, returns
589      * the collection. Otherwise returns the results of
590      * getRdfSchemas(new Criteria())
591      *
592      * @throws TorqueException
593      */
594     public List getRdfSchemas() throws TorqueException
595     {
596         if (collRdfSchemas == null)
597         {
598             collRdfSchemas = getRdfSchemas(new Criteria(10));
599         }
600         return collRdfSchemas;
601     }
602 
603     /***
604      * If this collection has already been initialized with
605      * an identical criteria, it returns the collection.
606      * Otherwise if this RdfNamespace has previously
607      * been saved, it will retrieve related RdfSchemas from storage.
608      * If this RdfNamespace is new, it will return
609      * an empty collection or the current collection, the criteria
610      * is ignored on a new object.
611      *
612      * @throws TorqueException
613      */
614     public List getRdfSchemas(Criteria criteria) throws TorqueException
615     {
616         if (collRdfSchemas == null)
617         {
618             if (isNew())
619             {
620                collRdfSchemas = new ArrayList();
621             }
622             else
623             {
624                       criteria.add(RdfSchemaPeer.NS_ID, getId() );
625                       collRdfSchemas = RdfSchemaPeer.doSelect(criteria);
626             }
627         }
628         else
629         {
630             // criteria has no effect for a new object
631             if (!isNew())
632             {
633                 // the following code is to determine if a new query is
634                 // called for.  If the criteria is the same as the last
635                 // one, just return the collection.
636                       criteria.add(RdfSchemaPeer.NS_ID, getId());
637                       if (!lastRdfSchemasCriteria.equals(criteria))
638                 {
639                     collRdfSchemas = RdfSchemaPeer.doSelect(criteria);
640                 }
641             }
642         }
643         lastRdfSchemasCriteria = criteria;
644 
645         return collRdfSchemas;
646     }
647 
648     /***
649      * If this collection has already been initialized, returns
650      * the collection. Otherwise returns the results of
651      * getRdfSchemas(new Criteria(),Connection)
652      * This method takes in the Connection also as input so that
653      * referenced objects can also be obtained using a Connection
654      * that is taken as input
655      */
656     public List getRdfSchemas(Connection con) throws TorqueException
657     {
658         if (collRdfSchemas == null)
659         {
660             collRdfSchemas = getRdfSchemas(new Criteria(10), con);
661         }
662         return collRdfSchemas;
663     }
664 
665     /***
666      * If this collection has already been initialized with
667      * an identical criteria, it returns the collection.
668      * Otherwise if this RdfNamespace has previously
669      * been saved, it will retrieve related RdfSchemas from storage.
670      * If this RdfNamespace is new, it will return
671      * an empty collection or the current collection, the criteria
672      * is ignored on a new object.
673      * This method takes in the Connection also as input so that
674      * referenced objects can also be obtained using a Connection
675      * that is taken as input
676      */
677     public List getRdfSchemas(Criteria criteria, Connection con)
678             throws TorqueException
679     {
680         if (collRdfSchemas == null)
681         {
682             if (isNew())
683             {
684                collRdfSchemas = new ArrayList();
685             }
686             else
687             {
688                        criteria.add(RdfSchemaPeer.NS_ID, getId());
689                        collRdfSchemas = RdfSchemaPeer.doSelect(criteria, con);
690              }
691          }
692          else
693          {
694              // criteria has no effect for a new object
695              if (!isNew())
696              {
697                  // the following code is to determine if a new query is
698                  // called for.  If the criteria is the same as the last
699                  // one, just return the collection.
700                        criteria.add(RdfSchemaPeer.NS_ID, getId());
701                        if (!lastRdfSchemasCriteria.equals(criteria))
702                  {
703                      collRdfSchemas = RdfSchemaPeer.doSelect(criteria, con);
704                  }
705              }
706          }
707          lastRdfSchemasCriteria = criteria;
708 
709          return collRdfSchemas;
710      }
711 
712                   
713               
714                     
715                               
716                                 
717                                                               
718                                         
719                     
720                     
721           
722     /***
723      * If this collection has already been initialized with
724      * an identical criteria, it returns the collection.
725      * Otherwise if this RdfNamespace is new, it will return
726      * an empty collection; or if this RdfNamespace has previously
727      * been saved, it will retrieve related RdfSchemas from storage.
728      *
729      * This method is protected by default in order to keep the public
730      * api reasonable.  You can provide public methods for those you
731      * actually need in RdfNamespace.
732      */
733     protected List getRdfSchemasJoinRdfNamespace(Criteria criteria)
734         throws TorqueException
735     {
736         if (collRdfSchemas == null)
737         {
738             if (isNew())
739             {
740                collRdfSchemas = new ArrayList();
741             }
742             else
743             {
744                             criteria.add(RdfSchemaPeer.NS_ID, getId());
745                             collRdfSchemas = RdfSchemaPeer.doSelectJoinRdfNamespace(criteria);
746             }
747         }
748         else
749         {
750             // the following code is to determine if a new query is
751             // called for.  If the criteria is the same as the last
752             // one, just return the collection.
753             boolean newCriteria = true;
754                         criteria.add(RdfSchemaPeer.NS_ID, getId());
755                         if (!lastRdfSchemasCriteria.equals(criteria))
756             {
757                 collRdfSchemas = RdfSchemaPeer.doSelectJoinRdfNamespace(criteria);
758             }
759         }
760         lastRdfSchemasCriteria = criteria;
761 
762         return collRdfSchemas;
763     }
764                             
765 
766 
767           
768     private static List fieldNames = null;
769 
770     /***
771      * Generate a list of field names.
772      *
773      * @return a list of field names
774      */
775     public static synchronized List getFieldNames()
776     {
777         if (fieldNames == null)
778         {
779             fieldNames = new ArrayList();
780               fieldNames.add("Id");
781               fieldNames.add("NsName");
782               fieldNames.add("Usr");
783               fieldNames.add("Modified");
784               fieldNames.add("Garbage");
785               fieldNames = Collections.unmodifiableList(fieldNames);
786         }
787         return fieldNames;
788     }
789 
790     /***
791      * Retrieves a field from the object by name passed in as a String.
792      *
793      * @param name field name
794      * @return value
795      */
796     public Object getByName(String name)
797     {
798           if (name.equals("Id"))
799         {
800                 return new Integer(getId());
801             }
802           if (name.equals("NsName"))
803         {
804                 return getNsName();
805             }
806           if (name.equals("Usr"))
807         {
808                 return new Integer(getUsr());
809             }
810           if (name.equals("Modified"))
811         {
812                 return getModified();
813             }
814           if (name.equals("Garbage"))
815         {
816                 return new Integer(getGarbage());
817             }
818           return null;
819     }
820     
821     /***
822      * Retrieves a field from the object by name passed in
823      * as a String.  The String must be one of the static
824      * Strings defined in this Class' Peer.
825      *
826      * @param name peer name
827      * @return value
828      */
829     public Object getByPeerName(String name)
830     {
831           if (name.equals(RdfNamespacePeer.ID))
832         {
833                 return new Integer(getId());
834             }
835           if (name.equals(RdfNamespacePeer.NS_NAME))
836         {
837                 return getNsName();
838             }
839           if (name.equals(RdfNamespacePeer.USR))
840         {
841                 return new Integer(getUsr());
842             }
843           if (name.equals(RdfNamespacePeer.MODIFIED))
844         {
845                 return getModified();
846             }
847           if (name.equals(RdfNamespacePeer.GARBAGE))
848         {
849                 return new Integer(getGarbage());
850             }
851           return null;
852     }
853 
854     /***
855      * Retrieves a field from the object by Position as specified
856      * in the xml schema.  Zero-based.
857      *
858      * @param pos position in xml schema
859      * @return value
860      */
861     public Object getByPosition(int pos)
862     {
863             if (pos == 0)
864         {
865                 return new Integer(getId());
866             }
867               if (pos == 1)
868         {
869                 return getNsName();
870             }
871               if (pos == 2)
872         {
873                 return new Integer(getUsr());
874             }
875               if (pos == 3)
876         {
877                 return getModified();
878             }
879               if (pos == 4)
880         {
881                 return new Integer(getGarbage());
882             }
883               return null;
884     }
885      
886     /***
887      * Stores the object in the database.  If the object is new,
888      * it inserts it; otherwise an update is performed.
889      *
890      * @throws Exception
891      */
892     public void save() throws Exception
893     {
894           save(RdfNamespacePeer.getMapBuilder()
895                 .getDatabaseMap().getName());
896       }
897 
898     /***
899      * Stores the object in the database.  If the object is new,
900      * it inserts it; otherwise an update is performed.
901        * Note: this code is here because the method body is
902      * auto-generated conditionally and therefore needs to be
903      * in this file instead of in the super class, BaseObject.
904        *
905      * @param dbName
906      * @throws TorqueException
907      */
908     public void save(String dbName) throws TorqueException
909     {
910         Connection con = null;
911           try
912         {
913             con = Transaction.begin(dbName);
914             save(con);
915             Transaction.commit(con);
916         }
917         catch(TorqueException e)
918         {
919             Transaction.safeRollback(con);
920             throw e;
921         }
922       }
923 
924       /*** flag to prevent endless save loop, if this object is referenced
925         by another object which falls in this transaction. */
926     private boolean alreadyInSave = false;
927       /***
928      * Stores the object in the database.  If the object is new,
929      * it inserts it; otherwise an update is performed.  This method
930      * is meant to be used as part of a transaction, otherwise use
931      * the save() method and the connection details will be handled
932      * internally
933      *
934      * @param con
935      * @throws TorqueException
936      */
937     public void save(Connection con) throws TorqueException
938     {
939           if (!alreadyInSave)
940         {
941             alreadyInSave = true;
942 
943 
944   
945             // If this object has been modified, then save it to the database.
946             if (isModified())
947             {
948                 if (isNew())
949                 {
950                     RdfNamespacePeer.doInsert((RdfNamespace) this, con);
951                     setNew(false);
952                 }
953                 else
954                 {
955                     RdfNamespacePeer.doUpdate((RdfNamespace) this, con);
956                 }
957             }
958 
959                                       
960                 
961             if (collRdfResources != null)
962             {
963                 for (int i = 0; i < collRdfResources.size(); i++)
964                 {
965                     ((RdfResource) collRdfResources.get(i)).save(con);
966                 }
967             }
968                                           
969                 
970             if (collRdfSchemas != null)
971             {
972                 for (int i = 0; i < collRdfSchemas.size(); i++)
973                 {
974                     ((RdfSchema) collRdfSchemas.get(i)).save(con);
975                 }
976             }
977                           alreadyInSave = false;
978         }
979       }
980 
981 
982                           
983       /***
984      * Set the PrimaryKey using ObjectKey.
985      *
986      * @param  id ObjectKey
987      */
988     public void setPrimaryKey(ObjectKey key)
989         throws TorqueException
990     {
991             setId(((NumberKey) key).intValue());
992         }
993 
994     /***
995      * Set the PrimaryKey using a String.
996      *
997      * @param key
998      */
999     public void setPrimaryKey(String key) throws TorqueException
1000     {
1001             setId(Integer.parseInt(key));
1002         }
1003 
1004   
1005     /***
1006      * returns an id that differentiates this object from others
1007      * of its class.
1008      */
1009     public ObjectKey getPrimaryKey()
1010     {
1011           return SimpleKey.keyFor(getId());
1012       }
1013 
1014  
1015 
1016     /***
1017      * Makes a copy of this object.
1018      * It creates a new object filling in the simple attributes.
1019        * It then fills all the association collections and sets the
1020      * related objects to isNew=true.
1021        */
1022       public RdfNamespace copy() throws TorqueException
1023     {
1024         return copyInto(new RdfNamespace());
1025     }
1026   
1027     protected RdfNamespace copyInto(RdfNamespace copyObj) throws TorqueException
1028     {
1029           copyObj.setId(id);
1030           copyObj.setNsName(nsName);
1031           copyObj.setUsr(usr);
1032           copyObj.setModified(modified);
1033           copyObj.setGarbage(garbage);
1034   
1035                     copyObj.setId(0);
1036                                     
1037                                       
1038                 
1039         List v = getRdfResources();
1040         for (int i = 0; i < v.size(); i++)
1041         {
1042             RdfResource obj = (RdfResource) v.get(i);
1043             copyObj.addRdfResource(obj.copy());
1044         }
1045                                                   
1046                 
1047         v = getRdfSchemas();
1048         for (int i = 0; i < v.size(); i++)
1049         {
1050             RdfSchema obj = (RdfSchema) v.get(i);
1051             copyObj.addRdfSchema(obj.copy());
1052         }
1053                     
1054         return copyObj;
1055     }
1056 
1057     /***
1058      * returns a peer instance associated with this om.  Since Peer classes
1059      * are not to have any instance attributes, this method returns the
1060      * same instance for all member of this class. The method could therefore
1061      * be static, but this would prevent one from overriding the behavior.
1062      */
1063     public RdfNamespacePeer getPeer()
1064     {
1065         return peer;
1066     }
1067 
1068     public String toString()
1069     {
1070         StringBuffer str = new StringBuffer();
1071         str.append("RdfNamespace:\n");
1072         str.append("Id = ")
1073            .append(getId())
1074            .append("\n");
1075         str.append("NsName = ")
1076            .append(getNsName())
1077            .append("\n");
1078         str.append("Usr = ")
1079            .append(getUsr())
1080            .append("\n");
1081         str.append("Modified = ")
1082            .append(getModified())
1083            .append("\n");
1084         str.append("Garbage = ")
1085            .append(getGarbage())
1086            .append("\n");
1087         return(str.toString());
1088     }
1089 }