FileDocCategorySizeDatePackage
XSComplexTypeDecl.javaAPI DocJava SE 5 API16858Fri Aug 26 14:55:50 BST 2005com.sun.org.apache.xerces.internal.impl.xs

XSComplexTypeDecl

public class XSComplexTypeDecl extends Object implements XSComplexTypeDefinition
The XML representation for a complexType schema component is a element information item
author
Elena Litani, IBM
author
Sandy Gao, IBM
version
$Id: XSComplexTypeDecl.java,v 1.7 2003/12/12 02:58:29 kk122374 Exp $

Fields Summary
String
fName
String
fTargetNamespace
XSTypeDefinition
fBaseType
short
fDerivedBy
short
fFinal
short
fBlock
short
fMiscFlags
XSAttributeGroupDecl
fAttrGrp
short
fContentType
XSSimpleType
fXSSimpleType
XSParticleDecl
fParticle
XSCMValidator
fCMValidator
XSObjectListImpl
fAnnotations
private static final short
CT_IS_ABSTRACT
private static final short
CT_HAS_TYPE_ID
private static final short
CT_IS_ANONYMOUS
Constructors Summary
public XSComplexTypeDecl()


      
        // do-nothing constructor for now.
    
Methods Summary
voidappendTypeInfo(java.lang.StringBuffer str)

        String contentType[] = {"EMPTY", "SIMPLE", "ELEMENT", "MIXED"};
        String derivedBy[] = {"EMPTY", "EXTENSION", "RESTRICTION"};

        str.append("Complex type name='" + fTargetNamespace + "," + getTypeName() + "', ");
        if (fBaseType != null)
            str.append(" base type name='" + fBaseType.getName() + "', ");

        str.append(" content type='" + contentType[fContentType] + "', ");
        str.append(" isAbstract='" + getAbstract() + "', ");
        str.append(" hasTypeId='" + containsTypeID() + "', ");
        str.append(" final='" + fFinal + "', ");
        str.append(" block='" + fBlock + "', ");
        if (fParticle != null)
            str.append(" particle='" + fParticle.toString() + "', ");
        str.append(" derivedBy='" + derivedBy[fDerivedBy] + "'. ");

    
public booleancontainsTypeID()


    // methods to get/set misc flag

        
        return((fMiscFlags & CT_HAS_TYPE_ID) != 0);
    
