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