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