View Javadoc
1   /*
2    * This class was automatically generated with 
3    * <a href="http://www.castor.org">Castor 1.3.1</a>, using an XML
4    * Schema.
5    * $Id$
6    */
7   
8   package org.exolab.castor.mapping.xml;
9   
10  /**
11   * The 'sql' element is used to store information about the
12   * database 
13   *  column to which a Java object is mapped to.
14   *  
15   * 
16   * @version $Revision$ $Date$
17   */
18  @SuppressWarnings("serial")
19  public class Sql implements java.io.Serializable {
20  
21  
22        //--------------------------/
23       //- Class/Member Variables -/
24      //--------------------------/
25  
26      /**
27       * An optional attribute used to store the name of the column
28       * in 
29       *  the database table.
30       *  
31       */
32      private java.util.List<java.lang.String> _name;
33  
34      /**
35       * An optional attibute used to specify the DB-specific type of
36       * the column.
37       *  
38       */
39      private java.lang.String _type;
40  
41      /**
42       * An optional attribute to specify the name of the bridge
43       * table 
44       *  containing the primary keys of the object on each side of
45       * the 
46       *  many to many relationship.
47       *  
48       */
49      private java.lang.String _manyTable;
50  
51      /**
52       * An optional attribute to specidy name of the columns that
53       * holds 
54       *  the foreign key to this object. That column is in the
55       * database 
56       *  table that stores objects of the Java type of this field.
57       *  
58       */
59      private java.util.List<java.lang.String> _manyKey;
60  
61      /**
62       * An optional attribute to specify cascading support; possible
63       * values are
64       *  'none', 'all', 'create', 'delete' and 'update'; it is
65       * possible to use more than one
66       *  of those values (when not using 'all' or 'none'), using
67       * whitespace as a 
68       *  delimiter (as in 'create delete').
69       *  
70       */
71      private java.lang.String _cascading;
72  
73      /**
74       * Field _readOnly.
75       */
76      private boolean _readOnly = false;
77  
78      /**
79       * keeps track of state for field: _readOnly
80       */
81      private boolean _has_readOnly;
82  
83      /**
84       * Field _transient.
85       */
86      private boolean _transient;
87  
88      /**
89       * keeps track of state for field: _transient
90       */
91      private boolean _has_transient;
92  
93      /**
94       * Field _dirty.
95       */
96      private org.exolab.castor.mapping.xml.types.SqlDirtyType _dirty = org.exolab.castor.mapping.xml.types.SqlDirtyType.fromValue("check");
97  
98  
99        //----------------/
100      //- Constructors -/
101     //----------------/
102 
103     public Sql() {
104         super();
105         this._name = new java.util.ArrayList<java.lang.String>();
106         this._manyKey = new java.util.ArrayList<java.lang.String>();
107         setDirty(org.exolab.castor.mapping.xml.types.SqlDirtyType.fromValue("check"));
108     }
109 
110 
111       //-----------/
112      //- Methods -/
113     //-----------/
114 
115     /**
116      * 
117      * 
118      * @param vManyKey
119      * @throws java.lang.IndexOutOfBoundsException if the index
120      * given is outside the bounds of the collection
121      */
122     public void addManyKey(
123             final java.lang.String vManyKey)
124     throws java.lang.IndexOutOfBoundsException {
125         this._manyKey.add(vManyKey);
126     }
127 
128     /**
129      * 
130      * 
131      * @param index
132      * @param vManyKey
133      * @throws java.lang.IndexOutOfBoundsException if the index
134      * given is outside the bounds of the collection
135      */
136     public void addManyKey(
137             final int index,
138             final java.lang.String vManyKey)
139     throws java.lang.IndexOutOfBoundsException {
140         this._manyKey.add(index, vManyKey);
141     }
142 
143     /**
144      * 
145      * 
146      * @param vName
147      * @throws java.lang.IndexOutOfBoundsException if the index
148      * given is outside the bounds of the collection
149      */
150     public void addName(
151             final java.lang.String vName)
152     throws java.lang.IndexOutOfBoundsException {
153         this._name.add(vName);
154     }
155 
156     /**
157      * 
158      * 
159      * @param index
160      * @param vName
161      * @throws java.lang.IndexOutOfBoundsException if the index
162      * given is outside the bounds of the collection
163      */
164     public void addName(
165             final int index,
166             final java.lang.String vName)
167     throws java.lang.IndexOutOfBoundsException {
168         this._name.add(index, vName);
169     }
170 
171     /**
172      */
173     public void deleteReadOnly(
174     ) {
175         this._has_readOnly= false;
176     }
177 
178     /**
179      */
180     public void deleteTransient(
181     ) {
182         this._has_transient= false;
183     }
184 
185     /**
186      * Method enumerateManyKey.
187      * 
188      * @return an Enumeration over all possible elements of this
189      * collection
190      */
191     public java.util.Enumeration<? extends java.lang.String> enumerateManyKey(
192     ) {
193         return java.util.Collections.enumeration(this._manyKey);
194     }
195 
196     /**
197      * Method enumerateName.
198      * 
199      * @return an Enumeration over all possible elements of this
200      * collection
201      */
202     public java.util.Enumeration<? extends java.lang.String> enumerateName(
203     ) {
204         return java.util.Collections.enumeration(this._name);
205     }
206 
207     /**
208      * Returns the value of field 'cascading'. The field
209      * 'cascading' has the following description: An optional
210      * attribute to specify cascading support; possible values are
211      *  'none', 'all', 'create', 'delete' and 'update'; it is
212      * possible to use more than one
213      *  of those values (when not using 'all' or 'none'), using
214      * whitespace as a 
215      *  delimiter (as in 'create delete').
216      *  
217      * 
218      * @return the value of field 'Cascading'.
219      */
220     public java.lang.String getCascading(
221     ) {
222         return this._cascading;
223     }
224 
225     /**
226      * Returns the value of field 'dirty'.
227      * 
228      * @return the value of field 'Dirty'.
229      */
230     public org.exolab.castor.mapping.xml.types.SqlDirtyType getDirty(
231     ) {
232         return this._dirty;
233     }
234 
235     /**
236      * Method getManyKey.
237      * 
238      * @param index
239      * @throws java.lang.IndexOutOfBoundsException if the index
240      * given is outside the bounds of the collection
241      * @return the value of the java.lang.String at the given index
242      */
243     public java.lang.String getManyKey(
244             final int index)
245     throws java.lang.IndexOutOfBoundsException {
246         // check bounds for index
247         if (index < 0 || index >= this._manyKey.size()) {
248             throw new IndexOutOfBoundsException("getManyKey: Index value '" + index + "' not in range [0.." + (this._manyKey.size() - 1) + "]");
249         }
250 
251         return (java.lang.String) _manyKey.get(index);
252     }
253 
254     /**
255      * Method getManyKey.Returns the contents of the collection in
256      * an Array.  <p>Note:  Just in case the collection contents
257      * are changing in another thread, we pass a 0-length Array of
258      * the correct type into the API call.  This way we <i>know</i>
259      * that the Array returned is of exactly the correct length.
260      * 
261      * @return this collection as an Array
262      */
263     public java.lang.String[] getManyKey(
264     ) {
265         java.lang.String[] array = new java.lang.String[0];
266         return (java.lang.String[]) this._manyKey.toArray(array);
267     }
268 
269     /**
270      * Method getManyKeyCount.
271      * 
272      * @return the size of this collection
273      */
274     public int getManyKeyCount(
275     ) {
276         return this._manyKey.size();
277     }
278 
279     /**
280      * Returns the value of field 'manyTable'. The field
281      * 'manyTable' has the following description: An optional
282      * attribute to specify the name of the bridge table 
283      *  containing the primary keys of the object on each side of
284      * the 
285      *  many to many relationship.
286      *  
287      * 
288      * @return the value of field 'ManyTable'.
289      */
290     public java.lang.String getManyTable(
291     ) {
292         return this._manyTable;
293     }
294 
295     /**
296      * Method getName.
297      * 
298      * @param index
299      * @throws java.lang.IndexOutOfBoundsException if the index
300      * given is outside the bounds of the collection
301      * @return the value of the java.lang.String at the given index
302      */
303     public java.lang.String getName(
304             final int index)
305     throws java.lang.IndexOutOfBoundsException {
306         // check bounds for index
307         if (index < 0 || index >= this._name.size()) {
308             throw new IndexOutOfBoundsException("getName: Index value '" + index + "' not in range [0.." + (this._name.size() - 1) + "]");
309         }
310 
311         return (java.lang.String) _name.get(index);
312     }
313 
314     /**
315      * Method getName.Returns the contents of the collection in an
316      * Array.  <p>Note:  Just in case the collection contents are
317      * changing in another thread, we pass a 0-length Array of the
318      * correct type into the API call.  This way we <i>know</i>
319      * that the Array returned is of exactly the correct length.
320      * 
321      * @return this collection as an Array
322      */
323     public java.lang.String[] getName(
324     ) {
325         java.lang.String[] array = new java.lang.String[0];
326         return (java.lang.String[]) this._name.toArray(array);
327     }
328 
329     /**
330      * Method getNameCount.
331      * 
332      * @return the size of this collection
333      */
334     public int getNameCount(
335     ) {
336         return this._name.size();
337     }
338 
339     /**
340      * Returns the value of field 'readOnly'.
341      * 
342      * @return the value of field 'ReadOnly'.
343      */
344     public boolean getReadOnly(
345     ) {
346         return this._readOnly;
347     }
348 
349     /**
350      * Returns the value of field 'transient'.
351      * 
352      * @return the value of field 'Transient'.
353      */
354     public boolean getTransient(
355     ) {
356         return this._transient;
357     }
358 
359     /**
360      * Returns the value of field 'type'. The field 'type' has the
361      * following description: An optional attibute used to specify
362      * the DB-specific type of the column.
363      *  
364      * 
365      * @return the value of field 'Type'.
366      */
367     public java.lang.String getType(
368     ) {
369         return this._type;
370     }
371 
372     /**
373      * Method hasReadOnly.
374      * 
375      * @return true if at least one ReadOnly has been added
376      */
377     public boolean hasReadOnly(
378     ) {
379         return this._has_readOnly;
380     }
381 
382     /**
383      * Method hasTransient.
384      * 
385      * @return true if at least one Transient has been added
386      */
387     public boolean hasTransient(
388     ) {
389         return this._has_transient;
390     }
391 
392     /**
393      * Returns the value of field 'readOnly'.
394      * 
395      * @return the value of field 'ReadOnly'.
396      */
397     public boolean isReadOnly(
398     ) {
399         return this._readOnly;
400     }
401 
402     /**
403      * Returns the value of field 'transient'.
404      * 
405      * @return the value of field 'Transient'.
406      */
407     public boolean isTransient(
408     ) {
409         return this._transient;
410     }
411 
412     /**
413      * Method isValid.
414      * 
415      * @return true if this object is valid according to the schema
416      */
417     public boolean isValid(
418     ) {
419         try {
420             validate();
421         } catch (org.exolab.castor.xml.ValidationException vex) {
422             return false;
423         }
424         return true;
425     }
426 
427     /**
428      * Method iterateManyKey.
429      * 
430      * @return an Iterator over all possible elements in this
431      * collection
432      */
433     public java.util.Iterator<? extends java.lang.String> iterateManyKey(
434     ) {
435         return this._manyKey.iterator();
436     }
437 
438     /**
439      * Method iterateName.
440      * 
441      * @return an Iterator over all possible elements in this
442      * collection
443      */
444     public java.util.Iterator<? extends java.lang.String> iterateName(
445     ) {
446         return this._name.iterator();
447     }
448 
449     /**
450      * 
451      * 
452      * @param out
453      * @throws org.exolab.castor.xml.MarshalException if object is
454      * null or if any SAXException is thrown during marshaling
455      * @throws org.exolab.castor.xml.ValidationException if this
456      * object is an invalid instance according to the schema
457      */
458     public void marshal(
459             final java.io.Writer out)
460     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
461         org.exolab.castor.xml.Marshaller.marshal(this, out);
462     }
463 
464     /**
465      * 
466      * 
467      * @param handler
468      * @throws java.io.IOException if an IOException occurs during
469      * marshaling
470      * @throws org.exolab.castor.xml.ValidationException if this
471      * object is an invalid instance according to the schema
472      * @throws org.exolab.castor.xml.MarshalException if object is
473      * null or if any SAXException is thrown during marshaling
474      */
475     public void marshal(
476             final org.xml.sax.ContentHandler handler)
477     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
478         org.exolab.castor.xml.Marshaller.marshal(this, handler);
479     }
480 
481     /**
482      */
483     public void removeAllManyKey(
484     ) {
485         this._manyKey.clear();
486     }
487 
488     /**
489      */
490     public void removeAllName(
491     ) {
492         this._name.clear();
493     }
494 
495     /**
496      * Method removeManyKey.
497      * 
498      * @param vManyKey
499      * @return true if the object was removed from the collection.
500      */
501     public boolean removeManyKey(
502             final java.lang.String vManyKey) {
503         boolean removed = _manyKey.remove(vManyKey);
504         return removed;
505     }
506 
507     /**
508      * Method removeManyKeyAt.
509      * 
510      * @param index
511      * @return the element removed from the collection
512      */
513     public java.lang.String removeManyKeyAt(
514             final int index) {
515         java.lang.Object obj = this._manyKey.remove(index);
516         return (java.lang.String) obj;
517     }
518 
519     /**
520      * Method removeName.
521      * 
522      * @param vName
523      * @return true if the object was removed from the collection.
524      */
525     public boolean removeName(
526             final java.lang.String vName) {
527         boolean removed = _name.remove(vName);
528         return removed;
529     }
530 
531     /**
532      * Method removeNameAt.
533      * 
534      * @param index
535      * @return the element removed from the collection
536      */
537     public java.lang.String removeNameAt(
538             final int index) {
539         java.lang.Object obj = this._name.remove(index);
540         return (java.lang.String) obj;
541     }
542 
543     /**
544      * Sets the value of field 'cascading'. The field 'cascading'
545      * has the following description: An optional attribute to
546      * specify cascading support; possible values are
547      *  'none', 'all', 'create', 'delete' and 'update'; it is
548      * possible to use more than one
549      *  of those values (when not using 'all' or 'none'), using
550      * whitespace as a 
551      *  delimiter (as in 'create delete').
552      *  
553      * 
554      * @param cascading the value of field 'cascading'.
555      */
556     public void setCascading(
557             final java.lang.String cascading) {
558         this._cascading = cascading;
559     }
560 
561     /**
562      * Sets the value of field 'dirty'.
563      * 
564      * @param dirty the value of field 'dirty'.
565      */
566     public void setDirty(
567             final org.exolab.castor.mapping.xml.types.SqlDirtyType dirty) {
568         this._dirty = dirty;
569     }
570 
571     /**
572      * 
573      * 
574      * @param index
575      * @param vManyKey
576      * @throws java.lang.IndexOutOfBoundsException if the index
577      * given is outside the bounds of the collection
578      */
579     public void setManyKey(
580             final int index,
581             final java.lang.String vManyKey)
582     throws java.lang.IndexOutOfBoundsException {
583         // check bounds for index
584         if (index < 0 || index >= this._manyKey.size()) {
585             throw new IndexOutOfBoundsException("setManyKey: Index value '" + index + "' not in range [0.." + (this._manyKey.size() - 1) + "]");
586         }
587 
588         this._manyKey.set(index, vManyKey);
589     }
590 
591     /**
592      * 
593      * 
594      * @param vManyKeyArray
595      */
596     public void setManyKey(
597             final java.lang.String[] vManyKeyArray) {
598         //-- copy array
599         _manyKey.clear();
600 
601         for (int i = 0; i < vManyKeyArray.length; i++) {
602                 this._manyKey.add(vManyKeyArray[i]);
603         }
604     }
605 
606     /**
607      * Sets the value of field 'manyTable'. The field 'manyTable'
608      * has the following description: An optional attribute to
609      * specify the name of the bridge table 
610      *  containing the primary keys of the object on each side of
611      * the 
612      *  many to many relationship.
613      *  
614      * 
615      * @param manyTable the value of field 'manyTable'.
616      */
617     public void setManyTable(
618             final java.lang.String manyTable) {
619         this._manyTable = manyTable;
620     }
621 
622     /**
623      * 
624      * 
625      * @param index
626      * @param vName
627      * @throws java.lang.IndexOutOfBoundsException if the index
628      * given is outside the bounds of the collection
629      */
630     public void setName(
631             final int index,
632             final java.lang.String vName)
633     throws java.lang.IndexOutOfBoundsException {
634         // check bounds for index
635         if (index < 0 || index >= this._name.size()) {
636             throw new IndexOutOfBoundsException("setName: Index value '" + index + "' not in range [0.." + (this._name.size() - 1) + "]");
637         }
638 
639         this._name.set(index, vName);
640     }
641 
642     /**
643      * 
644      * 
645      * @param vNameArray
646      */
647     public void setName(
648             final java.lang.String[] vNameArray) {
649         //-- copy array
650         _name.clear();
651 
652         for (int i = 0; i < vNameArray.length; i++) {
653                 this._name.add(vNameArray[i]);
654         }
655     }
656 
657     /**
658      * Sets the value of field 'readOnly'.
659      * 
660      * @param readOnly the value of field 'readOnly'.
661      */
662     public void setReadOnly(
663             final boolean readOnly) {
664         this._readOnly = readOnly;
665         this._has_readOnly = true;
666     }
667 
668     /**
669      * Sets the value of field 'transient'.
670      * 
671      * @param _transient
672      * @param transient the value of field 'transient'.
673      */
674     public void setTransient(
675             final boolean _transient) {
676         this._transient = _transient;
677         this._has_transient = true;
678     }
679 
680     /**
681      * Sets the value of field 'type'. The field 'type' has the
682      * following description: An optional attibute used to specify
683      * the DB-specific type of the column.
684      *  
685      * 
686      * @param type the value of field 'type'.
687      */
688     public void setType(
689             final java.lang.String type) {
690         this._type = type;
691     }
692 
693     /**
694      * Method unmarshal.
695      * 
696      * @param reader
697      * @throws org.exolab.castor.xml.MarshalException if object is
698      * null or if any SAXException is thrown during marshaling
699      * @throws org.exolab.castor.xml.ValidationException if this
700      * object is an invalid instance according to the schema
701      * @return the unmarshaled org.exolab.castor.mapping.xml.Sql
702      */
703     public static org.exolab.castor.mapping.xml.Sql unmarshal(
704             final java.io.Reader reader)
705     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
706         return (org.exolab.castor.mapping.xml.Sql) org.exolab.castor.xml.Unmarshaller.unmarshal(org.exolab.castor.mapping.xml.Sql.class, reader);
707     }
708 
709     /**
710      * 
711      * 
712      * @throws org.exolab.castor.xml.ValidationException if this
713      * object is an invalid instance according to the schema
714      */
715     public void validate(
716     )
717     throws org.exolab.castor.xml.ValidationException {
718         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
719         validator.validate(this);
720     }
721 
722 }