xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile Java2Schema.java
Date Tue, 20 Apr 2004 07:01:15 GMT
zieg        2004/04/20 00:01:15

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        ByNameBean.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        Java2Schema.java
  Log:
  Make java2schema write out supertype properties with type properties
  to be consistent with other binding tasks.  Someday we will likely
  undo this change and put the inheritance relationship into bts.
  
  Revision  Changes    Path
  1.12      +9 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ByNameBean.java
  
  Index: ByNameBean.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ByNameBean.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ByNameBean.java	25 Mar 2004 22:00:28 -0000	1.11
  +++ ByNameBean.java	20 Apr 2004 07:01:14 -0000	1.12
  @@ -118,7 +118,7 @@
      * Adds a new property
      */
     public void addProperty(QNameProperty newProp) {
  -    if (newProp.isAttribute() ? attProps.containsKey(newProp.getQName()) : eltProps.containsKey(newProp.getQName()))
  +    if (hasProperty(newProp))
         throw new IllegalArgumentException("duplicate property: " + newProp.getQName() +
" in type " + this);
   
       props.add(newProp);
  @@ -128,7 +128,14 @@
         eltProps.put(newProp.getQName(), newProp);
     }
   
  -  // ========================================================================
  +    public boolean hasProperty(QNameProperty newProp)
  +    {
  +        final QName prop_qname = newProp.getQName();
  +        return newProp.isAttribute() ? attProps.containsKey(prop_qname) :
  +            eltProps.containsKey(prop_qname);
  +    }
  +
  +    // ========================================================================
     // BindingType implementation
   
     /**
  
  
  
  1.51      +20 -2     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2Schema.java
  
  Index: Java2Schema.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2Schema.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- Java2Schema.java	15 Apr 2004 22:58:44 -0000	1.50
  +++ Java2Schema.java	20 Apr 2004 07:01:14 -0000	1.51
  @@ -30,6 +30,7 @@
   import java.util.Map;
   import java.util.HashMap;
   import java.util.Collection;
  +import java.util.Iterator;
   import java.io.IOException;
   import java.io.StringWriter;
   
  @@ -209,10 +210,11 @@
       // unfortunate that the SchemaDocument model does not allow us to deal
       // with this kind of thing in a more elegant and polymorphic way.
       ExtensionType extType = null;
  +    BindingType superBindingType = null;
       if (superclass != null && !superclass.isObjectType() &&
         !getAnnotation(clazz,TAG_CT_IGNORESUPER,false)) {
         // FIXME we're ignoring interfaces at the moment
  -      BindingType superBindingType = getBindingTypeFor(superclass);
  +      superBindingType = getBindingTypeFor(superclass);
         ComplexContentDocument.ComplexContent ccd = xsType.addNewComplexContent();
         extType = ccd.addNewExtension();
         extType.setBase(superBindingType.getName().getXmlName().getQName());
  @@ -227,6 +229,21 @@
         logError("Unexpected simple type",clazz);
         return bindType;
       }
  +
  +    //add super's props first
  +    if (superBindingType != null) {
  +      //REVIEW: will it ever be possible to have another type as the super type?
  +      //REVIEW: is copy by ref safe here?
  +      //TODO: deal with java->schema name collisions across inherited types
  +      ByNameBean super_type = (ByNameBean)superBindingType;
  +      for(Iterator itr = super_type.getProperties().iterator() ; itr.hasNext() ; ) {
  +        final QNameProperty prop = (QNameProperty)itr.next();
  +        bindType.addProperty(prop);
  +      }
  +      bindType.setAnyAttributeProperty(super_type.getAnyAttributeProperty());
  +      bindType.setAnyElementProperty(super_type.getAnyElementProperty());
  +    }
  +
       String rootName = getAnnotation(clazz,TAG_CT_ROOT,null);
       if (rootName != null) {
         QName rootQName = new QName(tns, rootName);
  @@ -719,7 +736,8 @@
        * initially).
        */
       private void addBtsProperty() {
  -      if (mBtsProp != null) mBtsType.addProperty(mBtsProp);
  +      if (mBtsProp != null && !mBtsType.hasProperty(mBtsProp))
  +          mBtsType.addProperty(mBtsProp);
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message