com.sun.xml.internal.xsom.XSComplexType Java Examples

The following examples show how to use com.sun.xml.internal.xsom.XSComplexType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: STDerivedComplexTypeBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void build(XSComplexType ct) {
    assert ct.getDerivationMethod()==XSType.EXTENSION;

    // base type is a simple type
    XSSimpleType baseType = ct.getBaseType().asSimpleType();

    // determine the binding of this complex type.
    builder.recordBindingMode(ct,ComplexTypeBindingMode.NORMAL);

    simpleTypeBuilder.refererStack.push(ct);
    TypeUse use = simpleTypeBuilder.build(baseType);
    simpleTypeBuilder.refererStack.pop();

    BIProperty prop = BIProperty.getCustomization(ct);
    CPropertyInfo p = prop.createValueProperty("Value",false,baseType,use, BGMBuilder.getName(baseType));
    selector.getCurrentBean().addProperty(p);

    // adds attributes and we are through.
    green.attContainer(ct);
}
 
Example #2
Source File: ChoiceContentComplexTypeBuilder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    if( !bgmBuilder.getGlobalBinding().isChoiceContentPropertyEnabled() )
        return false;

    if( ct.getBaseType()!=schemas.getAnyType() )
        // My reading of the spec is that if a complex type is
        // derived from another complex type by extension,
        // its top level model group is always a sequence
        // that combines the base type content model and
        // the extension defined in the new complex type.
        return false;

    XSParticle p = ct.getContentType().asParticle();
    if(p==null)
        return false;

    XSModelGroup mg = getTopLevelModelGroup(p);

    if( mg.getCompositor()!=XSModelGroup.CHOICE )
        return false;

    if( p.isRepeated() )
        return false;

    return true;
}
 
Example #3
Source File: AbstractExtendedComplexTypeBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Looks for the derivation chain t_1 > t_2 > ... > t
 * and find t_i such that t_i derives by restriction but
 * for every j>i, t_j derives by extension.
 *
 * @return null
 *      If there's no such t_i or if t_i is any type.
 */
protected XSComplexType getLastRestrictedType(XSComplexType t) {
    if (t.getBaseType() == schemas.getAnyType()) {
        return null;   // we don't count the restriction from anyType
    }
    if (t.getDerivationMethod() == XSType.RESTRICTION) {
        return t;
    }

    XSComplexType baseType = t.getBaseType().asComplexType();
    if (baseType != null) {
        return getLastRestrictedType(baseType);
    } else {
        return null;
    }
}
 
Example #4
Source File: AbstractExtendedComplexTypeBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Looks for the derivation chain t_1 > t_2 > ... > t
 * and find t_i such that t_i derives by restriction but
 * for every j>i, t_j derives by extension.
 *
 * @return null
 *      If there's no such t_i or if t_i is any type.
 */
protected XSComplexType getLastRestrictedType(XSComplexType t) {
    if (t.getBaseType() == schemas.getAnyType()) {
        return null;   // we don't count the restriction from anyType
    }
    if (t.getDerivationMethod() == XSType.RESTRICTION) {
        return t;
    }

    XSComplexType baseType = t.getBaseType().asComplexType();
    if (baseType != null) {
        return getLastRestrictedType(baseType);
    } else {
        return null;
    }
}
 
Example #5
Source File: ComplexTypeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Iterator<XSAttributeUse> iterateAttributeUses() {

        XSComplexType baseType = getBaseType().asComplexType();

        if( baseType==null )    return super.iterateAttributeUses();

        return new Iterators.Union<XSAttributeUse>(
            new Iterators.Filter<XSAttributeUse>(baseType.iterateAttributeUses()) {
                protected boolean matches(XSAttributeUse value) {
                    XSAttributeDecl u = value.getDecl();
                    UName n = new UName(u.getTargetNamespace(),u.getName());
                    return !prohibitedAtts.contains(n);
                }
            },
            super.iterateAttributeUses() );
    }
 
Example #6
Source File: STDerivedComplexTypeBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void build(XSComplexType ct) {
    assert ct.getDerivationMethod()==XSType.EXTENSION;

    // base type is a simple type
    XSSimpleType baseType = ct.getBaseType().asSimpleType();

    // determine the binding of this complex type.
    builder.recordBindingMode(ct,ComplexTypeBindingMode.NORMAL);

    simpleTypeBuilder.refererStack.push(ct);
    TypeUse use = simpleTypeBuilder.build(baseType);
    simpleTypeBuilder.refererStack.pop();

    BIProperty prop = BIProperty.getCustomization(ct);
    CPropertyInfo p = prop.createValueProperty("Value",false,baseType,use, BGMBuilder.getName(baseType));
    selector.getCurrentBean().addProperty(p);

    // adds attributes and we are through.
    green.attContainer(ct);
}
 
