com.sun.tools.internal.xjc.model.CPropertyInfo Java Examples
The following examples show how to use
com.sun.tools.internal.xjc.model.CPropertyInfo.
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: IsSetField.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
Example #2
Source File: IsSetField.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
Example #3
Source File: ConstField.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
ConstField( ClassOutlineImpl outline, CPropertyInfo prop ) { super(outline,prop); // we only support value constraints for a single-value property. assert !prop.isCollection(); JPrimitiveType ptype = implType.boxify().getPrimitiveType(); // generate the constant JExpression defaultValue = null; if(prop.defaultValue!=null) defaultValue = prop.defaultValue.compute(outline.parent()); $ref = outline.ref.field(JMod.PUBLIC|JMod.STATIC|JMod.FINAL, ptype!=null?ptype:implType, prop.getName(true), defaultValue ); $ref.javadoc().append(prop.javadoc); annotate($ref); }
Example #4
Source File: ConstField.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
ConstField( ClassOutlineImpl outline, CPropertyInfo prop ) { super(outline,prop); // we only support value constraints for a single-value property. assert !prop.isCollection(); JPrimitiveType ptype = implType.boxify().getPrimitiveType(); // generate the constant JExpression defaultValue = null; if(prop.defaultValue!=null) defaultValue = prop.defaultValue.compute(outline.parent()); $ref = outline.ref.field(JMod.PUBLIC|JMod.STATIC|JMod.FINAL, ptype!=null?ptype:implType, prop.getName(true), defaultValue ); $ref.javadoc().append(prop.javadoc); annotate($ref); }
Example #5
Source File: MultiWildcardComplexTypeBuilder.java From hottub with GNU General Public License v2.0 | 6 votes |
public void build(XSComplexType ct) { XSContentType contentType = ct.getContentType(); builder.recordBindingMode(ct, FALLBACK_CONTENT); BIProperty prop = BIProperty.getCustomization(ct); CPropertyInfo p; if(contentType.asEmpty()!=null) { p = prop.createValueProperty("Content",false,ct,CBuiltinLeafInfo.STRING,null); } else { RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(),false); p = prop.createReferenceProperty("Content", false, ct, ts, true, false, true, false); } selector.getCurrentBean().addProperty(p); // adds attributes and we are through. green.attContainer(ct); }
Example #6
Source File: MultiWildcardComplexTypeBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void build(XSComplexType ct) { XSContentType contentType = ct.getContentType(); builder.recordBindingMode(ct, FALLBACK_CONTENT); BIProperty prop = BIProperty.getCustomization(ct); CPropertyInfo p; if(contentType.asEmpty()!=null) { p = prop.createValueProperty("Content",false,ct,CBuiltinLeafInfo.STRING,null); } else { RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(),false); p = prop.createReferenceProperty("Content", false, ct, ts, true, false, true, false); } selector.getCurrentBean().addProperty(p); // adds attributes and we are through. green.attContainer(ct); }
Example #7
Source File: ConstField.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
ConstField( ClassOutlineImpl outline, CPropertyInfo prop ) { super(outline,prop); // we only support value constraints for a single-value property. assert !prop.isCollection(); JPrimitiveType ptype = implType.boxify().getPrimitiveType(); // generate the constant JExpression defaultValue = null; if(prop.defaultValue!=null) defaultValue = prop.defaultValue.compute(outline.parent()); $ref = outline.ref.field(JMod.PUBLIC|JMod.STATIC|JMod.FINAL, ptype!=null?ptype:implType, prop.getName(true), defaultValue ); $ref.javadoc().append(prop.javadoc); annotate($ref); }
Example #8
Source File: IsSetField.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
Example #9
Source File: MultiWildcardComplexTypeBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void build(XSComplexType ct) { XSContentType contentType = ct.getContentType(); builder.recordBindingMode(ct, FALLBACK_CONTENT); BIProperty prop = BIProperty.getCustomization(ct); CPropertyInfo p; if(contentType.asEmpty()!=null) { p = prop.createValueProperty("Content",false,ct,CBuiltinLeafInfo.STRING,null); } else { RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(),false); p = prop.createReferenceProperty("Content", false, ct, ts, true, false, true, false); } selector.getCurrentBean().addProperty(p); // adds attributes and we are through. green.attContainer(ct); }
Example #10
Source File: TDTDReader.java From jdk8u60 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 #11
Source File: BeanGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Determines the FieldRenderer used for the given FieldUse, * then generates the field declaration and accessor methods. * * The <code>fields</code> map will be updated with the newly * created FieldRenderer. */ private FieldOutline generateFieldDecl(ClassOutlineImpl cc, CPropertyInfo prop) { FieldRenderer fr = prop.realization; if (fr == null) // none is specified. use the default factory { fr = model.options.getFieldRendererFactory().getDefault(); } FieldOutline field = fr.generate(cc, prop); fields.put(prop, field); return field; }
Example #12
Source File: BIFactoryMethod.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * If the given component has {@link BIInlineBinaryData} customization, * reflect that to the specified property. */ public static void handle(XSComponent source, CPropertyInfo prop) { BIInlineBinaryData inline = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIInlineBinaryData.class); if(inline!=null) { prop.inlineBinaryData = true; inline.markAsAcknowledged(); } }
Example #13
Source File: DefaultFieldRenderer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private FieldRenderer decideRenderer(ClassOutlineImpl outline, CPropertyInfo prop) { if (prop instanceof CReferencePropertyInfo) { CReferencePropertyInfo p = (CReferencePropertyInfo)prop; if (p.isDummy()) { return frf.getDummyList(outline.parent().getCodeModel().ref(ArrayList.class)); } if (p.isContent() && (p.isMixedExtendedCust())) { return frf.getContentList(outline.parent().getCodeModel().ref(ArrayList.class).narrow(Serializable.class)); } } if(!prop.isCollection()) { // non-collection field // TODO: check for bidning info for optionalPrimitiveType=boxed or // noHasMethod=false and noDeletedMethod=false if(prop.isUnboxable()) // this one uses a primitive type as much as possible return frf.getRequiredUnboxed(); else // otherwise use the default non-collection field return frf.getSingle(); } if( defaultCollectionFieldRenderer==null ) { return frf.getList(outline.parent().getCodeModel().ref(ArrayList.class)); } // this field is a collection field. // use untyped list as the default. This is consistent // to the JAXB spec. return defaultCollectionFieldRenderer; }
Example #14
Source File: BindPurple.java From openjdk-jdk9 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 #15
Source File: NoExtendedContentField.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * @param coreList * A concrete class that implements the List interface. * An instance of this class will be used to store data * for this field. */ protected NoExtendedContentField(ClassOutlineImpl context, CPropertyInfo prop, JClass coreList) { // the JAXB runtime picks ArrayList if the signature is List, // so don't do eager allocation if it's ArrayList. // otherwise we need to do eager allocation so that the collection type specified by the user // will be used. super(context, prop, false); this.coreList = coreList; generate(); }
Example #16
Source File: DefaultParticleBinder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Reads fields of the super class and includes them * to name collision tests. */ void readSuperClass( CClassInfo base ) { for( ; base!=null; base=base.getBaseClass() ) { for( CPropertyInfo p : base.getProperties() ) occupiedLabels.put(p.getName(true),p); } }
Example #17
Source File: BeanGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Determines the FieldRenderer used for the given FieldUse, * then generates the field declaration and accessor methods. * * The <code>fields</code> map will be updated with the newly * created FieldRenderer. */ private FieldOutline generateFieldDecl(ClassOutlineImpl cc, CPropertyInfo prop) { FieldRenderer fr = prop.realization; if (fr == null) // none is specified. use the default factory { fr = model.options.getFieldRendererFactory().getDefault(); } FieldOutline field = fr.generate(cc, prop); fields.put(prop, field); return field; }
Example #18
Source File: BeanGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary. * Also generates other per-property annotations * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary. */ public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) { CAdapter adapter = prop.getAdapter(); if (adapter != null) { if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) { field.annotate(XmlAttachmentRef.class); } else { // [RESULT] // @XmlJavaTypeAdapter( Foo.class ) XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class); xjtw.value(adapter.adapterType.toType(this, EXPOSED)); } } switch (prop.id()) { case ID: field.annotate(XmlID.class); break; case IDREF: field.annotate(XmlIDREF.class); break; } if (prop.getExpectedMimeType() != null) { field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString()); } }
Example #19
Source File: BIFactoryMethod.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * If the given component has {@link BIInlineBinaryData} customization, * reflect that to the specified property. */ public static void handle(XSComponent source, CPropertyInfo prop) { BIInlineBinaryData inline = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIInlineBinaryData.class); if(inline!=null) { prop.inlineBinaryData = true; inline.markAsAcknowledged(); } }
Example #20
Source File: ContentListField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * @param coreList * A concrete class that implements the List interface. * An instance of this class will be used to store data * for this field. */ protected ContentListField(ClassOutlineImpl context, CPropertyInfo prop, JClass coreList) { // the JAXB runtime picks ArrayList if the signature is List, // so don't do eager allocation if it's ArrayList. // otherwise we need to do eager allocation so that the collection type specified by the user // will be used. super(context, prop, false); this.coreList = coreList; generate(); }
Example #21
Source File: BIProperty.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public CPropertyInfo createElementOrReferenceProperty( String defaultName, boolean forConstant, XSParticle source, RawTypeSet types) { boolean generateRef; switch(types.canBeTypeRefs) { case CAN_BE_TYPEREF: case SHOULD_BE_TYPEREF: // it's up to the use Boolean b = generateElementProperty(); if(b==null) // follow XJC recommendation generateRef = types.canBeTypeRefs== RawTypeSet.Mode.CAN_BE_TYPEREF; else // use the value user gave us generateRef = b; break; case MUST_BE_REFERENCE: generateRef = true; break; default: throw new AssertionError(); } if(generateRef) { return createReferenceProperty(defaultName,forConstant,source,types, false, false, false, false); } else { return createElementProperty(defaultName,forConstant,source,types); } }
Example #22
Source File: UntypedListFieldRenderer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public FieldOutline generate(ClassOutlineImpl context, CPropertyInfo prop) { if (dummy) { return new DummyListField(context, prop, coreList); } if (content) { return new ContentListField(context, prop, coreList); } return new UntypedListField(context, prop, coreList); }
Example #23
Source File: DefaultParticleBinder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Reads fields of the super class and includes them * to name collision tests. */ void readSuperClass( CClassInfo base ) { for( ; base!=null; base=base.getBaseClass() ) { for( CPropertyInfo p : base.getProperties() ) occupiedLabels.put(p.getName(true),p); } }
Example #24
Source File: ContentListField.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * @param coreList * A concrete class that implements the List interface. * An instance of this class will be used to store data * for this field. */ protected ContentListField(ClassOutlineImpl context, CPropertyInfo prop, JClass coreList) { // the JAXB runtime picks ArrayList if the signature is List, // so don't do eager allocation if it's ArrayList. // otherwise we need to do eager allocation so that the collection type specified by the user // will be used. super(context, prop, false); this.coreList = coreList; generate(); }
Example #25
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 #26
Source File: ModelChecker.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private boolean checkPropertyCollision(CPropertyInfo p1, CPropertyInfo p2) { if(!p1.getName(true).equals(p2.getName(true))) return false; errorReceiver.error(p1.locator,Messages.DUPLICATE_PROPERTY.format(p1.getName(true))); errorReceiver.error(p2.locator,Messages.ERR_RELEVANT_LOCATION.format()); return true; }
Example #27
Source File: ClassOutline.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Gets all the {@link FieldOutline}s newly declared * in this class. */ public final FieldOutline[] getDeclaredFields() { List<CPropertyInfo> props = target.getProperties(); FieldOutline[] fr = new FieldOutline[props.size()]; for( int i=0; i<fr.length; i++ ) fr[i] = parent().getField(props.get(i)); return fr; }
Example #28
Source File: ClassOutline.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Gets all the {@link FieldOutline}s newly declared * in this class. */ public final FieldOutline[] getDeclaredFields() { List<CPropertyInfo> props = target.getProperties(); FieldOutline[] fr = new FieldOutline[props.size()]; for( int i=0; i<fr.length; i++ ) fr[i] = parent().getField(props.get(i)); return fr; }
Example #29
Source File: AbstractField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns contents to be added to javadoc. */ protected final List<Object> listPossibleTypes( CPropertyInfo prop ) { List<Object> r = new ArrayList<Object>(); for( CTypeInfo tt : prop.ref() ) { JType t = tt.getType().toType(outline.parent(),Aspect.EXPOSED); if( t.isPrimitive() || t.isArray() ) r.add(t.fullName()); else { r.add(t); r.add("\n"); } } return r; }
Example #30
Source File: DefaultFieldRenderer.java From hottub with GNU General Public License v2.0 | 5 votes |
private FieldRenderer decideRenderer(ClassOutlineImpl outline, CPropertyInfo prop) { if (prop instanceof CReferencePropertyInfo) { CReferencePropertyInfo p = (CReferencePropertyInfo)prop; if (p.isDummy()) { return frf.getDummyList(outline.parent().getCodeModel().ref(ArrayList.class)); } if (p.isContent() && (p.isMixedExtendedCust())) { return frf.getContentList(outline.parent().getCodeModel().ref(ArrayList.class).narrow(Serializable.class)); } } if(!prop.isCollection()) { // non-collection field // TODO: check for bidning info for optionalPrimitiveType=boxed or // noHasMethod=false and noDeletedMethod=false if(prop.isUnboxable()) // this one uses a primitive type as much as possible return frf.getRequiredUnboxed(); else // otherwise use the default non-collection field return frf.getSingle(); } if( defaultCollectionFieldRenderer==null ) { return frf.getList(outline.parent().getCodeModel().ref(ArrayList.class)); } // this field is a collection field. // use untyped list as the default. This is consistent // to the JAXB spec. return defaultCollectionFieldRenderer; }