001: /*
002: * This class was automatically generated with
003: * <a href="http://www.castor.org">Castor 1.1-M2</a>, using an XML
004: * Schema.
005: * $Id$
006: */
007:
008: package org.exolab.castor.builder.binding.xml;
009:
010: //---------------------------------/
011: //- Imported classes and packages -/
012: //---------------------------------/
013:
014: import org.exolab.castor.xml.Marshaller;
015: import org.exolab.castor.xml.Unmarshaller;
016:
017: /**
018: * This type allows the mapping between an XML schema enumeration
019: * and a java class that follows the type-safe enumeration
020: * paradigm.
021: * Additionally, it allows the specify the name of the Java
022: * constant
023: * definition for a given enumeraton value.
024: *
025: *
026: * @version $Revision$ $Date$
027: */
028: public class EnumBindingType implements java.io.Serializable {
029:
030: //--------------------------/
031: //- Class/Member Variables -/
032: //--------------------------/
033:
034: /**
035: * Field _enumClassName.
036: */
037: private org.exolab.castor.builder.binding.xml.EnumClassName _enumClassName;
038:
039: /**
040: * Field _enumMemberList.
041: */
042: private java.util.List _enumMemberList;
043:
044: //----------------/
045: //- Constructors -/
046: //----------------/
047:
048: public EnumBindingType() {
049: super ();
050: this ._enumMemberList = new java.util.ArrayList();
051: }
052:
053: //-----------/
054: //- Methods -/
055: //-----------/
056:
057: /**
058: *
059: *
060: * @param vEnumMember
061: * @throws java.lang.IndexOutOfBoundsException if the index
062: * given is outside the bounds of the collection
063: */
064: public void addEnumMember(
065: final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember)
066: throws java.lang.IndexOutOfBoundsException {
067: this ._enumMemberList.add(vEnumMember);
068: }
069:
070: /**
071: *
072: *
073: * @param index
074: * @param vEnumMember
075: * @throws java.lang.IndexOutOfBoundsException if the index
076: * given is outside the bounds of the collection
077: */
078: public void addEnumMember(
079: final int index,
080: final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember)
081: throws java.lang.IndexOutOfBoundsException {
082: this ._enumMemberList.add(index, vEnumMember);
083: }
084:
085: /**
086: * Method enumerateEnumMember.
087: *
088: * @return an Enumeration over all possible elements of this
089: * collection
090: */
091: public java.util.Enumeration enumerateEnumMember() {
092: return java.util.Collections.enumeration(this ._enumMemberList);
093: }
094:
095: /**
096: * Returns the value of field 'enumClassName'.
097: *
098: * @return the value of field 'EnumClassName'.
099: */
100: public org.exolab.castor.builder.binding.xml.EnumClassName getEnumClassName() {
101: return this ._enumClassName;
102: }
103:
104: /**
105: * Method getEnumMember.
106: *
107: * @param index
108: * @throws java.lang.IndexOutOfBoundsException if the index
109: * given is outside the bounds of the collection
110: * @return the value of the
111: * org.exolab.castor.builder.binding.EnumMember at the given
112: * index
113: */
114: public org.exolab.castor.builder.binding.xml.EnumMember getEnumMember(
115: final int index) throws java.lang.IndexOutOfBoundsException {
116: // check bounds for index
117: if (index < 0 || index >= this ._enumMemberList.size()) {
118: throw new IndexOutOfBoundsException(
119: "getEnumMember: Index value '" + index
120: + "' not in range [0.."
121: + (this ._enumMemberList.size() - 1) + "]");
122: }
123:
124: return (org.exolab.castor.builder.binding.xml.EnumMember) _enumMemberList
125: .get(index);
126: }
127:
128: /**
129: * Method getEnumMember.Returns the contents of the collection
130: * in an Array. <p>Note: Just in case the collection contents
131: * are changing in another thread, we pass a 0-length Array of
132: * the correct type into the API call. This way we <i>know</i>
133: * that the Array returned is of exactly the correct length.
134: *
135: * @return this collection as an Array
136: */
137: public org.exolab.castor.builder.binding.xml.EnumMember[] getEnumMember() {
138: org.exolab.castor.builder.binding.xml.EnumMember[] array = new org.exolab.castor.builder.binding.xml.EnumMember[0];
139: return (org.exolab.castor.builder.binding.xml.EnumMember[]) this ._enumMemberList
140: .toArray(array);
141: }
142:
143: /**
144: * Method getEnumMemberCount.
145: *
146: * @return the size of this collection
147: */
148: public int getEnumMemberCount() {
149: return this ._enumMemberList.size();
150: }
151:
152: /**
153: * Method isValid.
154: *
155: * @return true if this object is valid according to the schema
156: */
157: public boolean isValid() {
158: try {
159: validate();
160: } catch (org.exolab.castor.xml.ValidationException vex) {
161: return false;
162: }
163: return true;
164: }
165:
166: /**
167: * Method iterateEnumMember.
168: *
169: * @return an Iterator over all possible elements in this
170: * collection
171: */
172: public java.util.Iterator iterateEnumMember() {
173: return this ._enumMemberList.iterator();
174: }
175:
176: /**
177: *
178: *
179: * @param out
180: * @throws org.exolab.castor.xml.MarshalException if object is
181: * null or if any SAXException is thrown during marshaling
182: * @throws org.exolab.castor.xml.ValidationException if this
183: * object is an invalid instance according to the schema
184: */
185: public void marshal(final java.io.Writer out)
186: throws org.exolab.castor.xml.MarshalException,
187: org.exolab.castor.xml.ValidationException {
188: Marshaller.marshal(this , out);
189: }
190:
191: /**
192: *
193: *
194: * @param handler
195: * @throws java.io.IOException if an IOException occurs during
196: * marshaling
197: * @throws org.exolab.castor.xml.ValidationException if this
198: * object is an invalid instance according to the schema
199: * @throws org.exolab.castor.xml.MarshalException if object is
200: * null or if any SAXException is thrown during marshaling
201: */
202: public void marshal(final org.xml.sax.ContentHandler handler)
203: throws java.io.IOException,
204: org.exolab.castor.xml.MarshalException,
205: org.exolab.castor.xml.ValidationException {
206: Marshaller.marshal(this , handler);
207: }
208:
209: /**
210: */
211: public void removeAllEnumMember() {
212: this ._enumMemberList.clear();
213: }
214:
215: /**
216: * Method removeEnumMember.
217: *
218: * @param vEnumMember
219: * @return true if the object was removed from the collection.
220: */
221: public boolean removeEnumMember(
222: final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember) {
223: boolean removed = _enumMemberList.remove(vEnumMember);
224: return removed;
225: }
226:
227: /**
228: * Method removeEnumMemberAt.
229: *
230: * @param index
231: * @return the element removed from the collection
232: */
233: public org.exolab.castor.builder.binding.xml.EnumMember removeEnumMemberAt(
234: final int index) {
235: java.lang.Object obj = this ._enumMemberList.remove(index);
236: return (org.exolab.castor.builder.binding.xml.EnumMember) obj;
237: }
238:
239: /**
240: * Sets the value of field 'enumClassName'.
241: *
242: * @param enumClassName the value of field 'enumClassName'.
243: */
244: public void setEnumClassName(
245: final org.exolab.castor.builder.binding.xml.EnumClassName enumClassName) {
246: this ._enumClassName = enumClassName;
247: }
248:
249: /**
250: *
251: *
252: * @param index
253: * @param vEnumMember
254: * @throws java.lang.IndexOutOfBoundsException if the index
255: * given is outside the bounds of the collection
256: */
257: public void setEnumMember(
258: final int index,
259: final org.exolab.castor.builder.binding.xml.EnumMember vEnumMember)
260: throws java.lang.IndexOutOfBoundsException {
261: // check bounds for index
262: if (index < 0 || index >= this ._enumMemberList.size()) {
263: throw new IndexOutOfBoundsException(
264: "setEnumMember: Index value '" + index
265: + "' not in range [0.."
266: + (this ._enumMemberList.size() - 1) + "]");
267: }
268:
269: this ._enumMemberList.set(index, vEnumMember);
270: }
271:
272: /**
273: *
274: *
275: * @param vEnumMemberArray
276: */
277: public void setEnumMember(
278: final org.exolab.castor.builder.binding.xml.EnumMember[] vEnumMemberArray) {
279: //-- copy array
280: _enumMemberList.clear();
281:
282: for (int i = 0; i < vEnumMemberArray.length; i++) {
283: this ._enumMemberList.add(vEnumMemberArray[i]);
284: }
285: }
286:
287: /**
288: * Method unmarshalEnumBindingType.
289: *
290: * @param reader
291: * @throws org.exolab.castor.xml.MarshalException if object is
292: * null or if any SAXException is thrown during marshaling
293: * @throws org.exolab.castor.xml.ValidationException if this
294: * object is an invalid instance according to the schema
295: * @return the unmarshaled
296: * org.exolab.castor.builder.binding.EnumBindingType
297: */
298: public static org.exolab.castor.builder.binding.xml.EnumBindingType unmarshalEnumBindingType(
299: final java.io.Reader reader)
300: throws org.exolab.castor.xml.MarshalException,
301: org.exolab.castor.xml.ValidationException {
302: return (org.exolab.castor.builder.binding.xml.EnumBindingType) Unmarshaller
303: .unmarshal(
304: org.exolab.castor.builder.binding.xml.EnumBindingType.class,
305: reader);
306: }
307:
308: /**
309: *
310: *
311: * @throws org.exolab.castor.xml.ValidationException if this
312: * object is an invalid instance according to the schema
313: */
314: public void validate()
315: throws org.exolab.castor.xml.ValidationException {
316: org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
317: validator.validate(this);
318: }
319:
320: }
|