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 org.apache.ws.commons.schema.constants.Constants;
23  
24  import javax.xml.namespace.QName;
25  
26  
27  /**
28   * The base class for all simple types and complex types.
29   */
30  
31  public class XmlSchemaType extends XmlSchemaAnnotated {
32  
33      Object baseSchemaType;
34      XmlSchemaDatatype dataType;
35      XmlSchemaDerivationMethod deriveBy, finalDerivation, finalResolved;
36      boolean isMixed;
37  
38      // name of the type
39      String name;
40  
41      XmlSchema schema;
42  
43      /**
44       * Creates new XmlSchemaType
45       */
46      public XmlSchemaType(XmlSchema schema) {
47          this.schema = schema;
48          finalDerivation = new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
49      }
50  
51      public Object getBaseSchemaType() {
52          return baseSchemaType;
53      }
54  
55      public XmlSchemaDatatype getDataType() {
56          return dataType;
57      }
58  
59      public XmlSchemaDerivationMethod getDeriveBy() {
60          return deriveBy;
61      }
62  
63      public XmlSchemaDerivationMethod getFinal() {
64          return finalDerivation;
65      }
66  
67      public void setFinal(XmlSchemaDerivationMethod finalDerivation) {
68          this.finalDerivation = finalDerivation;
69      }
70  
71      public XmlSchemaDerivationMethod getFinalResolved() {
72          return finalResolved;
73      }
74  
75      public boolean isMixed() {
76          return isMixed;
77      }
78  
79      public void setMixed(boolean isMixed) {
80          this.isMixed = isMixed;
81      }
82  
83      public String getName() {
84          return name;
85      }
86  
87      public void setName(String name) {
88          this.name = name;
89      }
90  
91      public QName getQName() {
92          if(name == null) {
93              return null;
94          }
95          return new QName(schema.logicalTargetNamespace, name);
96      }
97      
98      public String toString() {
99      	if(name == null) {
100     		return super.toString() + "[anonymous]";
101     	} else if (schema.logicalTargetNamespace == null) {
102     		return super.toString() + "[{}" + name + "]";
103     		
104     	} else {
105     		return super.toString() + "[{" + schema.logicalTargetNamespace + "}" + name + "]";
106     	}
107     }
108 }