com.sun.tools.internal.xjc.model.TypeUse Java Examples
The following examples show how to use
com.sun.tools.internal.xjc.model.TypeUse.
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: BIConversion.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public TypeUse getTypeUse(XSSimpleType owner) { if(typeUse!=null) return typeUse; JCodeModel cm = getCodeModel(); JDefinedClass a; try { a = cm._class(adapter); a.hide(); // we assume this is given by the user a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow( cm.ref(type))); } catch (JClassAlreadyExistsException e) { a = e.getExistingClass(); } // TODO: it's not correct to say that it adapts from String, // but OTOH I don't think we can compute that. typeUse = TypeUseFactory.adapt( CBuiltinLeafInfo.STRING, new CAdapter(a)); return typeUse; }
Example #2
Source File: BIConversion.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public TypeUse getTypeUse(XSSimpleType owner) { if(typeUse!=null) return typeUse; JCodeModel cm = getCodeModel(); JDefinedClass a; try { a = cm._class(adapter); a.hide(); // we assume this is given by the user a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow( cm.ref(type))); } catch (JClassAlreadyExistsException e) { a = e.getExistingClass(); } // TODO: it's not correct to say that it adapts from String, // but OTOH I don't think we can compute that. typeUse = TypeUseFactory.adapt( CBuiltinLeafInfo.STRING, new CAdapter(a)); return typeUse; }
Example #3
Source File: BIProperty.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
Example #4
Source File: BIProperty.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
Example #5
Source File: TypeUseBinder.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private TypeUse onDataType(String datatypeLibrary, String type) { DatatypeLib lib = compiler.datatypes.get(datatypeLibrary); if(lib!=null) { TypeUse use = lib.get(type); if(use!=null) return use; } // unknown return CBuiltinLeafInfo.STRING; }
Example #6
Source File: TDTDReader.java From hottub with GNU General Public License v2.0 | 5 votes |
protected CPropertyInfo createAttribute( String elementName, String attributeName, String attributeType, String[] enums, short attributeUse, String defaultValue ) throws SAXException { boolean required = attributeUse==USE_REQUIRED; // get the attribute-property declaration BIElement edecl = bindInfo.element(elementName); BIAttribute decl=null; if(edecl!=null) decl=edecl.attribute(attributeName); String propName; if(decl==null) propName = model.getNameConverter().toPropertyName(attributeName); else propName = decl.getPropertyName(); QName qname = new QName("",attributeName); // if no declaration is specified, just wrap it by // a FieldItem and let the normalizer handle its content. TypeUse use; if(decl!=null && decl.getConversion()!=null) use = decl.getConversion().getTransducer(); else use = builtinConversions.get(attributeType); CPropertyInfo r = new CAttributePropertyInfo( propName, null,null/*TODO*/, copyLocator(), qname, use, null, required ); if(defaultValue!=null) r.defaultValue = CDefaultValue.create( use, new XmlString(defaultValue) ); return r; }
Example #7
Source File: BindPurple.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Attribute use always becomes a property. */ public void attributeUse(XSAttributeUse use) { boolean hasFixedValue = use.getFixedValue()!=null; BIProperty pc = BIProperty.getCustomization(use); // map to a constant property ? boolean toConstant = pc.isConstantProperty() && hasFixedValue; TypeUse attType = bindAttDecl(use.getDecl()); CPropertyInfo prop = pc.createAttributeProperty( use, attType ); if(toConstant) { prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue()); prop.realization = builder.fieldRendererFactory.getConst(prop.realization); } else if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) { // don't support a collection default value. That's difficult to do. // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases if(use.getDefaultValue()!=null) { // this attribute use has a default value. // the item type is guaranteed to be a leaf type... or TODO: is it really so? // don't support default values if it's a list prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue()); } else if(use.getFixedValue()!=null) { prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue()); } } else if(prop.baseType != null && prop.baseType.isPrimitive()) { ErrorReporter errorReporter = Ring.get(ErrorReporter.class); errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name()); } getCurrentBean().addProperty(prop); }
Example #8
Source File: SimpleTypeBuilder.java From hottub with GNU General Public License v2.0 | 5 votes |
public TypeUse listSimpleType(XSListSimpleType type) { // bind item type individually and then compose them into a list // facets on the list shouldn't be taken account when binding item types, // so weed to call build(), not compose(). XSSimpleType itemType = type.getItemType(); refererStack.push(itemType); TypeUse tu = TypeUseFactory.makeCollection(build(type.getItemType())); refererStack.pop(); return tu; }
Example #9
Source File: TDTDReader.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected CPropertyInfo createAttribute( String elementName, String attributeName, String attributeType, String[] enums, short attributeUse, String defaultValue ) throws SAXException { boolean required = attributeUse==USE_REQUIRED; // get the attribute-property declaration BIElement edecl = bindInfo.element(elementName); BIAttribute decl=null; if(edecl!=null) decl=edecl.attribute(attributeName); String propName; if(decl==null) propName = model.getNameConverter().toPropertyName(attributeName); else propName = decl.getPropertyName(); QName qname = new QName("",attributeName); // if no declaration is specified, just wrap it by // a FieldItem and let the normalizer handle its content. TypeUse use; if(decl!=null && decl.getConversion()!=null) use = decl.getConversion().getTransducer(); else use = builtinConversions.get(attributeType); CPropertyInfo r = new CAttributePropertyInfo( propName, null,null/*TODO*/, copyLocator(), qname, use, null, required ); if(defaultValue!=null) r.defaultValue = CDefaultValue.create( use, new XmlString(defaultValue) ); return r; }
Example #10
Source File: SimpleTypeBuilder.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #11
Source File: ElementMappingImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected ElementMappingImpl(JAXBModelImpl parent, CElementInfo elementInfo) { super(parent,elementInfo); TypeUse t = clazz.getContentType(); if(clazz.getProperty().isCollection()) t = TypeUseFactory.makeCollection(t); CAdapter a = clazz.getProperty().getAdapter(); if(a!=null) t = TypeUseFactory.adapt(t,a); taa = new TypeAndAnnotationImpl(parent.outline,t); }
Example #12
Source File: JAXBModelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public TypeAndAnnotation getJavaType(QName xmlTypeName) { // TODO: primitive type handling? TypeUse use = model.typeUses().get(xmlTypeName); if(use==null) return null; return new TypeAndAnnotationImpl(outline,use); }
Example #13
Source File: SimpleTypeBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public TypeUse listSimpleType(XSListSimpleType type) { // bind item type individually and then compose them into a list // facets on the list shouldn't be taken account when binding item types, // so weed to call build(), not compose(). XSSimpleType itemType = type.getItemType(); refererStack.push(itemType); TypeUse tu = TypeUseFactory.makeCollection(build(type.getItemType())); refererStack.pop(); return tu; }
Example #14
Source File: SimpleTypeBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #15
Source File: RawTypeSetBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public XmlTypeRef(XSElementDecl decl) { this.decl = decl; SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); stb.refererStack.push(decl); TypeUse r = Ring.get(ClassSelector.class).bindToType(decl.getType(),decl); stb.refererStack.pop(); target = r; }
Example #16
Source File: SimpleTypeBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #17
Source File: TypeUseBinder.java From hottub with GNU General Public License v2.0 | 5 votes |
private TypeUse onContainer(DContainerPattern p) { TypeUse t=null; for( DPattern child : p ) { TypeUse s = child.accept(this); if(t!=null && t!=s) return CBuiltinLeafInfo.STRING; // heterogenous t = s; } return t; }
Example #18
Source File: Element.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * When this element is an PCDATA-only content model, * returns the conversion for it. Otherwise the behavior is undefined. */ private TypeUse getConversion() { assert contentModel == Term.EMPTY; // this is PCDATA-only element BIElement e = owner.bindInfo.element(name); if(e!=null) { BIConversion conv = e.getConversion(); if(conv!=null) return conv.getTransducer(); } return CBuiltinLeafInfo.STRING; }
Example #19
Source File: SimpleTypeBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * A version of the {@link #build(XSSimpleType)} method * used to bind the definition of a class generated from * the given simple type. */ public TypeUse buildDef( XSSimpleType type ) { XSSimpleType oldi = initiatingType; this.initiatingType = type; TypeUse e = type.apply(composer); initiatingType = oldi; return e; }
Example #20
Source File: JAXBModelImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public TypeAndAnnotation getJavaType(QName xmlTypeName) { // TODO: primitive type handling? TypeUse use = model.typeUses().get(xmlTypeName); if(use==null) return null; return new TypeAndAnnotationImpl(outline,use); }
Example #21
Source File: SimpleTypeBuilder.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public TypeUse listSimpleType(XSListSimpleType type) { // bind item type individually and then compose them into a list // facets on the list shouldn't be taken account when binding item types, // so weed to call build(), not compose(). XSSimpleType itemType = type.getItemType(); refererStack.push(itemType); TypeUse tu = TypeUseFactory.makeCollection(build(type.getItemType())); refererStack.pop(); return tu; }
Example #22
Source File: RawTypeSetBuilder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public XmlTypeRef(XSElementDecl decl) { this.decl = decl; SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); stb.refererStack.push(decl); TypeUse r = Ring.get(ClassSelector.class).bindToType(decl.getType(),decl); stb.refererStack.pop(); target = r; }
Example #23
Source File: ElementMappingImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected ElementMappingImpl(JAXBModelImpl parent, CElementInfo elementInfo) { super(parent,elementInfo); TypeUse t = clazz.getContentType(); if(clazz.getProperty().isCollection()) t = TypeUseFactory.makeCollection(t); CAdapter a = clazz.getProperty().getAdapter(); if(a!=null) t = TypeUseFactory.adapt(t,a); taa = new TypeAndAnnotationImpl(parent.outline,t); }
Example #24
Source File: RawTypeSetBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public XmlTypeRef(XSElementDecl decl) { this.decl = decl; SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); stb.refererStack.push(decl); TypeUse r = Ring.get(ClassSelector.class).bindToType(decl.getType(),decl); stb.refererStack.pop(); target = r; }
Example #25
Source File: TypeUseBinder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private TypeUse onDataType(String datatypeLibrary, String type) { DatatypeLib lib = compiler.datatypes.get(datatypeLibrary); if(lib!=null) { TypeUse use = lib.get(type); if(use!=null) return use; } // unknown return CBuiltinLeafInfo.STRING; }
Example #26
Source File: TDTDReader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected CPropertyInfo createAttribute( String elementName, String attributeName, String attributeType, String[] enums, short attributeUse, String defaultValue ) throws SAXException { boolean required = attributeUse==USE_REQUIRED; // get the attribute-property declaration BIElement edecl = bindInfo.element(elementName); BIAttribute decl=null; if(edecl!=null) decl=edecl.attribute(attributeName); String propName; if(decl==null) propName = model.getNameConverter().toPropertyName(attributeName); else propName = decl.getPropertyName(); QName qname = new QName("",attributeName); // if no declaration is specified, just wrap it by // a FieldItem and let the normalizer handle its content. TypeUse use; if(decl!=null && decl.getConversion()!=null) use = decl.getConversion().getTransducer(); else use = builtinConversions.get(attributeType); CPropertyInfo r = new CAttributePropertyInfo( propName, null,null/*TODO*/, copyLocator(), qname, use, null, required ); if(defaultValue!=null) r.defaultValue = CDefaultValue.create( use, new XmlString(defaultValue) ); return r; }
Example #27
Source File: BindPurple.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Attribute use always becomes a property. */ public void attributeUse(XSAttributeUse use) { boolean hasFixedValue = use.getFixedValue()!=null; BIProperty pc = BIProperty.getCustomization(use); // map to a constant property ? boolean toConstant = pc.isConstantProperty() && hasFixedValue; TypeUse attType = bindAttDecl(use.getDecl()); CPropertyInfo prop = pc.createAttributeProperty( use, attType ); if(toConstant) { prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue()); prop.realization = builder.fieldRendererFactory.getConst(prop.realization); } else if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) { // don't support a collection default value. That's difficult to do. // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases if(use.getDefaultValue()!=null) { // this attribute use has a default value. // the item type is guaranteed to be a leaf type... or TODO: is it really so? // don't support default values if it's a list prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue()); } else if(use.getFixedValue()!=null) { prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue()); } } else if(prop.baseType != null && prop.baseType.isPrimitive()) { ErrorReporter errorReporter = Ring.get(ErrorReporter.class); errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name()); } getCurrentBean().addProperty(prop); }
Example #28
Source File: BindPurple.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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(); } }
Example #29
Source File: BindPurple.java From hottub with GNU General Public License v2.0 | 5 votes |
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(); } }
Example #30
Source File: TypeUseBinder.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private TypeUse onContainer(DContainerPattern p) { TypeUse t=null; for( DPattern child : p ) { TypeUse s = child.accept(this); if(t!=null && t!=s) return CBuiltinLeafInfo.STRING; // heterogenous t = s; } return t; }