当前位置: 首页>>代码示例>>Java>>正文


Java XSRestrictionSimpleType.isLocal方法代码示例

本文整理汇总了Java中com.sun.xml.internal.xsom.XSRestrictionSimpleType.isLocal方法的典型用法代码示例。如果您正苦于以下问题:Java XSRestrictionSimpleType.isLocal方法的具体用法?Java XSRestrictionSimpleType.isLocal怎么用?Java XSRestrictionSimpleType.isLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.xml.internal.xsom.XSRestrictionSimpleType的用法示例。


在下文中一共展示了XSRestrictionSimpleType.isLocal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldBeMappedToTypeSafeEnumByDefault

import com.sun.xml.internal.xsom.XSRestrictionSimpleType; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:SimpleTypeBuilder.java

示例2: shouldBeMappedToTypeSafeEnumByDefault

import com.sun.xml.internal.xsom.XSRestrictionSimpleType; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:SimpleTypeBuilder.java


注:本文中的com.sun.xml.internal.xsom.XSRestrictionSimpleType.isLocal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。