001: /*
002: * This class was automatically generated with
003: * <a href="http://www.castor.org">Castor 1.1</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: * Class Forces.
019: *
020: * @version $Revision$ $Date$
021: */
022: public class Forces implements java.io.Serializable {
023:
024: //--------------------------/
025: //- Class/Member Variables -/
026: //--------------------------/
027:
028: /**
029: * Field _forceList.
030: */
031: private java.util.List _forceList;
032:
033: //----------------/
034: //- Constructors -/
035: //----------------/
036:
037: public Forces() {
038: super ();
039: this ._forceList = new java.util.ArrayList();
040: }
041:
042: //-----------/
043: //- Methods -/
044: //-----------/
045:
046: /**
047: *
048: *
049: * @param vForce
050: * @throws java.lang.IndexOutOfBoundsException if the index
051: * given is outside the bounds of the collection
052: */
053: public void addForce(final java.lang.String vForce)
054: throws java.lang.IndexOutOfBoundsException {
055: this ._forceList.add(vForce);
056: }
057:
058: /**
059: *
060: *
061: * @param index
062: * @param vForce
063: * @throws java.lang.IndexOutOfBoundsException if the index
064: * given is outside the bounds of the collection
065: */
066: public void addForce(final int index, final java.lang.String vForce)
067: throws java.lang.IndexOutOfBoundsException {
068: this ._forceList.add(index, vForce);
069: }
070:
071: /**
072: * Method enumerateForce.
073: *
074: * @return an Enumeration over all possible elements of this
075: * collection
076: */
077: public java.util.Enumeration enumerateForce() {
078: return java.util.Collections.enumeration(this ._forceList);
079: }
080:
081: /**
082: * Method getForce.
083: *
084: * @param index
085: * @throws java.lang.IndexOutOfBoundsException if the index
086: * given is outside the bounds of the collection
087: * @return the value of the java.lang.String at the given index
088: */
089: public java.lang.String getForce(final int index)
090: throws java.lang.IndexOutOfBoundsException {
091: // check bounds for index
092: if (index < 0 || index >= this ._forceList.size()) {
093: throw new IndexOutOfBoundsException(
094: "getForce: Index value '" + index
095: + "' not in range [0.."
096: + (this ._forceList.size() - 1) + "]");
097: }
098:
099: return (java.lang.String) _forceList.get(index);
100: }
101:
102: /**
103: * Method getForce.Returns the contents of the collection in an
104: * Array. <p>Note: Just in case the collection contents are
105: * changing in another thread, we pass a 0-length Array of the
106: * correct type into the API call. This way we <i>know</i>
107: * that the Array returned is of exactly the correct length.
108: *
109: * @return this collection as an Array
110: */
111: public java.lang.String[] getForce() {
112: java.lang.String[] array = new java.lang.String[0];
113: return (java.lang.String[]) this ._forceList.toArray(array);
114: }
115:
116: /**
117: * Method getForceCount.
118: *
119: * @return the size of this collection
120: */
121: public int getForceCount() {
122: return this ._forceList.size();
123: }
124:
125: /**
126: * Method isValid.
127: *
128: * @return true if this object is valid according to the schema
129: */
130: public boolean isValid() {
131: try {
132: validate();
133: } catch (org.exolab.castor.xml.ValidationException vex) {
134: return false;
135: }
136: return true;
137: }
138:
139: /**
140: * Method iterateForce.
141: *
142: * @return an Iterator over all possible elements in this
143: * collection
144: */
145: public java.util.Iterator iterateForce() {
146: return this ._forceList.iterator();
147: }
148:
149: /**
150: *
151: *
152: * @param out
153: * @throws org.exolab.castor.xml.MarshalException if object is
154: * null or if any SAXException is thrown during marshaling
155: * @throws org.exolab.castor.xml.ValidationException if this
156: * object is an invalid instance according to the schema
157: */
158: public void marshal(final java.io.Writer out)
159: throws org.exolab.castor.xml.MarshalException,
160: org.exolab.castor.xml.ValidationException {
161: Marshaller.marshal(this , out);
162: }
163:
164: /**
165: *
166: *
167: * @param handler
168: * @throws java.io.IOException if an IOException occurs during
169: * marshaling
170: * @throws org.exolab.castor.xml.ValidationException if this
171: * object is an invalid instance according to the schema
172: * @throws org.exolab.castor.xml.MarshalException if object is
173: * null or if any SAXException is thrown during marshaling
174: */
175: public void marshal(final org.xml.sax.ContentHandler handler)
176: throws java.io.IOException,
177: org.exolab.castor.xml.MarshalException,
178: org.exolab.castor.xml.ValidationException {
179: Marshaller.marshal(this , handler);
180: }
181:
182: /**
183: */
184: public void removeAllForce() {
185: this ._forceList.clear();
186: }
187:
188: /**
189: * Method removeForce.
190: *
191: * @param vForce
192: * @return true if the object was removed from the collection.
193: */
194: public boolean removeForce(final java.lang.String vForce) {
195: boolean removed = _forceList.remove(vForce);
196: return removed;
197: }
198:
199: /**
200: * Method removeForceAt.
201: *
202: * @param index
203: * @return the element removed from the collection
204: */
205: public java.lang.String removeForceAt(final int index) {
206: java.lang.Object obj = this ._forceList.remove(index);
207: return (java.lang.String) obj;
208: }
209:
210: /**
211: *
212: *
213: * @param index
214: * @param vForce
215: * @throws java.lang.IndexOutOfBoundsException if the index
216: * given is outside the bounds of the collection
217: */
218: public void setForce(final int index, final java.lang.String vForce)
219: throws java.lang.IndexOutOfBoundsException {
220: // check bounds for index
221: if (index < 0 || index >= this ._forceList.size()) {
222: throw new IndexOutOfBoundsException(
223: "setForce: Index value '" + index
224: + "' not in range [0.."
225: + (this ._forceList.size() - 1) + "]");
226: }
227:
228: this ._forceList.set(index, vForce);
229: }
230:
231: /**
232: *
233: *
234: * @param vForceArray
235: */
236: public void setForce(final java.lang.String[] vForceArray) {
237: //-- copy array
238: _forceList.clear();
239:
240: for (int i = 0; i < vForceArray.length; i++) {
241: this ._forceList.add(vForceArray[i]);
242: }
243: }
244:
245: /**
246: * Method unmarshalForces.
247: *
248: * @param reader
249: * @throws org.exolab.castor.xml.MarshalException if object is
250: * null or if any SAXException is thrown during marshaling
251: * @throws org.exolab.castor.xml.ValidationException if this
252: * object is an invalid instance according to the schema
253: * @return the unmarshaled
254: * org.exolab.castor.builder.binding.xml.Forces
255: */
256: public static org.exolab.castor.builder.binding.xml.Forces unmarshalForces(
257: final java.io.Reader reader)
258: throws org.exolab.castor.xml.MarshalException,
259: org.exolab.castor.xml.ValidationException {
260: return (org.exolab.castor.builder.binding.xml.Forces) Unmarshaller
261: .unmarshal(
262: org.exolab.castor.builder.binding.xml.Forces.class,
263: reader);
264: }
265:
266: /**
267: *
268: *
269: * @throws org.exolab.castor.xml.ValidationException if this
270: * object is an invalid instance according to the schema
271: */
272: public void validate()
273: throws org.exolab.castor.xml.ValidationException {
274: org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
275: validator.validate(this);
276: }
277:
278: }
|