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  /**
23   * Class that represents the complex content model for complex types.
24   * Contains extensions or restrictions on a complex type that has mixed
25   * content or elements only. Represents the World Wide Web Consortium (W3C)
26   * complexContent element.
27   */
28  
29  // Vidyanand - 16th Oct - initial implementation
30  
31  public class XmlSchemaComplexContent extends XmlSchemaContentModel {
32  
33      /**
34       * Creates new XmlSchemaComplexContent
35       */
36      public XmlSchemaComplexContent() {
37      }
38  
39      /* One of either the XmlSchemaComplexContentRestriction or 
40  	 * XmlSchemaComplexContentExtension classes.
41  	 */
42      XmlSchemaContent content;
43  
44      public XmlSchemaContent getContent() {
45          return this.content;
46      }
47  
48      public void setContent(XmlSchemaContent content) {
49          this.content = content;
50      }
51  
52      /* Indicates that this type has a mixed content model. Character data
53  	 * is allowed to appear between the child elements of the complex type. 
54  	 */
55      public boolean mixed;
56  
57      public boolean isMixed() {
58          return this.mixed;
59      }
60  
61      public void setMixed(boolean mixed) {
62          this.mixed = mixed;
63      }
64  
65      public String toString(String prefix, int tab) {
66          String xml = new String();
67          for (int i = 0; i < tab; i++)
68              xml += "\t";
69  
70          if (!prefix.equals("") && prefix.indexOf(":") == -1)
71              prefix += ":";
72  
73          xml += "<" + prefix + "complexContent>\n";
74  
75          xml += content.toString(prefix, (tab + 1));
76  
77          for (int i = 0; i < tab; i++)
78              xml += "\t";
79          xml += "<" + prefix + "complexContent>\n";
80          return xml;
81      }
82  }