Example #7
Source File: MixedExtendedComplexTypeBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {

        if (!bgmBuilder.isGenerateMixedExtensions()) return false;

        XSType bt = ct.getBaseType();
        if (bt.isComplexType() &&
            bt.asComplexType().isMixed() &&
            ct.isMixed() &&
            ct.getDerivationMethod()==XSType.EXTENSION &&
            ct.getContentType().asParticle() != null &&
            ct.getExplicitContent().asEmpty() == null
            )  {
                return true;
        }

        return false;
    }
 
Example #8
Source File: AbstractExtendedComplexTypeBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Looks for the derivation chain t_1 > t_2 > ... > t
 * and find t_i such that t_i derives by restriction but
 * for every j>i, t_j derives by extension.
 *
 * @return null
 *      If there's no such t_i or if t_i is any type.
 */
protected XSComplexType getLastRestrictedType(XSComplexType t) {
    if (t.getBaseType() == schemas.getAnyType()) {
        return null;   // we don't count the restriction from anyType
    }
    if (t.getDerivationMethod() == XSType.RESTRICTION) {
        return t;
    }

    XSComplexType baseType = t.getBaseType().asComplexType();
    if (baseType != null) {
        return getLastRestrictedType(baseType);
    } else {
        return null;
    }
}
 
Example #9
Source File: MixedComplexTypeBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    XSType bt = ct.getBaseType();
    if(bt ==schemas.getAnyType() && ct.isMixed())
        return true;    // fresh mixed complex type

    // there's no complex type in the inheritance tree yet
    if (bt.isComplexType() &&
        !bt.asComplexType().isMixed() &&
        ct.isMixed() &&
        ct.getDerivationMethod() == XSType.EXTENSION) {
            if (!bgmBuilder.isGenerateMixedExtensions() && (ct.getContentType().asParticle() == null)) {
                return false;
            }
            return true;
    }

    return false;
}
 
Example #10
Source File: ComplexTypeImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Iterator<XSAttributeUse> iterateAttributeUses() {

        XSComplexType baseType = getBaseType().asComplexType();

        if( baseType==null )    return super.iterateAttributeUses();

        return new Iterators.Union<XSAttributeUse>(
            new Iterators.Filter<XSAttributeUse>(baseType.iterateAttributeUses()) {
                protected boolean matches(XSAttributeUse value) {
                    XSAttributeDecl u = value.getDecl();
                    UName n = new UName(u.getTargetNamespace(),u.getName());
                    return !prohibitedAtts.contains(n);
                }
            },
            super.iterateAttributeUses() );
    }
 
Example #11
Source File: STDerivedComplexTypeBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void build(XSComplexType ct) {
    assert ct.getDerivationMethod()==XSType.EXTENSION;

    // base type is a simple type
    XSSimpleType baseType = ct.getBaseType().asSimpleType();

    // determine the binding of this complex type.
    builder.recordBindingMode(ct,ComplexTypeBindingMode.NORMAL);

    simpleTypeBuilder.refererStack.push(ct);
    TypeUse use = simpleTypeBuilder.build(baseType);
    simpleTypeBuilder.refererStack.pop();

    BIProperty prop = BIProperty.getCustomization(ct);
    CPropertyInfo p = prop.createValueProperty("Value",false,baseType,use, BGMBuilder.getName(baseType));
    selector.getCurrentBean().addProperty(p);

    // adds attributes and we are through.
    green.attContainer(ct);
}
 
Example #12
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Implements
 * <code>Validation Rule: Schema-Validity Assessment (Element) 1.2.1.2.4</code>
 */
private static boolean isSubstitutable( XSType _base, XSType derived ) {
    // too ugly to the point that it's almost unbearable.
    // I mean, it's not even transitive. Thus we end up calling this method
    // for each candidate
    if( _base.isComplexType() ) {
        XSComplexType base = _base.asComplexType();

        for( ; base!=derived; derived=derived.getBaseType() ) {
            if( base.isSubstitutionProhibited( derived.getDerivationMethod() ) )
                return false;    // Type Derivation OK (Complex)-1
        }
        return true;
    } else {
        // simple type don't have any @block
        return true;
    }
}
 
Example #13
Source File: MultiWildcardComplexTypeBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    if (!bgmBuilder.model.options.contentForWildcard) {
        return false;
    }
    XSType bt = ct.getBaseType();
    if (bt ==schemas.getAnyType() && ct.getContentType() != null) {
        XSParticle part = ct.getContentType().asParticle();
        if ((part != null) && (part.getTerm().isModelGroup())) {
            XSParticle[] parts = part.getTerm().asModelGroup().getChildren();
            int wildcardCount = 0;
            int i = 0;
            while ((i < parts.length) && (wildcardCount <= 1)) {
                if (parts[i].getTerm().isWildcard()) {
                    wildcardCount += 1;
                }
                i++;
            }
            return (wildcardCount > 1);
        }
    }
    return false;
}
 
