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 defines a simple type that determines the information and
21   * constraints for the values of attributes or elements with text-only
22   * content. Represents the World Wide Web Consortium (W3C) simpleType element.
23   */
24  
25  public class XmlSchemaSimpleType extends XmlSchemaType {
26  
27      XmlSchemaSimpleTypeContent content;
28  
29      /**
30       * Creates new XmlSchemaSimpleType
31       */
32      public XmlSchemaSimpleType(XmlSchema schema) {
33          super(schema);
34      }
35  
36      public XmlSchemaSimpleTypeContent getContent() {
37          return content;
38      }
39  
40      public void setContent(XmlSchemaSimpleTypeContent content) {
41          this.content = content;
42      }
43  
44      public String toString(String prefix, int tab) {
45          String xml = new String();
46  
47          for (int i = 0; i < tab; i++)
48              xml += "\t";
49  
50          if (!prefix.equals("") && prefix.indexOf(":") == -1)
51              prefix += ":";
52  
53  
54          xml += "<" + prefix + "simpleType>\n";
55  
56          if (content != null)
57              xml += content.toString(prefix, (tab + 1));
58  
59          for (int i = 0; i < tab; i++)
60              xml += "\t";
61  
62          xml += "</" + prefix + "simpleType>\n";
63          return xml;
64      }
65  
66  }
67