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  /**
20   * Requires the elements in the group to appear in the specified sequence
21   * within the containing element. Represents the World Wide Web Consortium
22   * (W3C) sequence (compositor) element.
23   */
24  
25  public class XmlSchemaSequence extends XmlSchemaGroupBase {
26  
27      /**
28       * Creates new XmlSchemaSequence
29       */
30      public XmlSchemaSequence() {
31      }
32  
33      /**
34       * The elements contained within the compositor.
35       * Collection of XmlSchemaElement, XmlSchemaGroupRef,
36       * XmlSchemaChoice, XmlSchemaSequence, or XmlSchemaAny.
37       */
38      public XmlSchemaObjectCollection getItems() {
39          return items;
40      }
41  
42      public String toString(String prefix, int tab) {
43          String xml = new String();
44          for (int i = 0; i < tab; i++)
45              xml += "\t";
46          if (!prefix.equals("") && prefix.indexOf(":") == -1)
47              prefix += ":";
48  
49          xml += "<" + prefix + "sequence>\n";
50          for (int i = 0; i < items.getCount(); i++) {
51              xml += items.getItem(i).toString(prefix, (tab + 1));
52          }
53  
54          for (int i = 0; i < tab; i++)
55              xml += "\t";
56  
57          xml += "</" + prefix + "sequence>\n";
58          return xml;
59      }
60  }