Example #14
Source File: MixedComplexTypeBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    XSType bt = ct.getBaseType();
    if(bt ==schemas.getAnyType() && ct.isMixed())
        return true;    // fresh mixed complex type

    // there's no complex type in the inheritance tree yet
    if (bt.isComplexType() &&
        !bt.asComplexType().isMixed() &&
        ct.isMixed() &&
        ct.getDerivationMethod() == XSType.EXTENSION) {
            if (!bgmBuilder.isGenerateMixedExtensions() && (ct.getContentType().asParticle() == null)) {
                return false;
            }
            return true;
    }

    return false;
}
 
Example #15
Source File: MixedExtendedComplexTypeBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {

        if (!bgmBuilder.isGenerateMixedExtensions()) return false;

        XSType bt = ct.getBaseType();
        if (bt.isComplexType() &&
            bt.asComplexType().isMixed() &&
            ct.isMixed() &&
            ct.getDerivationMethod()==XSType.EXTENSION &&
            ct.getContentType().asParticle() != null &&
            ct.getExplicitContent().asEmpty() == null
            )  {
                return true;
        }

        return false;
    }
 
Example #16
Source File: AbstractExtendedComplexTypeBuilder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Looks for the derivation chain t_1 > t_2 > ... > t
 * and find t_i such that t_i derives by restriction but
 * for every j>i, t_j derives by extension.
 *
 * @return null
 *      If there's no such t_i or if t_i is any type.
 */
protected XSComplexType getLastRestrictedType(XSComplexType t) {
    if (t.getBaseType() == schemas.getAnyType()) {
        return null;   // we don't count the restriction from anyType
    }
    if (t.getDerivationMethod() == XSType.RESTRICTION) {
        return t;
    }

    XSComplexType baseType = t.getBaseType().asComplexType();
    if (baseType != null) {
        return getLastRestrictedType(baseType);
    } else {
        return null;
    }
}
 
Example #17
Source File: MixedExtendedComplexTypeBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {

        if (!bgmBuilder.isGenerateMixedExtensions()) return false;

        XSType bt = ct.getBaseType();
        if (bt.isComplexType() &&
            bt.asComplexType().isMixed() &&
            ct.isMixed() &&
            ct.getDerivationMethod()==XSType.EXTENSION &&
            ct.getContentType().asParticle() != null &&
            ct.getExplicitContent().asEmpty() == null
            )  {
                return true;
        }

        return false;
    }
 
Example #18
Source File: ChoiceContentComplexTypeBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    if( !bgmBuilder.getGlobalBinding().isChoiceContentPropertyEnabled() )
        return false;

    if( ct.getBaseType()!=schemas.getAnyType() )
        // My reading of the spec is that if a complex type is
        // derived from another complex type by extension,
        // its top level model group is always a sequence
        // that combines the base type content model and
        // the extension defined in the new complex type.
        return false;

    XSParticle p = ct.getContentType().asParticle();
    if(p==null)
        return false;

    XSModelGroup mg = getTopLevelModelGroup(p);

    if( mg.getCompositor()!=XSModelGroup.CHOICE )
        return false;

    if( p.isRepeated() )
        return false;

    return true;
}
 
Example #19
Source File: BindPurple.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void complexType(XSComplexType ct) {
    CClass ctBean = selector.bindToType(ct,null,false);
    if(getCurrentBean()!=ctBean)
        // in some case complex type and element binds to the same class
        // don't make it has-a. Just make it is-a.
        getCurrentBean().setBaseClass(ctBean);
}
 
Example #20
Source File: DefaultClassBinder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Derives a name from a schema component.
 * For complex types, we take redefinition into account when
 * deriving a default name.
 */
private String deriveName( XSComplexType comp ) {
    String seed = builder.deriveName( comp.getName(), comp );
    int cnt = comp.getRedefinedCount();
    for( ; cnt>0; cnt-- )
        seed = "Original"+seed;
    return seed;
}
 
Example #21
Source File: RefererFinder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void schema(XSSchema xs) {
    if(!visited.add(xs))       return;

    for (XSComplexType ct : xs.getComplexTypes().values()) {
        complexType(ct);
    }

    for (XSElementDecl e : xs.getElementDecls().values()) {
        elementDecl(e);
    }
}
 
Example #22
Source File: MixedExtendedComplexTypeBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void build(XSComplexType ct) {
    XSComplexType baseType = ct.getBaseType().asComplexType();

    // build the base class
    CClass baseClass = selector.bindToType(baseType, ct, true);
    assert baseClass != null;   // global complex type must map to a class

    if (!checkIfExtensionSafe(baseType, ct)) {
        // error. We can't handle any further extension
        errorReceiver.error(ct.getLocator(),
                Messages.ERR_NO_FURTHER_EXTENSION.format(
                baseType.getName(), ct.getName() )
        );
        return;
    }

    selector.getCurrentBean().setBaseClass(baseClass);
    builder.recordBindingMode(ct, ComplexTypeBindingMode.FALLBACK_EXTENSION);

    BIProperty prop = BIProperty.getCustomization(ct);
    CPropertyInfo p;

    RawTypeSet ts = RawTypeSetBuilder.build(ct.getContentType().asParticle(), false);
    p = prop.createDummyExtendedMixedReferenceProperty("contentOverrideFor" + ct.getName(), ct, ts);

    selector.getCurrentBean().addProperty(p);

    // adds attributes and we are through.
    green.attContainer(ct);
}
 
Example #23
Source File: Axis.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<XSComponent> elementDecl(XSElementDecl decl) {
    XSComplexType ct = decl.getType().asComplexType();
    if(ct==null)
        return empty();
    else {
        // also pick up model groups inside this complex type
        return new Iterators.Union<XSComponent>(singleton(ct),complexType(ct));
    }
}
 
Example #24
Source File: SchemaWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void dumpComplexTypeAttribute( XSComplexType type ) {
    Iterator itr;

    itr = type.iterateAttGroups();
    while(itr.hasNext())
        dumpRef( (XSAttGroupDecl)itr.next() );

    itr = type.iterateDeclaredAttributeUses();
    while(itr.hasNext())
        attributeUse( (XSAttributeUse)itr.next() );

    XSWildcard awc = type.getAttributeWildcard();
    if(awc!=null)
        wildcard("anyAttribute",awc,"");
}
 
Example #25
Source File: MixedExtendedComplexTypeBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void build(XSComplexType ct) {
    XSComplexType baseType = ct.getBaseType().asComplexType();

    // build the base class
    CClass baseClass = selector.bindToType(baseType, ct, true);
    assert baseClass != null;   // global complex type must map to a class

    if (!checkIfExtensionSafe(baseType, ct)) {
        // error. We can't handle any further extension
        errorReceiver.error(ct.getLocator(),
                Messages.ERR_NO_FURTHER_EXTENSION.format(
                baseType.getName(), ct.getName() )
        );
        return;
    }

    selector.getCurrentBean().setBaseClass(baseClass);
    builder.recordBindingMode(ct, ComplexTypeBindingMode.FALLBACK_EXTENSION);

    BIProperty prop = BIProperty.getCustomization(ct);
    CPropertyInfo p;

    RawTypeSet ts = RawTypeSetBuilder.build(ct.getContentType().asParticle(), false);
    p = prop.createDummyExtendedMixedReferenceProperty("contentOverrideFor" + ct.getName(), ct, ts);

    selector.getCurrentBean().addProperty(p);

    // adds attributes and we are through.
    green.attContainer(ct);
}
 
Example #26
Source File: SchemaSetImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<XSComplexType> iterateComplexTypes() {
    return new Iterators.Map<XSComplexType,XSSchema>(iterateSchema()) {
        protected Iterator<XSComplexType> apply(XSSchema u) {
            return u.iterateComplexTypes();
        }
    };
}
 
Example #27
Source File: AbstractAxisImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<T> complexType(XSComplexType type) {
    // compensate particle
    XSParticle p = type.getContentType().asParticle();
    if(p!=null)
        return particle(p);
    else
        return empty();
}
 
Example #28
Source File: SchemaWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void dumpComplexTypeAttribute( XSComplexType type ) {
    Iterator itr;

    itr = type.iterateAttGroups();
    while(itr.hasNext())
        dumpRef( (XSAttGroupDecl)itr.next() );

    itr = type.iterateDeclaredAttributeUses();
    while(itr.hasNext())
        attributeUse( (XSAttributeUse)itr.next() );

    XSWildcard awc = type.getAttributeWildcard();
    if(awc!=null)
        wildcard("anyAttribute",awc,"");
}
 
Example #29
Source File: ComplexTypeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public List<XSComplexType> getSubtypes() {
    ArrayList subtypeList = new ArrayList();
    Iterator<XSComplexType> cTypes = getRoot().iterateComplexTypes();
    while (cTypes.hasNext()) {
        XSComplexType cType= cTypes.next();
        XSType base = cType.getBaseType();
        if ((base != null) && (base.equals(this))) {
            subtypeList.add(cType);
        }
    }
    return subtypeList;
}
 
Example #30
Source File: SchemaTreeTraverser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}