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

The following examples show how to use com.sun.xml.internal.xsom.XSType. 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: DefaultClassBinder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If only one global {@link XSElementDecl} is refering to {@link XSType},
 * return that element, otherwise null.
 */
private @Nullable XSElementDecl getSoleElementReferer(@NotNull XSType t) {
    Set<XSComponent> referer = builder.getReferer(t);

    XSElementDecl sole = null;
    for (XSComponent r : referer) {
        if(r instanceof XSElementDecl) {
            XSElementDecl x = (XSElementDecl) r;
            if(!x.isGlobal())
                // local element references can be ignored, as their names are either given
                // by the property, or by the JAXBElement (for things like mixed contents)
                continue;
            if(sole==null)  sole=x;
            else            return null;    // more than one
        } else {
            // if another type refers to this type, that means
            // this type has a sub-type, so type substitution is possible now.
            return null;
        }
    }

    return sole;
}
 
Example #2
Source File: DefaultClassBinder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If only one global {@link XSElementDecl} is refering to {@link XSType},
 * return that element, otherwise null.
 */
private @Nullable XSElementDecl getSoleElementReferer(@NotNull XSType t) {
    Set<XSComponent> referer = builder.getReferer(t);

    XSElementDecl sole = null;
    for (XSComponent r : referer) {
        if(r instanceof XSElementDecl) {
            XSElementDecl x = (XSElementDecl) r;
            if(!x.isGlobal())
                // local element references can be ignored, as their names are either given
                // by the property, or by the JAXBElement (for things like mixed contents)
                continue;
            if(sole==null)  sole=x;
            else            return null;    // more than one
        } else {
            // if another type refers to this type, that means
            // this type has a sub-type, so type substitution is possible now.
            return null;
        }
    }

    return sole;
}
 
Example #3
Source File: MixedComplexTypeBuilder.java    From hottub 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 #4
Source File: ComplexTypeImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public XSAttributeUse getAttributeUse( String nsURI, String localName ) {
    UName name = new UName(nsURI,localName);

    if(prohibitedAtts.contains(name))       return null;

    XSAttributeUse o = attributes.get(name);


    if(o==null) {
        Iterator itr = iterateAttGroups();
        while(itr.hasNext() && o==null)
            o = ((XSAttGroupDecl)itr.next()).getAttributeUse(nsURI,localName);
    }

    if(o==null) {
        XSType base = getBaseType();
        if(base.asComplexType()!=null)
            o = base.asComplexType().getAttributeUse(nsURI,localName);
    }

    return o;
}
 
Example #5
Source File: MixedComplexTypeBuilder.java    From openjdk-jdk8u 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 #6
Source File: MixedComplexTypeBuilder.java    From openjdk-8 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 #7
Source File: MultiWildcardComplexTypeBuilder.java    From openjdk-8 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 #8
Source File: ComplexTypeImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public XSAttributeUse getAttributeUse( String nsURI, String localName ) {
    UName name = new UName(nsURI,localName);

    if(prohibitedAtts.contains(name))       return null;

    XSAttributeUse o = attributes.get(name);


    if(o==null) {
        Iterator itr = iterateAttGroups();
        while(itr.hasNext() && o==null)
            o = ((XSAttGroupDecl)itr.next()).getAttributeUse(nsURI,localName);
    }

    if(o==null) {
        XSType base = getBaseType();
        if(base.asComplexType()!=null)
            o = base.asComplexType().getAttributeUse(nsURI,localName);
    }

    return o;
}
 
Example #9
Source File: SchemaTreeTraverser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates node for element declaration with additional attributes.
 *
 * @param decl      Element declaration.
 * @param extraAtts Additional attributes.
 */
