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.builder.binding.xml;
9   
10  /**
11   * This type allows the mapping between an XML schema enumeration
12   *  and a java class that follows the type-safe enumeration
13   * paradigm.
14   *  Additionally, it allows the specify the name of the Java
15   * constant
16   *  definition for a given enumeraton value.
17   *  
18   * 
19   * @version $Revision$ $Date$
20   */
21  public class EnumBindingType implements java.io.Serializable {
22  
23  
24        //--------------------------/
25       //- Class/Member Variables -/
26      //--------------------------/
27  
28      /**
29       * Field _enumClassName.
30       */
31      private org.exolab.castor.builder.binding.xml.EnumClassName _enumClassName;
32  
33      /**
34       * Field _enumMemberList.
35       */
36      private java.util.List _enumMemberList;
37  
38  
39        //----------------/
40       //- Constructors -/
41      //----------------/
42  
43      public EnumBindingType() {
44          super();
45          this._enumMemberList = new java.util.ArrayList();
46      }
47  
48  
49        //-----------/
50       //- Methods -/
51      //-----------/
52  
53      /**
54       * 
55       * 
56       * @param vEnumMember
57       * @throws java.lang.IndexOutOfBoundsException if the index
58       * given is outside the bounds of the collection
59       */
60      public void addEnumMember(
61              final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember)
62      throws java.lang.IndexOutOfBoundsException {
63          this._enumMemberList.add(vEnumMember);
64      }
65  
66      /**
67       * 
68       * 
69       * @param index
70       * @param vEnumMember
71       * @throws java.lang.IndexOutOfBoundsException if the index
72       * given is outside the bounds of the collection
73       */
74      public void addEnumMember(
75              final int index,
76              final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember)
77      throws java.lang.IndexOutOfBoundsException {
78          this._enumMemberList.add(index, vEnumMember);
79      }
80  
81      /**
82       * Method enumerateEnumMember.
83       * 
84       * @return an Enumeration over all possible elements of this
85       * collection
86       */
87      public java.util.Enumeration enumerateEnumMember(
88      ) {
89          return java.util.Collections.enumeration(this._enumMemberList);
90      }
91  
92      /**
93       * Returns the value of field 'enumClassName'.
94       * 
95       * @return the value of field 'EnumClassName'.
96       */
97      public org.exolab.castor.builder.binding.xml.EnumClassName getEnumClassName(
98      ) {
99          return this._enumClassName;
100     }
101 
102     /**
103      * Method getEnumMember.
104      * 
105      * @param index
106      * @throws java.lang.IndexOutOfBoundsException if the index
107      * given is outside the bounds of the collection
108      * @return the value of the
109      * org.exolab.castor.builder.binding.xml.EnumMember at the
110      * given index
111      */
112     public org.exolab.castor.builder.binding.xml.EnumMember getEnumMember(
113             final int index)
114     throws java.lang.IndexOutOfBoundsException {
115         // check bounds for index
116         if (index < 0 || index >= this._enumMemberList.size()) {
117             throw new IndexOutOfBoundsException("getEnumMember: Index value '" + index + "' not in range [0.." + (this._enumMemberList.size() - 1) + "]");
118         }
119 
120         return (org.exolab.castor.builder.binding.xml.EnumMember) _enumMemberList.get(index);
121     }
122 
123     /**
124      * Method getEnumMember.Returns the contents of the collection
125      * in an Array.  <p>Note:  Just in case the collection contents
126      * are changing in another thread, we pass a 0-length Array of
127      * the correct type into the API call.  This way we <i>know</i>
128      * that the Array returned is of exactly the correct length.
129      * 
130      * @return this collection as an Array
131      */
132     public org.exolab.castor.builder.binding.xml.EnumMember[] getEnumMember(
133     ) {
134         org.exolab.castor.builder.binding.xml.EnumMember[] array = new org.exolab.castor.builder.binding.xml.EnumMember[0];
135         return (org.exolab.castor.builder.binding.xml.EnumMember[]) this._enumMemberList.toArray(array);
136     }
137 
138     /**
139      * Method getEnumMemberCount.
140      * 
141      * @return the size of this collection
142      */
143     public int getEnumMemberCount(
144     ) {
145         return this._enumMemberList.size();
146     }
147 
148     /**
149      * Method isValid.
150      * 
151      * @return true if this object is valid according to the schema
152      */
153     public boolean isValid(
154     ) {
155         try {
156             validate();
157         } catch (org.exolab.castor.xml.ValidationException vex) {
158             return false;
159         }
160         return true;
161     }
162 
163     /**
164      * Method iterateEnumMember.
165      * 
166      * @return an Iterator over all possible elements in this
167      * collection
168      */
169     public java.util.Iterator iterateEnumMember(
170     ) {
171         return this._enumMemberList.iterator();
172     }
173 
174     /**
175      * 
176      * 
177      * @param out
178      * @throws org.exolab.castor.xml.MarshalException if object is
179      * null or if any SAXException is thrown during marshaling
180      * @throws org.exolab.castor.xml.ValidationException if this
181      * object is an invalid instance according to the schema
182      */
183     public void marshal(
184             final java.io.Writer out)
185     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
186         org.exolab.castor.xml.Marshaller.marshal(this, out);
187     }
188 
189     /**
190      * 
191      * 
192      * @param handler
193      * @throws java.io.IOException if an IOException occurs during
194      * marshaling
195      * @throws org.exolab.castor.xml.ValidationException if this
196      * object is an invalid instance according to the schema
197      * @throws org.exolab.castor.xml.MarshalException if object is
198      * null or if any SAXException is thrown during marshaling
199      */
200     public void marshal(
201             final org.xml.sax.ContentHandler handler)
202     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
203         org.exolab.castor.xml.Marshaller.marshal(this, handler);
204     }
205 
206     /**
207      */
208     public void removeAllEnumMember(
209     ) {
210         this._enumMemberList.clear();
211     }
212 
213     /**
214      * Method removeEnumMember.
215      * 
216      * @param vEnumMember
217      * @return true if the object was removed from the collection.
218      */
219     public boolean removeEnumMember(
220             final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember) {
221         boolean removed = _enumMemberList.remove(vEnumMember);
222         return removed;
223     }
224 
225     /**
226      * Method removeEnumMemberAt.
227      * 
228      * @param index
229      * @return the element removed from the collection
230      */
231     public org.exolab.castor.builder.binding.xml.EnumMember removeEnumMemberAt(
232             final int index) {
233         java.lang.Object obj = this._enumMemberList.remove(index);
234         return (org.exolab.castor.builder.binding.xml.EnumMember) obj;
235     }
236 
237     /**
238      * Sets the value of field 'enumClassName'.
239      * 
240      * @param enumClassName the value of field 'enumClassName'.
241      */
242     public void setEnumClassName(
243             final org.exolab.castor.builder.binding.xml.EnumClassName enumClassName) {
244         this._enumClassName = enumClassName;
245     }
246 
247     /**
248      * 
249      * 
250      * @param index
251      * @param vEnumMember
252      * @throws java.lang.IndexOutOfBoundsException if the index
253      * given is outside the bounds of the collection
254      */
255     public void setEnumMember(
256             final int index,
257             final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember)
258     throws java.lang.IndexOutOfBoundsException {
259         // check bounds for index
260         if (index < 0 || index >= this._enumMemberList.size()) {
261             throw new IndexOutOfBoundsException("setEnumMember: Index value '" + index + "' not in range [0.." + (this._enumMemberList.size() - 1) + "]");
262         }
263 
264         this._enumMemberList.set(index, vEnumMember);
265     }
266 
267     /**
268      * 
269      * 
270      * @param vEnumMemberArray
271      */
272     public void setEnumMember(
273             final org.exolab.castor.builder.binding.xml.EnumMember[] vEnumMemberArray) {
274         //-- copy array
275         _enumMemberList.clear();
276 
277         for (int i = 0; i < vEnumMemberArray.length; i++) {
278                 this._enumMemberList.add(vEnumMemberArray[i]);
279         }
280     }
281 
282     /**
283      * Method unmarshalEnumBindingType.
284      * 
285      * @param reader
286      * @throws org.exolab.castor.xml.MarshalException if object is
287      * null or if any SAXException is thrown during marshaling
288      * @throws org.exolab.castor.xml.ValidationException if this
289      * object is an invalid instance according to the schema
290      * @return the unmarshaled
291      * org.exolab.castor.builder.binding.xml.EnumBindingType
292      */
293     public static org.exolab.castor.builder.binding.xml.EnumBindingType unmarshalEnumBindingType(
294             final java.io.Reader reader)
295     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
296         return (org.exolab.castor.builder.binding.xml.EnumBindingType) org.exolab.castor.xml.Unmarshaller.unmarshal(org.exolab.castor.builder.binding.xml.EnumBindingType.class, reader);
297     }
298 
299     /**
300      * 
301      * 
302      * @throws org.exolab.castor.xml.ValidationException if this
303      * object is an invalid instance according to the schema
304      */
305     public void validate(
306     )
307     throws org.exolab.castor.xml.ValidationException {
308         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
309         validator.validate(this);
310     }
311 
312 }