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      /**
    52       * This function returns null. It is intended at some point to return the base type in the event of a restriction,
    53       * but that functionality is not implemented.
    54       * @see #getBaseSchemaTypeName()
    55       * @return null
    56       */
    57      public Object getBaseSchemaType() {
    58          return baseSchemaType;
    59      }
    60
    61      /**
    62       * If there is a base schema type, which by definition has to have a global name, return it.
    63       * @return the qualified name of the base schema type. Return null if none (e.g. for simple types).
    64       */
    65      public QName getBaseSchemaTypeName() {
    66      	return null;
    67      }
    68
    69      public XmlSchemaDatatype getDataType() {
    70          return dataType;
    71      }
    72
    73      public XmlSchemaDerivationMethod getDeriveBy() {
    74          return deriveBy;
    75      }
    76
    77      public XmlSchemaDerivationMethod getFinal() {
    78          return finalDerivation;
    79      }
    80
    81      public void setFinal(XmlSchemaDerivationMethod finalDerivation) {
    82          this.finalDerivation = finalDerivation;
    83      }
    84
    85      public XmlSchemaDerivationMethod getFinalResolved() {
    86          return finalResolved;
    87      }
    88
    89      public boolean isMixed() {
    90          return isMixed;
    91      }
    92
    93      public void setMixed(boolean isMixed) {
    94          this.isMixed = isMixed;
    95      }
    96
    97      public String getName() {
    98          return name;
    99      }
    100
    101     public void setName(String name) {
    102         this.name = name;
    103     }
    104
    105     public QName getQName() {
    106         if(name == null) {
    107             return null;
    108         }
    109         return new QName(schema.logicalTargetNamespace, name);
    110     }
    111
    112     public String toString() {
    113     	if(name == null) {
    114     		return super.toString() + "[anonymous]";
    115     	} else if (schema.logicalTargetNamespace == null) {
    116     		return super.toString() + "[{}" + name + "]";
    117
    118     	} else {
    119     		return super.toString() + "[{" + schema.logicalTargetNamespace + "}" + name + "]";
    120     	}
    121     }
    122 }