private void elementDecl(XSElementDecl decl, String extraAtts) {
    XSType type = decl.getType();

    // TODO: various other attributes

    String str = MessageFormat.format("Element name=\"{0}\"{1}{2}",
            new Object[]{
                decl.getName(),
                type.isLocal() ? "" : " type=\"{"
            + type.getTargetNamespace() + "}"
            + type.getName() + "\"", extraAtts});

    SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    if (type.isLocal()) {
        if (type.isLocal()) {
            type.visit(this);
        }
    }

    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
Example #10
Source File: BGMBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all types that refer to the given complex type.
 */
public Set<XSComponent> getReferer(XSType c) {
    if(refFinder==null) {
        refFinder = new RefererFinder();
        refFinder.schemaSet(Ring.get(XSSchemaSet.class));
    }
    return refFinder.getReferer(c);
}
 
Example #11
Source File: RefererFinder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Called for each reference to record the fact.
 *
 * So far we only care about references to types.
 */
private void refer(XSComponent source, XSType target) {
    Set<XSComponent> r = referers.get(target);
    if(r==null) {
        r = new HashSet<XSComponent>();
        referers.put(target,r);
    }
    r.add(source);
}
 
Example #12
Source File: ComplexTypeImpl.java    From openjdk-jdk9 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 #13
Source File: SimpleTypeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean isDerivedFrom(XSType t) {
    XSType x = this;
    while(true) {
        if(t==x)
            return true;
        XSType s = x.getBaseType();
        if(s==x)
            return false;
        x = s;
    }
}
 
Example #14
Source File: ComplexTypeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public XSWildcard getAttributeWildcard() {
    WildcardImpl complete = localAttWildcard;

    Iterator itr = iterateAttGroups();
    while( itr.hasNext() ) {
        WildcardImpl w = (WildcardImpl)((XSAttGroupDecl)itr.next()).getAttributeWildcard();

        if(w==null)     continue;

        if(complete==null)
            complete = w;
        else
            // TODO: the spec says it's intersection,
            // but I think it has to be union.
            complete = complete.union(ownerDocument,w);
    }

    if( getDerivationMethod()==RESTRICTION )    return complete;

    WildcardImpl base=null;
    XSType baseType = getBaseType();
    if(baseType.asComplexType()!=null)
        base = (WildcardImpl)baseType.asComplexType().getAttributeWildcard();

    if(complete==null)  return base;
    if(base==null)      return complete;

    return complete.union(ownerDocument,base);
}
 
Example #15
Source File: BGMBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Fill-in the contents of each classes. */
private void buildContents() {
    ClassSelector cs = getClassSelector();
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);

    for( XSSchema s : Ring.get(XSSchemaSet.class).getSchemas() ) {
        BISchemaBinding sb = getBindInfo(s).get(BISchemaBinding.class);

        if(sb!=null && !sb.map) {
            sb.markAsAcknowledged();
            continue;       // no mapping for this package
        }

        getClassSelector().pushClassScope( new CClassInfoParent.Package(
            getClassSelector().getPackage(s.getTargetNamespace())) );

        checkMultipleSchemaBindings(s);
        processPackageJavadoc(s);
        populate(s.getAttGroupDecls(),s);
        populate(s.getAttributeDecls(),s);
        populate(s.getElementDecls(),s);
        populate(s.getModelGroupDecls(),s);

        // fill in typeUses
        for (XSType t : s.getTypes().values()) {
            stb.refererStack.push(t);
            model.typeUses().put( getName(t), cs.bindToType(t,s) );
            stb.refererStack.pop();
        }

        getClassSelector().popClassScope();
    }
}
 
Example #16
Source File: SchemaSetImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<XSType> iterateTypes() {
    return new Iterators.Map<XSType,XSSchema>(iterateSchema()) {
        protected Iterator<XSType> apply(XSSchema u) {
            return u.iterateTypes();
        }
    };
}
 
Example #17
Source File: SchemaSetImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<XSType> iterateTypes() {
    return new Iterators.Map<XSType,XSSchema>(iterateSchema()) {
        protected Iterator<XSType> apply(XSSchema u) {
            return u.iterateTypes();
        }
    };
}
 
