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   * Class ClassChoice.
12   * 
13   * @version $Revision$ $Date$
14   */
15  @SuppressWarnings("serial")
16  public class ClassChoice implements java.io.Serializable {
17  
18  
19        //--------------------------/
20       //- Class/Member Variables -/
21      //--------------------------/
22  
23      /**
24       * The 'field' element is used to describe the property of a
25       * Java object.
26       *  
27       */
28      private java.util.List<org.exolab.castor.mapping.xml.FieldMapping> _fieldMappingList;
29  
30      /**
31       * Field _containerList.
32       */
33      private java.util.List<org.exolab.castor.mapping.xml.Container> _containerList;
34  
35  
36        //----------------/
37       //- Constructors -/
38      //----------------/
39  
40      public ClassChoice() {
41          super();
42          this._fieldMappingList = new java.util.ArrayList<org.exolab.castor.mapping.xml.FieldMapping>();
43          this._containerList = new java.util.ArrayList<org.exolab.castor.mapping.xml.Container>();
44      }
45  
46  
47        //-----------/
48       //- Methods -/
49      //-----------/
50  
51      /**
52       * 
53       * 
54       * @param vContainer
55       * @throws java.lang.IndexOutOfBoundsException if the index
56       * given is outside the bounds of the collection
57       */
58      public void addContainer(
59              final org.exolab.castor.mapping.xml.Container vContainer)
60      throws java.lang.IndexOutOfBoundsException {
61          this._containerList.add(vContainer);
62      }
63  
64      /**
65       * 
66       * 
67       * @param index
68       * @param vContainer
69       * @throws java.lang.IndexOutOfBoundsException if the index
70       * given is outside the bounds of the collection
71       */
72      public void addContainer(
73              final int index,
74              final org.exolab.castor.mapping.xml.Container vContainer)
75      throws java.lang.IndexOutOfBoundsException {
76          this._containerList.add(index, vContainer);
77      }
78  
79      /**
80       * 
81       * 
82       * @param vFieldMapping
83       * @throws java.lang.IndexOutOfBoundsException if the index
84       * given is outside the bounds of the collection
85       */
86      public void addFieldMapping(
87              final org.exolab.castor.mapping.xml.FieldMapping vFieldMapping)
88      throws java.lang.IndexOutOfBoundsException {
89          this._fieldMappingList.add(vFieldMapping);
90      }
91  
92      /**
93       * 
94       * 
95       * @param index
96       * @param vFieldMapping
97       * @throws java.lang.IndexOutOfBoundsException if the index
98       * given is outside the bounds of the collection
99       */
100     public void addFieldMapping(
101             final int index,
102             final org.exolab.castor.mapping.xml.FieldMapping vFieldMapping)
103     throws java.lang.IndexOutOfBoundsException {
104         this._fieldMappingList.add(index, vFieldMapping);
105     }
106 
107     /**
108      * Method enumerateContainer.
109      * 
110      * @return an Enumeration over all possible elements of this
111      * collection
112      */
113     public java.util.Enumeration<? extends org.exolab.castor.mapping.xml.Container> enumerateContainer(
114     ) {
115         return java.util.Collections.enumeration(this._containerList);
116     }
117 
118     /**
119      * Method enumerateFieldMapping.
120      * 
121      * @return an Enumeration over all possible elements of this
122      * collection
123      */
124     public java.util.Enumeration<? extends org.exolab.castor.mapping.xml.FieldMapping> enumerateFieldMapping(
125     ) {
126         return java.util.Collections.enumeration(this._fieldMappingList);
127     }
128 
129     /**
130      * Method getContainer.
131      * 
132      * @param index
133      * @throws java.lang.IndexOutOfBoundsException if the index
134      * given is outside the bounds of the collection
135      * @return the value of the
136      * org.exolab.castor.mapping.xml.Container at the given index
137      */
138     public org.exolab.castor.mapping.xml.Container getContainer(
139             final int index)
140     throws java.lang.IndexOutOfBoundsException {
141         // check bounds for index
142         if (index < 0 || index >= this._containerList.size()) {
143             throw new IndexOutOfBoundsException("getContainer: Index value '" + index + "' not in range [0.." + (this._containerList.size() - 1) + "]");
144         }
145 
146         return (org.exolab.castor.mapping.xml.Container) _containerList.get(index);
147     }
148 
149     /**
150      * Method getContainer.Returns the contents of the collection
151      * in an Array.  <p>Note:  Just in case the collection contents
152      * are changing in another thread, we pass a 0-length Array of
153      * the correct type into the API call.  This way we <i>know</i>
154      * that the Array returned is of exactly the correct length.
155      * 
156      * @return this collection as an Array
157      */
158     public org.exolab.castor.mapping.xml.Container[] getContainer(
159     ) {
160         org.exolab.castor.mapping.xml.Container[] array = new org.exolab.castor.mapping.xml.Container[0];
161         return (org.exolab.castor.mapping.xml.Container[]) this._containerList.toArray(array);
162     }
163 
164     /**
165      * Method getContainerCount.
166      * 
167      * @return the size of this collection
168      */
169     public int getContainerCount(
170     ) {
171         return this._containerList.size();
172     }
173 
174     /**
175      * Method getFieldMapping.
176      * 
177      * @param index
178      * @throws java.lang.IndexOutOfBoundsException if the index
179      * given is outside the bounds of the collection
180      * @return the value of the
181      * org.exolab.castor.mapping.xml.FieldMapping at the given index
182      */
183     public org.exolab.castor.mapping.xml.FieldMapping getFieldMapping(
184             final int index)
185     throws java.lang.IndexOutOfBoundsException {
186         // check bounds for index
187         if (index < 0 || index >= this._fieldMappingList.size()) {
188             throw new IndexOutOfBoundsException("getFieldMapping: Index value '" + index + "' not in range [0.." + (this._fieldMappingList.size() - 1) + "]");
189         }
190 
191         return (org.exolab.castor.mapping.xml.FieldMapping) _fieldMappingList.get(index);
192     }
193 
194     /**
195      * Method getFieldMapping.Returns the contents of the
196      * collection in an Array.  <p>Note:  Just in case the
197      * collection contents are changing in another thread, we pass
198      * a 0-length Array of the correct type into the API call. 
199      * This way we <i>know</i> that the Array returned is of
200      * exactly the correct length.
201      * 
202      * @return this collection as an Array
203      */
204     public org.exolab.castor.mapping.xml.FieldMapping[] getFieldMapping(
205     ) {
206         org.exolab.castor.mapping.xml.FieldMapping[] array = new org.exolab.castor.mapping.xml.FieldMapping[0];
207         return (org.exolab.castor.mapping.xml.FieldMapping[]) this._fieldMappingList.toArray(array);
208     }
209 
210     /**
211      * Method getFieldMappingCount.
212      * 
213      * @return the size of this collection
214      */
215     public int getFieldMappingCount(
216     ) {
217         return this._fieldMappingList.size();
218     }
219 
220     /**
221      * Method isValid.
222      * 
223      * @return true if this object is valid according to the schema
224      */
225     public boolean isValid(
226     ) {
227         try {
228             validate();
229         } catch (org.exolab.castor.xml.ValidationException vex) {
230             return false;
231         }
232         return true;
233     }
234 
235     /**
236      * Method iterateContainer.
237      * 
238      * @return an Iterator over all possible elements in this
239      * collection
240      */
241     public java.util.Iterator<? extends org.exolab.castor.mapping.xml.Container> iterateContainer(
242     ) {
243         return this._containerList.iterator();
244     }
245 
246     /**
247      * Method iterateFieldMapping.
248      * 
249      * @return an Iterator over all possible elements in this
250      * collection
251      */
252     public java.util.Iterator<? extends org.exolab.castor.mapping.xml.FieldMapping> iterateFieldMapping(
253     ) {
254         return this._fieldMappingList.iterator();
255     }
256 
257     /**
258      * 
259      * 
260      * @param out
261      * @throws org.exolab.castor.xml.MarshalException if object is
262      * null or if any SAXException is thrown during marshaling
263      * @throws org.exolab.castor.xml.ValidationException if this
264      * object is an invalid instance according to the schema
265      */
266     public void marshal(
267             final java.io.Writer out)
268     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
269         org.exolab.castor.xml.Marshaller.marshal(this, out);
270     }
271 
272     /**
273      * 
274      * 
275      * @param handler
276      * @throws java.io.IOException if an IOException occurs during
277      * marshaling
278      * @throws org.exolab.castor.xml.ValidationException if this
279      * object is an invalid instance according to the schema
280      * @throws org.exolab.castor.xml.MarshalException if object is
281      * null or if any SAXException is thrown during marshaling
282      */
283     public void marshal(
284             final org.xml.sax.ContentHandler handler)
285     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
286         org.exolab.castor.xml.Marshaller.marshal(this, handler);
287     }
288 
289     /**
290      */
291     public void removeAllContainer(
292     ) {
293         this._containerList.clear();
294     }
295 
296     /**
297      */
298     public void removeAllFieldMapping(
299     ) {
300         this._fieldMappingList.clear();
301     }
302 
303     /**
304      * Method removeContainer.
305      * 
306      * @param vContainer
307      * @return true if the object was removed from the collection.
308      */
309     public boolean removeContainer(
310             final org.exolab.castor.mapping.xml.Container vContainer) {
311         boolean removed = _containerList.remove(vContainer);
312         return removed;
313     }
314 
315     /**
316      * Method removeContainerAt.
317      * 
318      * @param index
319      * @return the element removed from the collection
320      */
321     public org.exolab.castor.mapping.xml.Container removeContainerAt(
322             final int index) {
323         java.lang.Object obj = this._containerList.remove(index);
324         return (org.exolab.castor.mapping.xml.Container) obj;
325     }
326 
327     /**
328      * Method removeFieldMapping.
329      * 
330      * @param vFieldMapping
331      * @return true if the object was removed from the collection.
332      */
333     public boolean removeFieldMapping(
334             final org.exolab.castor.mapping.xml.FieldMapping vFieldMapping) {
335         boolean removed = _fieldMappingList.remove(vFieldMapping);
336         return removed;
337     }
338 
339     /**
340      * Method removeFieldMappingAt.
341      * 
342      * @param index
343      * @return the element removed from the collection
344      */
345     public org.exolab.castor.mapping.xml.FieldMapping removeFieldMappingAt(
346             final int index) {
347         java.lang.Object obj = this._fieldMappingList.remove(index);
348         return (org.exolab.castor.mapping.xml.FieldMapping) obj;
349     }
350 
351     /**
352      * 
353      * 
354      * @param index
355      * @param vContainer
356      * @throws java.lang.IndexOutOfBoundsException if the index
357      * given is outside the bounds of the collection
358      */
359     public void setContainer(
360             final int index,
361             final org.exolab.castor.mapping.xml.Container vContainer)
362     throws java.lang.IndexOutOfBoundsException {
363         // check bounds for index
364         if (index < 0 || index >= this._containerList.size()) {
365             throw new IndexOutOfBoundsException("setContainer: Index value '" + index + "' not in range [0.." + (this._containerList.size() - 1) + "]");
366         }
367 
368         this._containerList.set(index, vContainer);
369     }
370 
371     /**
372      * 
373      * 
374      * @param vContainerArray
375      */
376     public void setContainer(
377             final org.exolab.castor.mapping.xml.Container[] vContainerArray) {
378         //-- copy array
379         _containerList.clear();
380 
381         for (int i = 0; i < vContainerArray.length; i++) {
382                 this._containerList.add(vContainerArray[i]);
383         }
384     }
385 
386     /**
387      * 
388      * 
389      * @param index
390      * @param vFieldMapping
391      * @throws java.lang.IndexOutOfBoundsException if the index
392      * given is outside the bounds of the collection
393      */
394     public void setFieldMapping(
395             final int index,
396             final org.exolab.castor.mapping.xml.FieldMapping vFieldMapping)
397     throws java.lang.IndexOutOfBoundsException {
398         // check bounds for index
399         if (index < 0 || index >= this._fieldMappingList.size()) {
400             throw new IndexOutOfBoundsException("setFieldMapping: Index value '" + index + "' not in range [0.." + (this._fieldMappingList.size() - 1) + "]");
401         }
402 
403         this._fieldMappingList.set(index, vFieldMapping);
404     }
405 
406     /**
407      * 
408      * 
409      * @param vFieldMappingArray
410      */
411     public void setFieldMapping(
412             final org.exolab.castor.mapping.xml.FieldMapping[] vFieldMappingArray) {
413         //-- copy array
414         _fieldMappingList.clear();
415 
416         for (int i = 0; i < vFieldMappingArray.length; i++) {
417                 this._fieldMappingList.add(vFieldMappingArray[i]);
418         }
419     }
420 
421     /**
422      * Method unmarshal.
423      * 
424      * @param reader
425      * @throws org.exolab.castor.xml.MarshalException if object is
426      * null or if any SAXException is thrown during marshaling
427      * @throws org.exolab.castor.xml.ValidationException if this
428      * object is an invalid instance according to the schema
429      * @return the unmarshaled
430      * org.exolab.castor.mapping.xml.ClassChoice
431      */
432     public static org.exolab.castor.mapping.xml.ClassChoice unmarshal(
433             final java.io.Reader reader)
434     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
435         return (org.exolab.castor.mapping.xml.ClassChoice) org.exolab.castor.xml.Unmarshaller.unmarshal(org.exolab.castor.mapping.xml.ClassChoice.class, reader);
436     }
437 
438     /**
439      * 
440      * 
441      * @throws org.exolab.castor.xml.ValidationException if this
442      * object is an invalid instance according to the schema
443      */
444     public void validate(
445     )
446     throws org.exolab.castor.xml.ValidationException {
447         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
448         validator.validate(this);
449     }
450 
451 }