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