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 javax.xml.namespace.QName;
23  
24  
25  /**
26   * Class for complex types with a complex content model that are derived
27   * by restriction. Restricts the contents of the complex type to a subset
28   * of the inherited complex type. Represents the World Wide Web Consortium
29   * (W3C) restriction element for complex content.
30   */
31  
32  public class XmlSchemaComplexContentRestriction extends XmlSchemaContent {
33  
34      /**
35       * Creates new XmlSchemaComplexContentRestriction
36       */
37      public XmlSchemaComplexContentRestriction() {
38          attributes = new XmlSchemaObjectCollection();
39      }
40  
41      /* Allows an XmlSchemaAnyAttribute to be used for the attribute value.*/
42      XmlSchemaAnyAttribute anyAttribute;
43  
44      public void setAnyAttribute(XmlSchemaAnyAttribute anyAttribute) {
45          this.anyAttribute = anyAttribute;
46      }
47  
48      public XmlSchemaAnyAttribute getAnyAttribute() {
49          return this.anyAttribute;
50      }
51  
52      /* Contains XmlSchemaAttribute and XmlSchemaAttributeGroupRef. 
53  	 *  Collection of attributes for the simple type.
54  	 */
55      XmlSchemaObjectCollection attributes;
56  
57      public XmlSchemaObjectCollection getAttributes() {
58          return this.attributes;
59      }
60  
61      /* Name of the built-in data type, simple type, or complex type.*/
62      QName baseTypeName;
63  
64      public void setBaseTypeName(QName baseTypeName) {
65          this.baseTypeName = baseTypeName;
66      }
67  
68      public QName getBaseTypeName() {
69          return this.baseTypeName;
70      }
71  
72      /*One of the XmlSchemaGroupRef, XmlSchemaChoice, XmlSchemaAll, 
73  	 * or XmlSchemaSequence classes.
74  	 */
75      XmlSchemaParticle particle;
76  
77      public XmlSchemaParticle getParticle() {
78          return this.particle;
79      }
80  
81      public void setParticle(XmlSchemaParticle particle) {
82          this.particle = particle;
83      }
84  
85      public String toString(String prefix, int tab) {
86          String xml = new String();
87          for (int i = 0; i < tab; i++)
88              xml += "\t";
89          if (!prefix.equals("") && prefix.indexOf(":") == -1)
90              prefix += ":";
91  
92          xml += "<" + prefix + "restriction>\n";
93  
94          if (particle != null)
95              xml += particle.toString(prefix, (tab + 1));
96  
97          for (int i = 0; i < tab; i++)
98              xml += "\t";
99  
100         xml += "</" + prefix + "restriction>\n";
101         return xml;
102     }
103 }
104