View Javadoc

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