Java Code Examples for com.sun.xml.internal.xsom.XSType#getBaseType()

The following examples show how to use com.sun.xml.internal.xsom.XSType#getBaseType() . 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: Util.java    From TencentKona-8 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 2
Source File: Util.java    From openjdk-jdk9 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 3
Source File: Util.java    From openjdk-jdk8u 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 4
Source File: Util.java    From openjdk-8-source 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 5
Source File: ElementDecl.java    From jdk8u60 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 6
Source File: SimpleTypeImpl.java    From openjdk-jdk8u-backup 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 7
Source File: TypeClosure.java    From openjdk-jdk8u-backup 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 8
Source File: TypeClosure.java    From openjdk-jdk9 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 9
Source File: ElementDecl.java    From openjdk-jdk9 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 10
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 11
Source File: SimpleTypeImpl.java    From openjdk-jdk8u 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 12
Source File: TypeClosure.java    From openjdk-jdk8u 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 13
Source File: ComplexTypeImpl.java    From openjdk-jdk8u-backup 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 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 15
Source File: Util.java    From jdk8u60 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()]);
}
 
Example 16
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 17
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 18
Source File: ElementDecl.java    From TencentKona-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 19
Source File: Util.java    From TencentKona-8 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()]);
}
 
Example 20
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()]);
}