Example #18
Source File: ElementDecl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void updateSubstitutabilityMap() {
    ElementDecl parent = this;
    XSType type = this.getType();

    boolean rused = false;
    boolean eused = false;

    while( (parent=(ElementDecl)parent.getSubstAffiliation())!=null ) {

        if(parent.isSubstitutionDisallowed(XSType.SUBSTITUTION))
            continue;

        boolean rd = parent.isSubstitutionDisallowed(XSType.RESTRICTION);
        boolean ed = parent.isSubstitutionDisallowed(XSType.EXTENSION);

        if( (rd && rused) || ( ed && eused ) )   continue;

        XSType parentType = parent.getType();
        while (type!=parentType) {
            if(type.getDerivationMethod()==XSType.RESTRICTION)  rused = true;
            else                                                eused = true;

            type = type.getBaseType();
            if(type==null)  // parentType and type doesn't share the common base type. a bug in the schema.
                break;

            if( type.isComplexType() ) {
                rd |= type.asComplexType().isSubstitutionProhibited(XSType.RESTRICTION);
                ed |= type.asComplexType().isSubstitutionProhibited(XSType.EXTENSION);
            }
            if (getRoot().getAnyType().equals(type)) break;
        }

        if( (rd && rused) || ( ed && eused ) )   continue;

        // this element can substitute "parent"
        parent.addSubstitutable(this);
    }
}
 
Example #19
Source File: ComplexTypeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public XSWildcard getAttributeWildcard() {
    WildcardImpl complete = localAttWildcard;

    Iterator itr = iterateAttGroups();
    while( itr.hasNext() ) {
        WildcardImpl w = (WildcardImpl)((XSAttGroupDecl)itr.next()).getAttributeWildcard();

        if(w==null)     continue;

        if(complete==null)
            complete = w;
        else
            // TODO: the spec says it's intersection,
            // but I think it has to be union.
            complete = complete.union(ownerDocument,w);
    }

    if( getDerivationMethod()==RESTRICTION )    return complete;

    WildcardImpl base=null;
    XSType baseType = getBaseType();
    if(baseType.asComplexType()!=null)
        base = (WildcardImpl)baseType.asComplexType().getAttributeWildcard();

    if(complete==null)  return base;
    if(base==null)      return complete;

    return complete.union(ownerDocument,base);
}
 
Example #20
Source File: BGMBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all types that refer to the given complex type.
 */
public Set<XSComponent> getReferer(XSType c) {
    if(refFinder==null) {
        refFinder = new RefererFinder();
        refFinder.schemaSet(Ring.get(XSSchemaSet.class));
    }
    return refFinder.getReferer(c);
}
 
Example #21
Source File: SimpleTypeImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public boolean isDerivedFrom(XSType t) {
    XSType x = this;
    while(true) {
        if(t==x)
            return true;
        XSType s = x.getBaseType();
        if(s==x)
            return false;
        x = s;
    }
}
 
Example #22
Source File: BaseContentRef.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public BaseContentRef(final NGCCRuntimeEx $runtime, Ref.Type _baseType) {
    this.baseType = _baseType;
    $runtime.addPatcher(this);
    $runtime.addErrorChecker(new Patch() {
        public void run() throws SAXException {
            XSType t = baseType.getType();
            if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) {
                $runtime.reportError(
                    Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED,
                        t.getTargetNamespace(), t.getName()), loc);
            }
        }
    });
    this.loc = $runtime.copyLocator();
}
 
Example #23
Source File: SchemaWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void elementDecl( XSElementDecl decl, String extraAtts ) {
    XSType type = decl.getType();

    // TODO: various other attributes

    // qualified attr; Issue
    if(decl.getForm() != null) {
        extraAtts += " form=\"" + (decl.getForm() ? "qualified" : "unqualified" ) + "\"";
    }

    println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}>",
        decl.getName(),
        type.isLocal()?"":" type=\"{"+
        type.getTargetNamespace()+'}'+
        type.getName()+'\"',
        extraAtts,
        type.isLocal()?"":"/"));

    if(type.isLocal()) {
        indent++;

        if(type.isLocal())  type.visit(this);

        indent--;
        println("</element>");
    }
}
 