public booleanderivedFrom(java.lang.String ancestorNS, java.lang.String ancestorName, short derivationMethod)

        // ancestor is null, retur false
        if (ancestorName == null)
            return false;
        // ancestor is anyType, return true
        if (ancestorNS != null &&
            ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) &&
            ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
            return true;
        }

        // recursively get base, and compare it with ancestor
        XSTypeDefinition type = this;
        while (!(ancestorName.equals(type.getName()) &&
                 ((ancestorNS == null && type.getNamespace() == null) ||
                  (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) &&   // compare with ancestor
               type != SchemaGrammar.fAnySimpleType &&  // reached anySimpleType
               type != SchemaGrammar.fAnyType) {        // reached anyType
            if( derivationMethod!=0 ) {
                if( type instanceof XSComplexTypeDefinition ) {
                    switch( ((XSComplexTypeDefinition)type).getDerivationMethod() ) {
                    case XSConstants.DERIVATION_EXTENSION:
                        if( (derivationMethod&TypeInfo.DERIVATION_EXTENSION) == 0 )
                            return false;
                        break;
                    case XSConstants.DERIVATION_RESTRICTION:
                        if( (derivationMethod&TypeInfo.DERIVATION_RESTRICTION) == 0 )
                            return false;
                        break;
                    }
                } else 
                if( type instanceof XSSimpleTypeDefinition ) {
                    // broken (but then the spec is broken, so what do you expect!) FIXME.
                    switch( ((XSSimpleTypeDefinition)type).getVariety()) {
                    case XSSimpleTypeDefinition.VARIETY_ATOMIC:
                        if( (derivationMethod&TypeInfo.DERIVATION_RESTRICTION) == 0 )
                            return false;
                        break;
                   case XSSimpleTypeDefinition.VARIETY_LIST:
                       if( (derivationMethod&TypeInfo.DERIVATION_LIST) == 0 )
                           return false;
                       break;
                   case XSSimpleTypeDefinition.VARIETY_UNION:
                       if( (derivationMethod&TypeInfo.DERIVATION_UNION) == 0 )
                           return false;
                       break;
                  }
                }
            }
            type = (XSTypeDefinition)type.getBaseType();
        }

        return type != SchemaGrammar.fAnySimpleType &&
        type != SchemaGrammar.fAnyType;
    
public booleanderivedFromType(com.sun.org.apache.xerces.internal.xs.XSTypeDefinition ancestor, short derivationMethod)

        // ancestor is null, retur false
        if (ancestor == null)
            return false;
        // ancestor is anyType, return true
        if (ancestor == SchemaGrammar.fAnyType)
            return true;
        // recursively get base, and compare it with ancestor
        XSTypeDefinition type = this;
        while (type != ancestor &&                     // compare with ancestor
               type != SchemaGrammar.fAnySimpleType &&  // reached anySimpleType
               type != SchemaGrammar.fAnyType) {        // reached anyType
            type = type.getBaseType();
        }

        return type == ancestor;
    
public booleangetAbstract()
{abstract} A boolean. Complex types for which {abstract} is true must not be used as the {type definition} for the validation of element information items.

        return((fMiscFlags & CT_IS_ABSTRACT) != 0);
    
public com.sun.org.apache.xerces.internal.xs.XSObjectListgetAnnotations()
Optional. Annotation.

        return fAnnotations;
    
public booleangetAnonymous()
A boolean that specifies if the type definition is anonymous. Convenience attribute. This is a field is not part of XML Schema component model.

        return((fMiscFlags & CT_IS_ANONYMOUS) != 0);
    
public com.sun.org.apache.xerces.internal.impl.xs.XSAttributeGroupDeclgetAttrGrp()

        return fAttrGrp;
    
public com.sun.org.apache.xerces.internal.xs.XSAttributeUsegetAttributeUse(java.lang.String namespace, java.lang.String name)

         return fAttrGrp.getAttributeUse(namespace, name);
    
public com.sun.org.apache.xerces.internal.xs.XSObjectListgetAttributeUses()
{attribute uses} A set of attribute uses.

        return fAttrGrp.getAttributeUses();
    
public com.sun.org.apache.xerces.internal.xs.XSWildcardgetAttributeWildcard()
{attribute wildcard} Optional. A wildcard.

        return fAttrGrp.getAttributeWildcard();
    
public com.sun.org.apache.xerces.internal.xs.XSTypeDefinitiongetBaseType()
{base type definition} Either a simple type definition or a complex type definition.

        return fBaseType;
    
public synchronized com.sun.org.apache.xerces.internal.impl.xs.models.XSCMValidatorgetContentModel(com.sun.org.apache.xerces.internal.impl.xs.models.CMBuilder cmBuilder)

        if (fCMValidator == null)
            fCMValidator = cmBuilder.getContentModel(this);

        return fCMValidator;
    
public shortgetContentType()
{content type} One of empty, a simple type definition (see simpleType, or mixed, element-only (see cmParticle).

        return fContentType;
    
public shortgetDerivationMethod()
{derivation method} Either extension or restriction. The valid constant value for this XSConstants EXTENTION, RESTRICTION.

        return fDerivedBy;
    
public shortgetFinal()
{final} For complex type definition it is a subset of {extension, restriction}.

return
A bit flag that represents: {extension, restriction) or none for complexTypes; {extension, list, restriction, union} or none for simpleTypes;

        return fFinal;
    
public shortgetFinalSet()

        return fFinal;
    
public java.lang.StringgetName()
The name of this XSObject depending on the XSObject type.

        return getAnonymous() ? null : fName;
    
public java.lang.StringgetNamespace()
The namespace URI of this node, or null if it is unspecified. defines how a namespace URI is attached to schema components.

        return fTargetNamespace;
    
public com.sun.org.apache.xerces.internal.xs.XSNamespaceItemgetNamespaceItem()

see
com.sun.org.apache.xerces.internal.impl.xs.psvi.XSObject#getNamespaceItem()

        // REVISIT: implement
    	return null;
    
public com.sun.org.apache.xerces.internal.xs.XSParticlegetParticle()
A particle for mixed or element-only content model, otherwise null

        return fParticle;
    
public shortgetProhibitedSubstitutions()
{prohibited substitutions}

return
A bit flag corresponding to prohibited substitutions

        return fBlock;
    
public com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinitiongetSimpleType()
A simple type definition corresponding to simple content model, otherwise null

        return fXSSimpleType;
    
public java.lang.StringgetTargetNamespace()

        return fTargetNamespace;
    
public shortgetType()
Get the type of the object, i.e ELEMENT_DECLARATION.

        return XSConstants.TYPE_DEFINITION;
    
public shortgetTypeCategory()

        return COMPLEX_TYPE;
    
public java.lang.StringgetTypeName()

        return fName;
    
public java.lang.StringgetTypeNamespace()

        return getNamespace();
    
public booleanisDerivedFrom(java.lang.String typeNamespace, java.lang.String typeName, int derivationMethod)

        return derivedFrom(typeNamespace,typeName,(short)derivationMethod);
    
public booleanisFinal(short derivation)
{final} For complex type definition it is a subset of {extension, restriction}. For simple type definition it is a subset of {extension, list, restriction, union}.

param
derivation Extension, restriction, list, union constants (defined in XSConstants).
return
True if derivation is in the final set, otherwise false.

        return (fFinal & derivation) != 0;
    
public booleanisProhibitedSubstitution(short prohibited)
{prohibited substitutions} A subset of {extension, restriction}.

param
prohibited extention or restriction constants (defined in XSConstants).
return
True if prohibited is a prohibited substitution, otherwise false.

        return (fBlock & prohibited) != 0;
    
public voidreset()

        fName = null;
        fTargetNamespace = null;
        fBaseType = null;
        fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
        fFinal = XSConstants.DERIVATION_NONE;
        fBlock = XSConstants.DERIVATION_NONE;

        fMiscFlags = 0;

        // reset attribute group
        fAttrGrp.reset();
        fContentType = CONTENTTYPE_EMPTY;
        fXSSimpleType = null;
        fParticle = null;
        fCMValidator = null;
        if(fAnnotations != null) {
            // help out the garbage collector
            fAnnotations.clear();
        }
        fAnnotations = null;
    
public voidsetContainsTypeID()

        fMiscFlags |= CT_HAS_TYPE_ID;
    
public voidsetIsAbstractType()

        fMiscFlags |= CT_IS_ABSTRACT;
    
public voidsetIsAnonymous()

        fMiscFlags |= CT_IS_ANONYMOUS;
    
public voidsetName(java.lang.String name)

        fName = name;
   
public voidsetValues(java.lang.String name, java.lang.String targetNamespace, com.sun.org.apache.xerces.internal.xs.XSTypeDefinition baseType, short derivedBy, short schemaFinal, short block, short contentType, boolean isAbstract, com.sun.org.apache.xerces.internal.impl.xs.XSAttributeGroupDecl attrGrp, com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType simpleType, com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl particle, com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl annotations)

        fTargetNamespace = targetNamespace;
        fBaseType = baseType;
        fDerivedBy = derivedBy;
        fFinal = schemaFinal;
        fBlock = block;
        fContentType = contentType;
        if(isAbstract)
            fMiscFlags |= CT_IS_ABSTRACT;
        fAttrGrp = attrGrp;
        fXSSimpleType = simpleType;
        fParticle = particle;
        fAnnotations = annotations;
   
public java.lang.StringtoString()

        StringBuffer str = new StringBuffer();
        appendTypeInfo(str);
        return str.toString();