Java Code Examples for com.sun.xml.internal.xsom.XSRestrictionSimpleType#getRedefinedBy()

The following examples show how to use com.sun.xml.internal.xsom.XSRestrictionSimpleType#getRedefinedBy() . 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: SimpleTypeBuilder.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit <jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example 2
Source File: SimpleTypeBuilder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example 3
Source File: SimpleTypeBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example 4
Source File: SimpleTypeBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example 5
Source File: SimpleTypeBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit {@code <jaxb:enum>} customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example 6
Source File: SimpleTypeBuilder.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example 7
Source File: SimpleTypeBuilder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example 8
Source File: SimpleTypeBuilder.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}