View Javadoc

1   /*
2    * Copyright 2004,2007 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.ws.commons.schema;
18  
19  import java.util.Iterator;
20  import java.util.Vector;
21  
22  /**
23   * An object collection class to handle XmlSchemaObjects when collections
24   * are returned from method calls.
25   */
26  public class XmlSchemaObjectCollection {
27  
28      Vector objects;
29  
30      /**
31       * Creates new XmlSchemaObjectCollection
32       */
33      public XmlSchemaObjectCollection() {
34          objects = new Vector();
35      }
36  
37      public int getCount() {
38          return objects.size();
39      }
40  
41      public XmlSchemaObject getItem(int i) {
42          return (XmlSchemaObject) objects.elementAt(i);
43      }
44  
45      public void setItem(int i, XmlSchemaObject item) {
46          objects.insertElementAt(item, i);
47      }
48  
49      public void add(XmlSchemaObject item) {
50          objects.addElement(item);
51      }
52  
53      public boolean contains(XmlSchemaObject item) {
54          return objects.contains(item);
55      }
56  
57      public int indexOf(XmlSchemaObject item) {
58          return objects.indexOf(item);
59      }
60  
61      public void remove(XmlSchemaObject item) {
62          objects.remove(item);
63      }
64  
65      public void removeAt(int index) {
66          objects.removeElementAt(index);
67      }
68  
69      public Iterator getIterator() {
70          return objects.iterator();
71      }
72  
73      public String toString(String prefix, int tab) {
74          String xml = new String();
75  
76          for (int i = 0; i < getCount(); i++) {
77              xml += getItem(i).toString(prefix, tab);
78          }
79  
80  
81          return xml;
82  
83      }
84  }