/** * Performs error check */ public void errorCheck() { ErrorReceiver er = Ring.get(ErrorReceiver.class); for (QName n : enumBaseTypes) { XSSchemaSet xs = Ring.get(XSSchemaSet.class); XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart()); if(st==null) { er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n)); continue; } if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) { er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n)); continue; } } }
/** * Performs error check */ public void errorCheck() { ErrorReceiver er = Ring.get(ErrorReceiver.class); for (QName n : enumBaseTypes) { XSSchemaSet xs = Ring.get(XSSchemaSet.class); XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart()); if(st==null) { er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n)); continue; } if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) { er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n)); continue; } } }
/** * Performs error check */ public void errorCheck() { ErrorReceiver er = Ring.get(ErrorReceiver.class); for (QName n : enumBaseTypes) { XSSchemaSet xs = Ring.get(XSSchemaSet.class); XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart()); if(st==null) { er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n)); continue; } if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) { er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n)); continue; } } }
/** * Performs error check */ public void errorCheck() { ErrorReceiver er = Ring.get(ErrorReceiver.class); for (QName n : enumBaseTypes) { XSSchemaSet xs = Ring.get(XSSchemaSet.class); XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart()); if(st==null) { er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n)); continue; } if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) { er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n)); continue; } } }
/** * Performs error check */ public void errorCheck() { ErrorReceiver er = Ring.get(ErrorReceiver.class); for (QName n : enumBaseTypes) { XSSchemaSet xs = Ring.get(XSSchemaSet.class); XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart()); if(st==null) { er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n)); continue; } if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) { er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n)); continue; } } }
if( !canBeMappedToTypeSafeEnum(type) )
/** * 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() || facets.size()>builder.getGlobalBinding().getDefaultEnumMemberSizeCap() ) // if the type itself doesn't have the enumeration facet, // it won't be mapped to a type-safe enum. // // if there are too many facets, it's not very useful 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; }
/** * 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() || facets.size()>builder.getGlobalBinding().getDefaultEnumMemberSizeCap() ) // if the type itself doesn't have the enumeration facet, // it won't be mapped to a type-safe enum. // // if there are too many facets, it's not very useful 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; }
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM );
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM );
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM );
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM );
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM );