1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2001-2005 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.impl.xs;
  22 
  23 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
  24 import com.sun.org.apache.xerces.internal.xs.*;
  25 import com.sun.org.apache.xerces.internal.impl.xs.models.XSCMValidator;
  26 import com.sun.org.apache.xerces.internal.impl.xs.models.CMBuilder;
  27 import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
  28 import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
  29 import org.w3c.dom.TypeInfo;
  30 
  31 /**
  32  * The XML representation for a complexType
  33  * schema component is a <complexType> element information item
  34  *
  35  * @xerces.internal
  36  *
  37  * @author Elena Litani, IBM
  38  * @author Sandy Gao, IBM
  39  * @version $Id: XSComplexTypeDecl.java,v 1.8 2010-11-01 04:39:55 joehw Exp $
  40  */
  41 public class XSComplexTypeDecl implements XSComplexTypeDefinition, TypeInfo {
  42 
  43     // name of the complexType
  44     String fName = null;
  45 
  46     // target namespace of the complexType
  47     String fTargetNamespace = null;
  48 
  49     // base type of the complexType
  50     XSTypeDefinition fBaseType = null;
  51 
  52     // derivation method of the complexType
  53     short fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
  54 
  55     // final set of the complexType
  56     short fFinal = XSConstants.DERIVATION_NONE;
  57 
  58     // block set (prohibited substitution) of the complexType
  59     short fBlock = XSConstants.DERIVATION_NONE;
  60 
  61     // flags: whether is abstract; whether contains ID type;
  62     //        whether it's an anonymous tpye
  63     short fMiscFlags = 0;
  64 
  65     // the attribute group that holds the attribute uses and attribute wildcard
  66     XSAttributeGroupDecl fAttrGrp = null;
  67 
  68     // the content type of the complexType
  69     short fContentType = CONTENTTYPE_EMPTY;
  70 
  71     // if the content type is simple, then the corresponding simpleType
  72     XSSimpleType fXSSimpleType = null;
  73 
  74     // if the content type is element or mixed, the particle
  75     XSParticleDecl fParticle = null;
  76 
  77     // if there is a particle, the content model corresponding to that particle
  78     volatile XSCMValidator fCMValidator = null;
  79 
  80     // the content model that's sufficient for computing UPA
  81     XSCMValidator fUPACMValidator = null;
  82 
  83     // list of annotations affiliated with this type
  84     XSObjectListImpl fAnnotations = null;
  85 
  86     // The namespace schema information item corresponding to the target namespace
  87     // of the complex type definition, if it is globally declared; or null otherwise.
  88     private XSNamespaceItem fNamespaceItem = null;
  89 
  90     // DOM Level 3 TypeInfo Derivation Method constants
  91     static final int DERIVATION_ANY = 0;
  92     static final int DERIVATION_RESTRICTION = 1;
  93     static final int DERIVATION_EXTENSION = 2;
  94     static final int DERIVATION_UNION = 4;
  95     static final int DERIVATION_LIST = 8;
  96 
  97     public XSComplexTypeDecl() {
  98         // do-nothing constructor for now.
  99     }
 100 
 101     public void setValues(String name, String targetNamespace,
 102             XSTypeDefinition baseType, short derivedBy, short schemaFinal,
 103             short block, short contentType,
 104             boolean isAbstract, XSAttributeGroupDecl attrGrp,
 105             XSSimpleType simpleType, XSParticleDecl particle,
 106             XSObjectListImpl annotations) {
 107         fTargetNamespace = targetNamespace;
 108         fBaseType = baseType;
 109         fDerivedBy = derivedBy;
 110         fFinal = schemaFinal;
 111         fBlock = block;
 112         fContentType = contentType;
 113         if(isAbstract)
 114             fMiscFlags |= CT_IS_ABSTRACT;
 115         fAttrGrp = attrGrp;
 116         fXSSimpleType = simpleType;
 117         fParticle = particle;
 118         fAnnotations = annotations;
 119    }
 120 
 121    public void setName(String name) {
 122         fName = name;
 123    }
 124 
 125     public short getTypeCategory() {
 126         return COMPLEX_TYPE;
 127     }
 128 
 129     public String getTypeName() {
 130         return fName;
 131     }
 132 
 133     public short getFinalSet(){
 134         return fFinal;
 135     }
 136 
 137     public String getTargetNamespace(){
 138         return fTargetNamespace;
 139     }
 140 
 141     // flags for the misc flag
 142     private static final short CT_IS_ABSTRACT = 1;
 143     private static final short CT_HAS_TYPE_ID = 2;
 144     private static final short CT_IS_ANONYMOUS = 4;
 145 
 146     // methods to get/set misc flag
 147 
 148     public boolean containsTypeID () {
 149         return((fMiscFlags & CT_HAS_TYPE_ID) != 0);
 150     }
 151 
 152     public void setIsAbstractType() {
 153         fMiscFlags |= CT_IS_ABSTRACT;
 154     }
 155     public void setContainsTypeID() {
 156         fMiscFlags |= CT_HAS_TYPE_ID;
 157     }
 158     public void setIsAnonymous() {
 159         fMiscFlags |= CT_IS_ANONYMOUS;
 160     }
 161 
 162     public XSCMValidator getContentModel(CMBuilder cmBuilder) {
 163         // for complex type with empty or simple content,
 164         // there is no content model validator
 165         if (fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE ||
 166             fContentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
 167             return null;
 168         }
 169         if (fCMValidator == null)
 170             synchronized (this) {
 171                 if (fCMValidator == null) {
 172                     fCMValidator = cmBuilder.getContentModel(this);
 173                 }
 174             }
 175         return fCMValidator;
 176     }
 177 
 178     // some utility methods:
 179 
 180     // return the attribute group for this complex type
 181     public XSAttributeGroupDecl getAttrGrp() {
 182         return fAttrGrp;
 183     }
 184 
 185     public String toString() {
 186         StringBuilder str = new StringBuilder(192);
 187         appendTypeInfo(str);
 188         return str.toString();
 189     }
 190 
 191     void appendTypeInfo(StringBuilder str) {
 192         String contentType[] = {"EMPTY", "SIMPLE", "ELEMENT", "MIXED"};
 193         String derivedBy[] = {"EMPTY", "EXTENSION", "RESTRICTION"};
 194 
 195         str.append("Complex type name='").append(fTargetNamespace).append(',').append(getTypeName()).append("', ");
 196         if (fBaseType != null) {
 197             str.append(" base type name='").append(fBaseType.getName()).append("', ");
 198         }
 199         str.append(" content type='").append(contentType[fContentType]).append("', ");
 200         str.append(" isAbstract='").append(getAbstract()).append("', ");
 201         str.append(" hasTypeId='").append(containsTypeID()).append("', ");
 202         str.append(" final='").append(fFinal).append("', ");
 203         str.append(" block='").append(fBlock).append("', ");
 204         if (fParticle != null) {
 205             str.append(" particle='").append(fParticle.toString()).append("', ");
 206         }
 207         str.append(" derivedBy='").append(derivedBy[fDerivedBy]).append("'. ");
 208 
 209     }
 210 
 211     public boolean derivedFromType(XSTypeDefinition ancestor, short derivationMethod) {
 212         // ancestor is null, retur false
 213         if (ancestor == null)
 214             return false;
 215         // ancestor is anyType, return true
 216         if (ancestor == SchemaGrammar.fAnyType)
 217             return true;
 218         // recursively get base, and compare it with ancestor
 219         XSTypeDefinition type = this;
 220         while (type != ancestor &&                     // compare with ancestor
 221                type != SchemaGrammar.fAnySimpleType &&  // reached anySimpleType
 222                type != SchemaGrammar.fAnyType) {        // reached anyType
 223             type = type.getBaseType();
 224         }
 225 
 226         return type == ancestor;
 227     }
 228 
 229     public boolean derivedFrom(String ancestorNS, String ancestorName, short derivationMethod) {
 230         // ancestor is null, retur false
 231         if (ancestorName == null)
 232             return false;
 233         // ancestor is anyType, return true
 234         if (ancestorNS != null &&
 235             ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) &&
 236             ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
 237             return true;
 238         }
 239 
 240         // recursively get base, and compare it with ancestor
 241         XSTypeDefinition type = this;
 242         while (!(ancestorName.equals(type.getName()) &&
 243                  ((ancestorNS == null && type.getNamespace() == null) ||
 244                   (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) &&   // compare with ancestor
 245                type != SchemaGrammar.fAnySimpleType &&  // reached anySimpleType
 246                type != SchemaGrammar.fAnyType) {        // reached anyType
 247             type = (XSTypeDefinition)type.getBaseType();
 248         }
 249 
 250         return type != SchemaGrammar.fAnySimpleType &&
 251         type != SchemaGrammar.fAnyType;
 252     }
 253 
 254     /**
 255      * Checks if a type is derived from another given the the name, namespace
 256      * and derivation method. See:
 257      * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
 258      *
 259      * @param ancestorNS
 260      *            The namspace of the ancestor type declaration
 261      * @param ancestorName
 262      *            The name of the ancestor type declaration
 263      * @param derivationMethod
 264      *            The derivation method
 265      *
 266      * @return boolean True if the ancestor type is derived from the reference
 267      *         type by the specifiied derivation method.
 268      */
 269     public boolean isDOMDerivedFrom(String ancestorNS, String ancestorName,
 270             int derivationMethod) {
 271         // ancestor is null, retur false
 272         if (ancestorName == null)
 273             return false;
 274 
 275         // ancestor is anyType, return true
 276         if (ancestorNS != null
 277                 && ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
 278                 && ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)
 279                 && (derivationMethod == DERIVATION_RESTRICTION
 280                 && derivationMethod == DERIVATION_EXTENSION)) {
 281             return true;
 282         }
 283 
 284         // restriction
 285         if ((derivationMethod & DERIVATION_RESTRICTION) != 0) {
 286             if (isDerivedByRestriction(ancestorNS, ancestorName,
 287                     derivationMethod, this)) {
 288                 return true;
 289             }
 290         }
 291 
 292         // extension
 293         if ((derivationMethod & DERIVATION_EXTENSION) != 0) {
 294             if (isDerivedByExtension(ancestorNS, ancestorName,
 295                     derivationMethod, this)) {
 296                 return true;
 297             }
 298         }
 299 
 300         // list or union
 301         if ((((derivationMethod & DERIVATION_LIST) != 0) || ((derivationMethod & DERIVATION_UNION) != 0))
 302                 && ((derivationMethod & DERIVATION_RESTRICTION) == 0)
 303                 && ((derivationMethod & DERIVATION_EXTENSION) == 0)) {
 304 
 305             if (ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
 306                     && ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
 307                 ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
 308             }
 309 
 310             if(!(fName.equals(SchemaSymbols.ATTVAL_ANYTYPE)
 311                             && fTargetNamespace.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA))){
 312                 if (fBaseType != null && fBaseType instanceof XSSimpleTypeDecl) {
 313 
 314                     return ((XSSimpleTypeDecl) fBaseType).isDOMDerivedFrom(ancestorNS,
 315                             ancestorName, derivationMethod);
 316                 } else if (fBaseType != null
 317                         && fBaseType instanceof XSComplexTypeDecl) {
 318                     return ((XSComplexTypeDecl) fBaseType).isDOMDerivedFrom(
 319                             ancestorNS, ancestorName, derivationMethod);
 320                 }
 321             }
 322         }
 323 
 324         // If the value of the parameter is 0 i.e. no bit (corresponding to
 325         // restriction, list, extension or union) is set to 1 for the
 326         // derivationMethod parameter.
 327         if (((derivationMethod  & DERIVATION_EXTENSION) == 0)
 328                 && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
 329                         && ((derivationMethod & DERIVATION_LIST) == 0)
 330                         && ((derivationMethod & DERIVATION_UNION) == 0))) {
 331             return isDerivedByAny(ancestorNS, ancestorName, derivationMethod, this);
 332         }
 333 
 334         return false;
 335     }
 336 
 337     /**
 338      * Checks if a type is derived from another by any combination of
 339      * restriction, list ir union. See:
 340      * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
 341      *
 342      * @param ancestorNS
 343      *            The namspace of the ancestor type declaration
 344      * @param ancestorName
 345      *            The name of the ancestor type declaration
 346      * @param derivationMethod
 347      *            A short indication the method of derivation
 348      * @param type
 349      *            The reference type definition
 350      *
 351      * @return boolean True if the type is derived by any method for the
 352      *         reference type
 353      */
 354     private boolean isDerivedByAny(String ancestorNS, String ancestorName,
 355             int derivationMethod, XSTypeDefinition type) {
 356         XSTypeDefinition oldType = null;
 357         boolean derivedFrom = false;
 358         while (type != null && type != oldType) {
 359 
 360             // If the ancestor type is reached or is the same as this type.
 361             if ((ancestorName.equals(type.getName()))
 362                     && ((ancestorNS == null && type.getNamespace() == null)
 363                         || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) {
 364                 derivedFrom = true;
 365                 break;
 366             }
 367 
 368             // Check if this type is derived from the base by restriction or
 369             // extension
 370             if (isDerivedByRestriction(ancestorNS, ancestorName,
 371                     derivationMethod, type)) {
 372                 return true;
 373             } else if (!isDerivedByExtension(ancestorNS, ancestorName,
 374                     derivationMethod, type)) {
 375                 return true;
 376             }
 377             oldType = type;
 378             type = type.getBaseType();
 379         }
 380 
 381         return derivedFrom;
 382     }
 383 
 384     /**
 385      * Checks if a type is derived from another by restriction. See:
 386      * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
 387      *
 388      * @param ancestorNS
 389      *            The namspace of the ancestor type declaration
 390      * @param ancestorName
 391      *            The name of the ancestor type declaration
 392      * @param derivationMethod
 393      *            A short indication the method of derivation *
 394      * @param type
 395      *            The reference type definition
 396      *
 397      * @return boolean True if the type is derived by restriciton for the
 398      *         reference type
 399      */
 400     private boolean isDerivedByRestriction(String ancestorNS,
 401             String ancestorName, int derivationMethod, XSTypeDefinition type) {
 402 
 403         XSTypeDefinition oldType = null;
 404         while (type != null && type != oldType) {
 405 
 406             // ancestor is anySimpleType, return false
 407             if (ancestorNS != null
 408                     && ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
 409                     && ancestorName.equals(SchemaSymbols.ATTVAL_ANYSIMPLETYPE)) {
 410                 return false;
 411             }
 412 
 413             // if the name and namespace of this type is the same as the
 414             // ancestor return true
 415             if ((ancestorName.equals(type.getName()))
 416                     && (ancestorNS != null && ancestorNS.equals(type.getNamespace()))
 417                             || ((type.getNamespace() == null && ancestorNS == null))) {
 418 
 419                 return true;
 420             }
 421 
 422             // If the base type is a complexType with simpleContent
 423             if (type instanceof XSSimpleTypeDecl) {
 424                 if (ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
 425                         && ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
 426                     ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
 427                 }
 428                 return ((XSSimpleTypeDecl) type).isDOMDerivedFrom(ancestorNS,
 429                         ancestorName, derivationMethod);
 430             } else {
 431                 // If the base type is a complex type
 432                 // Every derivation step till the base type should be
 433                 // restriction. If not return false
 434                 if (((XSComplexTypeDecl) type).getDerivationMethod() != XSConstants.DERIVATION_RESTRICTION) {
 435                     return false;
 436                 }
 437             }
 438             oldType = type;
 439             type = type.getBaseType();
 440 
 441         }
 442 
 443         return false;
 444     }
 445 
 446     /**
 447      * Checks if a type is derived from another by extension. See:
 448      * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
 449      *
 450      * @param ancestorNS
 451      *            The namspace of the ancestor type declaration
 452      * @param ancestorName
 453      *            The name of the ancestor type declaration
 454      * @param derivationMethod
 455      *            A short indication the method of derivation
 456      * @param type
 457      *            The reference type definition
 458      *
 459      * @return boolean True if the type is derived by extension for the
 460      *         reference type
 461      */
 462     private boolean isDerivedByExtension(String ancestorNS,
 463             String ancestorName, int derivationMethod, XSTypeDefinition type) {
 464 
 465         boolean extension = false;
 466         XSTypeDefinition oldType = null;
 467         while (type != null && type != oldType) {
 468             // If ancestor is anySimpleType return false.
 469             if (ancestorNS != null
 470                     && ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
 471                     && ancestorName.equals(SchemaSymbols.ATTVAL_ANYSIMPLETYPE)
 472                     && SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(type.getNamespace())
 473                             && SchemaSymbols.ATTVAL_ANYTYPE.equals(type.getName())) {
 474                 break;
 475             }
 476 
 477             if ((ancestorName.equals(type.getName()))
 478                     && ((ancestorNS == null && type.getNamespace() == null)
 479                         || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) {
 480                 // returns true if atleast one derivation step was extension
 481                 return extension;
 482             }
 483 
 484             // If the base type is a complexType with simpleContent
 485             if (type instanceof XSSimpleTypeDecl) {
 486                 if (ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
 487                         && ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
 488                     ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
 489                 }
 490 
 491                 // derivationMethod extension will always return false for a
 492                 // simpleType,
 493                 // we treat it like a restriction
 494                 if ((derivationMethod & DERIVATION_EXTENSION) != 0) {
 495                     return extension
 496                     & ((XSSimpleTypeDecl) type).isDOMDerivedFrom(
 497                             ancestorNS, ancestorName,
 498                             (derivationMethod & DERIVATION_RESTRICTION));
 499                 } else {
 500                     return extension
 501                     & ((XSSimpleTypeDecl) type).isDOMDerivedFrom(
 502                             ancestorNS, ancestorName, derivationMethod);
 503                 }
 504 
 505             } else {
 506                 // If the base type is a complex type
 507                 // At least one derivation step upto the ancestor type should be
 508                 // extension.
 509                 if (((XSComplexTypeDecl) type).getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
 510                     extension = extension | true;
 511                 }
 512             }
 513             oldType = type;
 514             type = type.getBaseType();
 515         }
 516 
 517         return false;
 518     }
 519 
 520 
 521 
 522     public void reset(){
 523         fName = null;
 524         fTargetNamespace = null;
 525         fBaseType = null;
 526         fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
 527         fFinal = XSConstants.DERIVATION_NONE;
 528         fBlock = XSConstants.DERIVATION_NONE;
 529 
 530         fMiscFlags = 0;
 531 
 532         // reset attribute group
 533         fAttrGrp.reset();
 534         fContentType = CONTENTTYPE_EMPTY;
 535         fXSSimpleType = null;
 536         fParticle = null;
 537         fCMValidator = null;
 538         fUPACMValidator = null;
 539         if(fAnnotations != null) {
 540             // help out the garbage collector
 541             fAnnotations.clearXSObjectList();
 542         }
 543         fAnnotations = null;
 544     }
 545 
 546     /**
 547      * Get the type of the object, i.e ELEMENT_DECLARATION.
 548      */
 549     public short getType() {
 550         return XSConstants.TYPE_DEFINITION;
 551     }
 552 
 553     /**
 554      * The <code>name</code> of this <code>XSObject</code> depending on the
 555      * <code>XSObject</code> type.
 556      */
 557     public String getName() {
 558         return getAnonymous() ? null : fName;
 559     }
 560 
 561     /**
 562      * A boolean that specifies if the type definition is anonymous.
 563      * Convenience attribute. This is a field is not part of
 564      * XML Schema component model.
 565      */
 566     public boolean getAnonymous() {
 567         return((fMiscFlags & CT_IS_ANONYMOUS) != 0);
 568     }
 569 
 570     /**
 571      * The namespace URI of this node, or <code>null</code> if it is
 572      * unspecified.  defines how a namespace URI is attached to schema
 573      * components.
 574      */
 575     public String getNamespace() {
 576         return fTargetNamespace;
 577     }
 578 
 579     /**
 580      * {base type definition} Either a simple type definition or a complex
 581      * type definition.
 582      */
 583     public XSTypeDefinition getBaseType() {
 584         return fBaseType;
 585     }
 586 
 587     /**
 588      * {derivation method} Either extension or restriction. The valid constant
 589      * value for this <code>XSConstants</code> EXTENTION, RESTRICTION.
 590      */
 591     public short getDerivationMethod() {
 592         return fDerivedBy;
 593     }
 594 
 595     /**
 596      * {final} For complex type definition it is a subset of {extension,
 597      * restriction}. For simple type definition it is a subset of
 598      * {extension, list, restriction, union}.
 599      * @param derivation  Extension, restriction, list, union constants
 600      *   (defined in <code>XSConstants</code>).
 601      * @return True if derivation is in the final set, otherwise false.
 602      */
 603     public boolean isFinal(short derivation) {
 604         return (fFinal & derivation) != 0;
 605     }
 606 
 607     /**
 608      * {final} For complex type definition it is a subset of {extension, restriction}.
 609      *
 610      * @return A bit flag that represents:
 611      *         {extension, restriction) or none for complexTypes;
 612      *         {extension, list, restriction, union} or none for simpleTypes;
 613      */
 614     public short getFinal() {
 615         return fFinal;
 616     }
 617 
 618     /**
 619      * {abstract} A boolean. Complex types for which {abstract} is true must
 620      * not be used as the {type definition} for the validation of element
 621      * information items.
 622      */
 623     public boolean getAbstract() {
 624         return((fMiscFlags & CT_IS_ABSTRACT) != 0);
 625     }
 626 
 627     /**
 628      *  {attribute uses} A set of attribute uses.
 629      */
 630     public XSObjectList getAttributeUses() {
 631         return fAttrGrp.getAttributeUses();
 632     }
 633 
 634     /**
 635      * {attribute wildcard} Optional. A wildcard.
 636      */
 637     public XSWildcard getAttributeWildcard() {
 638         return fAttrGrp.getAttributeWildcard();
 639     }
 640 
 641     /**
 642      * {content type} One of empty, a simple type definition (see
 643      * <code>simpleType</code>, or mixed, element-only (see
 644      * <code>cmParticle</code>).
 645      */
 646     public short getContentType() {
 647         return fContentType;
 648     }
 649 
 650     /**
 651      * A simple type definition corresponding to simple content model,
 652      * otherwise <code>null</code>
 653      */
 654     public XSSimpleTypeDefinition getSimpleType() {
 655         return fXSSimpleType;
 656     }
 657 
 658     /**
 659      * A particle for mixed or element-only content model, otherwise
 660      * <code>null</code>
 661      */
 662     public XSParticle getParticle() {
 663         return fParticle;
 664     }
 665 
 666     /**
 667      * {prohibited substitutions} A subset of {extension, restriction}.
 668      * @param prohibited  extention or restriction constants (defined in
 669      *   <code>XSConstants</code>).
 670      * @return True if prohibited is a prohibited substitution, otherwise
 671      *   false.
 672      */
 673     public boolean isProhibitedSubstitution(short prohibited) {
 674         return (fBlock & prohibited) != 0;
 675     }
 676 
 677     /**
 678      * {prohibited substitutions}
 679      *
 680      * @return A bit flag corresponding to prohibited substitutions
 681      */
 682     public short getProhibitedSubstitutions() {
 683         return fBlock;
 684     }
 685 
 686     /**
 687      * Optional. Annotation.
 688      */
 689     public XSObjectList getAnnotations() {
 690         return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
 691     }
 692 
 693     /**
 694      * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
 695      */
 696     public XSNamespaceItem getNamespaceItem() {
 697         return fNamespaceItem;
 698     }
 699 
 700     void setNamespaceItem(XSNamespaceItem namespaceItem) {
 701         fNamespaceItem = namespaceItem;
 702     }
 703 
 704     /* (non-Javadoc)
 705      * @see org.apache.xerces.xs.XSComplexTypeDefinition#getAttributeUse(java.lang.String, java.lang.String)
 706      */
 707     public XSAttributeUse getAttributeUse(String namespace, String name) {
 708          return fAttrGrp.getAttributeUse(namespace, name);
 709     }
 710 
 711     public String getTypeNamespace() {
 712         return getNamespace();
 713     }
 714 
 715     public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod) {
 716         return isDOMDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod);
 717     }
 718 
 719 } // class XSComplexTypeDecl