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 the restriction of simpleType elements. Represents the World
24   * Wide Web Consortium (W3C) restriction element for simple types.
25   */
26  
27  public class XmlSchemaSimpleTypeRestriction extends XmlSchemaSimpleTypeContent {
28  
29      /**
30       * Creates new XmlSchemaSimpleTypeRestriction
31       */
32      public XmlSchemaSimpleTypeRestriction() {
33          facets = new XmlSchemaObjectCollection();
34      }
35  
36      XmlSchemaSimpleType baseType;
37  
38      public XmlSchemaSimpleType getBaseType() {
39          return this.baseType;
40      }
41  
42      public void setBaseType(XmlSchemaSimpleType baseType) {
43          this.baseType = baseType;
44      }
45  
46      QName baseTypeName;
47  
48      public QName getBaseTypeName() {
49          return this.baseTypeName;
50      }
51  
52      public void setBaseTypeName(QName baseTypeName) {
53          this.baseTypeName = baseTypeName;
54      }
55  
56      XmlSchemaObjectCollection facets;// = new XmlSchemaObjectCollection();
57  
58      public XmlSchemaObjectCollection getFacets() {
59          return this.facets;
60      }
61  
62      public String toString(String prefix, int tab) {
63          String xml = new String();
64  
65          if (!prefix.equals("") && prefix.indexOf(":") == -1)
66              prefix += ":";
67  
68          for (int i = 0; i < tab; i++)
69              xml += "\t";
70  
71          xml += "<" + prefix + "restriction ";
72  
73          if (baseTypeName != null) {
74              xml += "base =\"" + baseTypeName + "\">\n";
75          } else {
76              xml += ">\n";
77              // inline def
78              xml += baseType.toString(prefix, (tab + 1));
79          }
80  
81          xml += facets.toString(prefix, (tab + 1));
82          for (int i = 0; i < tab; i++)
83              xml += "\t";
84          xml += "</" + prefix + "restriction>\n";
85  
86  
87          return xml;
88  
89      }
90  
91  }