private TypeUse bindAttDecl(XSAttributeDecl decl) { SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); stb.refererStack.push( decl ); try { return stb.build(decl.getType()); } finally { stb.refererStack.pop(); } }
/** * Entry point from outside. Builds a BGM type expression * from a simple type schema component. * * @param type * the simple type to be bound. */ public TypeUse build( XSSimpleType type ) { XSSimpleType oldi = initiatingType; this.initiatingType = type; TypeUse e = checkRefererCustomization(type); if(e==null) e = compose(type); initiatingType = oldi; return e; }
/** * Recursively decend the type inheritance chain to find a binding. */ TypeUse compose( XSSimpleType t ) { TypeUse e = find(t); if(e!=null) return e; return t.apply(composer); }
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM ); getErrorReporter().error( type.getLocator(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM_LOCATION ); return bindToTypeSafeEnum( (XSRestrictionSimpleType)type, en.className, en.javadoc, en.members, getEnumMemberMode().getModeWithEnum(), en.getLocation() ); String name = type.getName(); if(name!=null) { r = lookupBuiltin(name); if(r!=null) return r; if(shouldBeMappedToTypeSafeEnumByDefault(rst)) { r = bindToTypeSafeEnum(rst,null,null, Collections.<String, BIEnumMember>emptyMap(), getEnumMemberMode(),null); if(r!=null) return r; return (CNonElement)getClassSelector()._bindToClass(type,null,false);
getErrorReporter().error( loc, Messages.ERR_NO_ENUM_NAME_AVAILABLE ); TypeUse use = build(type.getSimpleBaseType()); refererStack.pop(); List<CEnumConstant> memberList = buildCEnumConstants(type, false, members, errorRef); if(memberList==null || checkMemberNameCollision(memberList)!=null) { switch(mode) { case SKIP: getErrorReporter().error( errorRef[0].getLocator(), Messages.ERR_CANNOT_GENERATE_ENUM_NAME, errorRef[0].getValue() ); } else { CEnumConstant[] collision = checkMemberNameCollision(memberList); getErrorReporter().error( collision[0].getLocator(), Messages.ERR_ENUM_MEMBER_NAME_COLLISION, collision[0].getName() ); getErrorReporter().error( collision[1].getLocator(), Messages.ERR_ENUM_MEMBER_NAME_COLLISION_RELATED ); memberList = buildCEnumConstants(type,true,members,null); break; getErrorReporter().error( loc, Messages.ERR_NO_ENUM_FACET ); return null; scope = new CClassInfoParent.Package(getClassSelector().getPackage(type.getTargetNamespace())); else
XSComponent top = getReferer(); detectJavaTypeCustomization(); } else if( top instanceof XSAttributeDecl ) { XSAttributeDecl aref = (XSAttributeDecl)top; assert aref.getType()==type; detectJavaTypeCustomization(); } else if( top instanceof XSComplexType ) { XSComplexType tref = (XSComplexType)top; assert tref.getBaseType()==type || tref.getContentType()==type; detectJavaTypeCustomization(); } else if( top == type ) { BIConversion conv = getRefererCustomization(); if(conv!=null) { conv.markAsAcknowledged();
getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP, type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap()); if( !canBeMappedToTypeSafeEnum(type) )
/** * 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; } } }
protected final void createSimpleTypeProperty(XSSimpleType type,String propName) { BIProperty prop = BIProperty.getCustomization(type); SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); // since we are building the simple type here, use buildDef CPropertyInfo p = prop.createValueProperty(propName,false,type,stb.buildDef(type),BGMBuilder.getName(type)); getCurrentBean().addProperty(p); }
public TypeUse restrictionSimpleType(XSRestrictionSimpleType type) { // just process the base type. return compose(type.getSimpleBaseType()); } };
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM ); getErrorReporter().error( type.getLocator(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM_LOCATION ); return bindToTypeSafeEnum( (XSRestrictionSimpleType)type, en.className, en.javadoc, en.members, getEnumMemberMode().getModeWithEnum(), en.getLocation() ); String name = type.getName(); if(name!=null) { r = lookupBuiltin(name); if(r!=null) return r; if(shouldBeMappedToTypeSafeEnumByDefault(rst)) { r = bindToTypeSafeEnum(rst,null,null, Collections.<String, BIEnumMember>emptyMap(), getEnumMemberMode(),null); if(r!=null) return r; return (CNonElement)getClassSelector()._bindToClass(type,null,false);
getErrorReporter().error( loc, Messages.ERR_NO_ENUM_NAME_AVAILABLE ); TypeUse use = build(type.getSimpleBaseType()); refererStack.pop(); List<CEnumConstant> memberList = buildCEnumConstants(type, false, members, errorRef); if(memberList==null || checkMemberNameCollision(memberList)!=null) { switch(mode) { case SKIP: getErrorReporter().error( errorRef[0].getLocator(), Messages.ERR_CANNOT_GENERATE_ENUM_NAME, errorRef[0].getValue() ); } else { CEnumConstant[] collision = checkMemberNameCollision(memberList); getErrorReporter().error( collision[0].getLocator(), Messages.ERR_ENUM_MEMBER_NAME_COLLISION, collision[0].getName() ); getErrorReporter().error( collision[1].getLocator(), Messages.ERR_ENUM_MEMBER_NAME_COLLISION_RELATED ); memberList = buildCEnumConstants(type,true,members,null); break; getErrorReporter().error( loc, Messages.ERR_NO_ENUM_FACET ); return null; scope = new CClassInfoParent.Package(getClassSelector().getPackage(type.getTargetNamespace())); else
XSComponent top = getReferer(); detectJavaTypeCustomization(); } else if( top instanceof XSAttributeDecl ) { XSAttributeDecl aref = (XSAttributeDecl)top; assert aref.getType()==type; detectJavaTypeCustomization(); } else if( top instanceof XSComplexType ) { XSComplexType tref = (XSComplexType)top; assert tref.getBaseType()==type || tref.getContentType()==type; detectJavaTypeCustomization(); } else if( top == type ) { BIConversion conv = getRefererCustomization(); if(conv!=null) { conv.markAsAcknowledged();
getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP, type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap()); if( !canBeMappedToTypeSafeEnum(type) )
/** * 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; } } }
protected final void createSimpleTypeProperty(XSSimpleType type,String propName) { BIProperty prop = BIProperty.getCustomization(type); SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); // since we are building the simple type here, use buildDef CPropertyInfo p = prop.createValueProperty(propName,false,type,stb.buildDef(type),BGMBuilder.getName(type)); getCurrentBean().addProperty(p); }
public TypeUse restrictionSimpleType(XSRestrictionSimpleType type) { // just process the base type. return compose(type.getSimpleBaseType()); } };
if( !canBeMappedToTypeSafeEnum(type) ) { getErrorReporter().error( en.getLocation(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM ); getErrorReporter().error( type.getLocator(), Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM_LOCATION ); return bindToTypeSafeEnum( (XSRestrictionSimpleType)type, en.className, en.javadoc, en.members, getEnumMemberMode().getModeWithEnum(), en.getLocation() ); String name = type.getName(); if(name!=null) { r = lookupBuiltin(name); if(r!=null) return r; if(shouldBeMappedToTypeSafeEnumByDefault(rst)) { r = bindToTypeSafeEnum(rst,null,null, Collections.<String, BIEnumMember>emptyMap(), getEnumMemberMode(),null); if(r!=null) return r; return (CNonElement)getClassSelector()._bindToClass(type,null,false);
getErrorReporter().error( loc, Messages.ERR_NO_ENUM_NAME_AVAILABLE ); TypeUse use = build(type.getSimpleBaseType()); refererStack.pop(); List<CEnumConstant> memberList = buildCEnumConstants(type, false, members, errorRef); if(memberList==null || checkMemberNameCollision(memberList)!=null) { switch(mode) { case SKIP: getErrorReporter().error( errorRef[0].getLocator(), Messages.ERR_CANNOT_GENERATE_ENUM_NAME, errorRef[0].getValue() ); } else { CEnumConstant[] collision = checkMemberNameCollision(memberList); getErrorReporter().error( collision[0].getLocator(), Messages.ERR_ENUM_MEMBER_NAME_COLLISION, collision[0].getName() ); getErrorReporter().error( collision[1].getLocator(), Messages.ERR_ENUM_MEMBER_NAME_COLLISION_RELATED ); memberList = buildCEnumConstants(type,true,members,null); break; getErrorReporter().error( loc, Messages.ERR_NO_ENUM_FACET ); return null; scope = new CClassInfoParent.Package(getClassSelector().getPackage(type.getTargetNamespace())); else
XSComponent top = getReferer(); detectJavaTypeCustomization(); } else if( top instanceof XSAttributeDecl ) { XSAttributeDecl aref = (XSAttributeDecl)top; assert aref.getType()==type; detectJavaTypeCustomization(); } else if( top instanceof XSComplexType ) { XSComplexType tref = (XSComplexType)top; assert tref.getBaseType()==type || tref.getContentType()==type; detectJavaTypeCustomization(); } else if( top == type ) { BIConversion conv = getRefererCustomization(); if(conv!=null) { conv.markAsAcknowledged();