Example #24
Source File: ElementDecl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void updateSubstitutabilityMap() {
    ElementDecl parent = this;
    XSType type = this.getType();

    boolean rused = false;
    boolean eused = false;

    while( (parent=(ElementDecl)parent.getSubstAffiliation())!=null ) {

        if(parent.isSubstitutionDisallowed(XSType.SUBSTITUTION))
            continue;

        boolean rd = parent.isSubstitutionDisallowed(XSType.RESTRICTION);
        boolean ed = parent.isSubstitutionDisallowed(XSType.EXTENSION);

        if( (rd && rused) || ( ed && eused ) )   continue;

        XSType parentType = parent.getType();
        while (type!=parentType) {
            if(type.getDerivationMethod()==XSType.RESTRICTION)  rused = true;
            else                                                eused = true;

            type = type.getBaseType();
            if(type==null)  // parentType and type doesn't share the common base type. a bug in the schema.
                break;

            if( type.isComplexType() ) {
                rd |= type.asComplexType().isSubstitutionProhibited(XSType.RESTRICTION);
                ed |= type.asComplexType().isSubstitutionProhibited(XSType.EXTENSION);
            }
            if (getRoot().getAnyType().equals(type)) break;
        }

        if( (rd && rused) || ( ed && eused ) )   continue;

        // this element can substitute "parent"
        parent.addSubstitutable(this);
    }
}
 
Example #25
Source File: TypeClosure.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public boolean contains(XSType type) {
    if( typeSet.contains(type) ) {
        return true;
    } else {
        XSType baseType = type.getBaseType();
        if( baseType == null ) {
            return false;
        } else {
            // climb the super type hierarchy
            return contains(baseType);
        }
    }
}
 
Example #26
Source File: SchemaSetImpl.java    From openjdk-8-source 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 #27
Source File: BISchemaBinding.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Transforms the default name produced from XML name
 * by following the customization.
 *
 * This shouldn't be applied to a class name specified
 * by a customization.
 *
 * @param cmp
 *      The schema component from which the default name is derived.
 */
public String mangleClassName( String name, XSComponent cmp ) {
    if( cmp instanceof XSType )
        return nameXmlTransform.typeName.mangle(name);
    if( cmp instanceof XSElementDecl )
        return nameXmlTransform.elementName.mangle(name);
    if( cmp instanceof XSAttributeDecl )
        return nameXmlTransform.attributeName.mangle(name);
    if( cmp instanceof XSModelGroup || cmp instanceof XSModelGroupDecl )
        return nameXmlTransform.modelGroupName.mangle(name);

    // otherwise no modification
    return name;
}
 
Example #28
Source File: ElementDecl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void updateSubstitutabilityMap() {
    ElementDecl parent = this;
    XSType type = this.getType();

    boolean rused = false;
    boolean eused = false;

    while( (parent=(ElementDecl)parent.getSubstAffiliation())!=null ) {

        if(parent.isSubstitutionDisallowed(XSType.SUBSTITUTION))
            continue;

        boolean rd = parent.isSubstitutionDisallowed(XSType.RESTRICTION);
        boolean ed = parent.isSubstitutionDisallowed(XSType.EXTENSION);

        if( (rd && rused) || ( ed && eused ) )   continue;

        XSType parentType = parent.getType();
        while (type!=parentType) {
            if(type.getDerivationMethod()==XSType.RESTRICTION)  rused = true;
            else                                                eused = true;

            type = type.getBaseType();
            if(type==null)  // parentType and type doesn't share the common base type. a bug in the schema.
                break;

            if( type.isComplexType() ) {
                rd |= type.asComplexType().isSubstitutionProhibited(XSType.RESTRICTION);
                ed |= type.asComplexType().isSubstitutionProhibited(XSType.EXTENSION);
            }
            if (getRoot().getAnyType().equals(type)) break;
        }

        if( (rd && rused) || ( ed && eused ) )   continue;

        // this element can substitute "parent"
        parent.addSubstitutable(this);
    }
}
 
Example #29
Source File: SchemaSetImpl.java    From jdk8u60 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: Util.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static XSType[] listDirectSubstitutables( XSType _this ) {
    ArrayList r = new ArrayList();

    // TODO: handle @block
    Iterator itr = ((SchemaImpl)_this.getOwnerSchema()).parent.iterateTypes();
    while( itr.hasNext() ) {
        XSType t = (XSType)itr.next();
        if( t.getBaseType()==_this )
            r.add(t);
    }
    return (XSType[]) r.toArray(new XSType[r.size()]);
}