xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From david...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases BindingTests.java
Date Tue, 28 Oct 2003 17:51:27 GMT
davidbau    2003/10/28 09:51:27

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        BaseBindingLoader.java BindingFile.java
                        BindingLoader.java BindingProperty.java
                        BindingType.java BuiltinBindingLoader.java
                        BuiltinBindingType.java ByNameBean.java
                        JavaName.java JaxbBean.java ParticleProperty.java
                        PathBindingLoader.java SimpleBindingType.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        JAXRPCSchemaBinder.java Java2Schema.java
               v2/src/configschema/schema binding-config.xsd
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        BindingContextFactory.java
                        ByNameRuntimeBindingType.java
                        RuntimeBindingTypeTable.java UnmarshalContext.java
                        UnmarshallerImpl.java
               v2/test/cases/schema/typesonly typesonly.xsd
               v2/test/src/drt/drtcases BindingTests.java
  Added:       v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        BindingTypeName.java
  Log:
  Refactoring some code that needed cleanup.
  
  (1) BindingTypeName is now introduced and public: it is a JavaName + XmlName
  (2) Everywhere we used to return a bindingType where we effectively acutally
      had a BindingTypeName, we now return a BindingTypeName.
  (3) JavaName now carries around a bit that says whether it's an XmlObject
  (4) java-to-element table added to binding-config.xml, for marshalling java
      classes to whole documents.
  
  Code review: Scott Z
  Regression tests: passed
  
  Revision  Changes    Path
  1.3       +62 -61    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BaseBindingLoader.java
  
  Index: BaseBindingLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BaseBindingLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseBindingLoader.java	13 Oct 2003 22:26:50 -0000	1.2
  +++ BaseBindingLoader.java	28 Oct 2003 17:51:26 -0000	1.3
  @@ -58,94 +58,95 @@
   
   import java.util.Map;
   import java.util.LinkedHashMap;
  +import java.util.Collection;
   
   /**
    * Base class
    */ 
   public abstract class BaseBindingLoader implements BindingLoader
   {
  -    protected final Map bindingTypes = new LinkedHashMap();    // name-pair -> BindingType
  -    protected final Map xmlFromJava = new LinkedHashMap();     // javaName -> pair
  -    protected final Map javaFromXmlPojo = new LinkedHashMap(); // xmlName -> pair (pojo)
  -    protected final Map javaFromXmlObj = new LinkedHashMap();  // xmlName -> pair (xmlobj)
  +    private final Map bindingTypes = new LinkedHashMap();    // name-pair -> BindingType
  +    private final Map xmlFromJava = new LinkedHashMap();     // javaName -> pair
  +    private final Map xmlFromJavaElement = new LinkedHashMap(); // javaName -> pair (xml element)
  +    private final Map javaFromXmlPojo = new LinkedHashMap(); // xmlName -> pair (pojo)
  +    private final Map javaFromXmlObj = new LinkedHashMap();  // xmlName -> pair (xmlobj)
   
  -    public BindingType getBindingType(JavaName jName, XmlName xName)
  +    public BindingType getBindingType(BindingTypeName btName)
       {
  -        return (BindingType)bindingTypes.get(pair(jName, xName));
  +        return (BindingType)bindingTypes.get(btName);
       }
   
  -    public BindingType getBindingTypeForXmlPojo(XmlName xName)
  +    public BindingTypeName lookupPojoFor(XmlName xName)
       {
  -        NamePair pair = (NamePair)javaFromXmlPojo.get(xName);
  -        if (pair == null)
  -            return null;
  -        
  -        return (BindingType)bindingTypes.get(pair);
  +        return (BindingTypeName)javaFromXmlPojo.get(xName);
       }
   
  -    public BindingType getBindingTypeForXmlObj(XmlName xName)
  +    public BindingTypeName lookupXmlObjectFor(XmlName xName)
       {
  -        NamePair pair = (NamePair)javaFromXmlObj.get(xName);
  -        if (pair == null)
  -            return null;
  -        
  -        return (BindingType)bindingTypes.get(pair);
  +        return (BindingTypeName)javaFromXmlObj.get(xName);
       }
   
  -    public BindingType getBindingTypeForJava(JavaName jName)
  +    public BindingTypeName lookupTypeFor(JavaName jName)
       {
  -        NamePair pair = (NamePair)xmlFromJava.get(jName);
  -        if (pair == null)
  -            return null;
  -        
  -        return (BindingType)bindingTypes.get(pair);
  +        return (BindingTypeName)xmlFromJava.get(jName);
       }
   
  -    protected static NamePair pair(JavaName jName, XmlName xName)
  +    public BindingTypeName lookupElementFor(JavaName jName)
       {
  -        return new NamePair(jName, xName);
  +        return (BindingTypeName)xmlFromJavaElement.get(jName);
       }
  -
  -    protected static class NamePair
  +    
  +    protected void addBindingType(BindingType bType)
       {
  -        private final JavaName jName;
  -        private final XmlName xName;
  -
  -        NamePair(JavaName jName, XmlName xName)
  -        {
  -            this.jName = jName;
  -            this.xName = xName;
  -        }
  -
  -        public JavaName getJavaName()
  -        {
  -            return jName;
  -        }
  +        bindingTypes.put(bType.getName(), bType);
  +    }
  +    
  +    protected void addPojoFor(XmlName xName, BindingTypeName btName)
  +    {
  +        assert(!btName.getJavaName().isXmlObject());
  +        javaFromXmlPojo.put(xName, btName);
  +    }
   
  -        public XmlName getXmlName()
  -        {
  -            return xName;
  -        }
  +    protected void addXmlObjectFor(XmlName xName, BindingTypeName btName)
  +    {
  +        assert(btName.getJavaName().isXmlObject());
  +        javaFromXmlObj.put(xName, btName);
  +    }
   
  -        public boolean equals(Object o)
  -        {
  -            if (this == o) return true;
  -            if (!(o instanceof BindingFile.NamePair)) return false;
  +    protected void addTypeFor(JavaName jName, BindingTypeName btName)
  +    {
  +        assert(btName.getXmlName().isSchemaType());
  +        xmlFromJava.put(jName, btName);
  +    }
   
  -            final BindingFile.NamePair namePair = (BindingFile.NamePair) o;
  +    protected void addElementFor(JavaName jName, BindingTypeName btName)
  +    {
  +        assert(btName.getXmlName().getComponentType() == XmlName.ELEMENT);
  +        xmlFromJavaElement.put(jName, btName);
  +    }
  +    
  +    public Collection bindingTypes()
  +    {
  +        return bindingTypes.values();
  +    }
  +    
  +    public Collection typeMappedJavaTypes()
  +    {
  +        return xmlFromJava.keySet();
  +    }
   
  -            if (!jName.equals(namePair.jName)) return false;
  -            if (!xName.equals(namePair.xName)) return false;
  +    public Collection elementMappedJavaTypes()
  +    {
  +        return xmlFromJavaElement.keySet();
  +    }
   
  -            return true;
  -        }
  +    public Collection pojoMappedXmlTypes()
  +    {
  +        return javaFromXmlPojo.keySet();
  +    }
   
  -        public int hashCode()
  -        {
  -            int result;
  -            result = jName.hashCode();
  -            result = 29 * result + xName.hashCode();
  -            return result;
  -        }
  +    public Collection xmlObjectMappedXmlTypes()
  +    {
  +        return javaFromXmlObj.keySet();
       }
   }
  
  
  
  1.7       +48 -58    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingFile.java
  
  Index: BindingFile.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingFile.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BindingFile.java	27 Oct 2003 19:17:21 -0000	1.6
  +++ BindingFile.java	28 Oct 2003 17:51:26 -0000	1.7
  @@ -57,16 +57,11 @@
   
   import org.apache.xmlbeans.XmlOptions;
   
  -import java.util.Map;
   import java.util.ArrayList;
   import java.util.List;
   import java.util.Iterator;
  -import java.util.Collection;
  -import java.util.Collections;
   import java.io.IOException;
   
  -import com.sun.tools.javac.v8.util.Pair;
  -
   
   /**
    * Represents a BindingLoader whose contents are loaded from a
  @@ -74,7 +69,6 @@
    */
   public class BindingFile extends BaseBindingLoader
   {
  -
       /**
        * This constructor is used when making a new one out of the blue.
        */
  @@ -106,7 +100,7 @@
                   doc.getBindingConfig().getBindings().getBindingTypeArray();
           for (int i = 0; i < btNodes.length; i++)
           {
  -            BindingType next = BindingType.loadFromBindingTypeNode(this, btNodes[i]);
  +            BindingType next = BindingType.loadFromBindingTypeNode(btNodes[i]);
               addBindingType(next, false, false);
           }
           org.apache.xmlbeans.x2003.x09.bindingConfig.Mapping[] mNodes =
  @@ -115,7 +109,15 @@
           {
               JavaName jName = JavaName.forString(mNodes[i].getJavatype());
               XmlName xName = XmlName.forString(mNodes[i].getXmlcomponent());
  -            xmlFromJava.put(jName, pair(jName, xName));
  +            addTypeFor(jName, BindingTypeName.forPair(jName, xName));
  +        }
  +
  +        mNodes = doc.getBindingConfig().getJavaToElement().getMappingArray();
  +        for (int i = 0; i < mNodes.length; i++)
  +        {
  +            JavaName jName = JavaName.forString(mNodes[i].getJavatype());
  +            XmlName xName = XmlName.forString(mNodes[i].getXmlcomponent());
  +            addElementFor(jName, BindingTypeName.forPair(jName, xName));
           }
   
           mNodes = doc.getBindingConfig().getXmlToPojo().getMappingArray();
  @@ -123,7 +125,7 @@
           {
               JavaName jName = JavaName.forString(mNodes[i].getJavatype());
               XmlName xName = XmlName.forString(mNodes[i].getXmlcomponent());
  -            javaFromXmlPojo.put(xName, pair(jName, xName));
  +            addPojoFor(xName, BindingTypeName.forPair(jName, xName));
           }
   
           mNodes = doc.getBindingConfig().getXmlToXmlobj().getMappingArray();
  @@ -131,7 +133,7 @@
           {
               JavaName jName = JavaName.forString(mNodes[i].getJavatype());
               XmlName xName = XmlName.forString(mNodes[i].getXmlcomponent());
  -            javaFromXmlObj.put(xName, pair(jName, xName));
  +            addXmlObjectFor(xName, BindingTypeName.forPair(jName, xName));
           }
       }
   
  @@ -157,12 +159,13 @@
   
           // make tables
           org.apache.xmlbeans.x2003.x09.bindingConfig.BindingTable btabNode = bcNode.addNewBindings();
  -        org.apache.xmlbeans.x2003.x09.bindingConfig.MappingTable jtabNode = bcNode.addNewJavaToXml();
  +        org.apache.xmlbeans.x2003.x09.bindingConfig.MappingTable typetabNode = bcNode.addNewJavaToXml();
  +        org.apache.xmlbeans.x2003.x09.bindingConfig.MappingTable elementtabNode = bcNode.addNewJavaToElement();
           org.apache.xmlbeans.x2003.x09.bindingConfig.MappingTable pojotabNode = bcNode.addNewXmlToPojo();
           org.apache.xmlbeans.x2003.x09.bindingConfig.MappingTable xotabNode = bcNode.addNewXmlToXmlobj();
   
           // fill em in: binding types (delegate to BindingType.write)
  -        for (Iterator i = bindingTypes.values().iterator(); i.hasNext(); )
  +        for (Iterator i = bindingTypes().iterator(); i.hasNext(); )
           {
               BindingType bType = (BindingType)i.next();
               org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType btNode = btabNode.addNewBindingType();
  @@ -170,75 +173,62 @@
           }
   
           // from-java mappings
  -        for (Iterator i = xmlFromJava.entrySet().iterator(); i.hasNext(); )
  +        for (Iterator i = typeMappedJavaTypes().iterator(); i.hasNext(); )
           {
  -            Map.Entry entry = (Map.Entry)i.next();
  -            JavaName jName = (JavaName)entry.getKey();
  -            NamePair pair = (NamePair)entry.getValue();
  -            XmlName xName = pair.getXmlName();
  -            org.apache.xmlbeans.x2003.x09.bindingConfig.Mapping mNode = jtabNode.addNewMapping();
  +            JavaName jName = (JavaName)i.next();
  +            BindingTypeName pair = lookupTypeFor(jName);
  +            org.apache.xmlbeans.x2003.x09.bindingConfig.Mapping mNode = typetabNode.addNewMapping();
               mNode.setJavatype(jName.toString());
  -            mNode.setXmlcomponent(xName.toString());
  +            mNode.setXmlcomponent(pair.getXmlName().toString());
  +        }
  +
  +        // from-java mappings
  +        for (Iterator i = elementMappedJavaTypes().iterator(); i.hasNext(); )
  +        {
  +            JavaName jName = (JavaName)i.next();
  +            BindingTypeName pair = lookupElementFor(jName);
  +            org.apache.xmlbeans.x2003.x09.bindingConfig.Mapping mNode = elementtabNode.addNewMapping();
  +            mNode.setJavatype(jName.toString());
  +            mNode.setXmlcomponent(pair.getXmlName().toString());
           }
   
           // to-pojo
  -        for (Iterator i = javaFromXmlPojo.entrySet().iterator(); i.hasNext(); )
  +        for (Iterator i = pojoMappedXmlTypes().iterator(); i.hasNext(); )
           {
  -            Map.Entry entry = (Map.Entry)i.next();
  -            JavaName jName = (JavaName)entry.getValue();
  -            XmlName xName = (XmlName)entry.getKey();
  +            XmlName xName = (XmlName)i.next();
  +            BindingTypeName pair = lookupPojoFor(xName);
               org.apache.xmlbeans.x2003.x09.bindingConfig.Mapping mNode = pojotabNode.addNewMapping();
  -            mNode.setJavatype(jName.toString());
  +            mNode.setJavatype(pair.getJavaName().toString());
               mNode.setXmlcomponent(xName.toString());
           }
   
           // to-xmlobj
  -        for (Iterator i = javaFromXmlObj.entrySet().iterator(); i.hasNext(); )
  +        for (Iterator i = xmlObjectMappedXmlTypes().iterator(); i.hasNext(); )
           {
  -            Map.Entry entry = (Map.Entry)i.next();
  -            JavaName jName = (JavaName)entry.getValue();
  -            XmlName xName = (XmlName)entry.getKey();
  +            XmlName xName = (XmlName)i.next();
  +            BindingTypeName pair = lookupXmlObjectFor(xName);
               org.apache.xmlbeans.x2003.x09.bindingConfig.Mapping mNode = xotabNode.addNewMapping();
  -            mNode.setJavatype(jName.toString());
  +            mNode.setJavatype(pair.getJavaName().toString());
               mNode.setXmlcomponent(xName.toString());
           }
       }
   
       public void addBindingType(BindingType bType, boolean fromJavaDefault, boolean fromXmlDefault)
       {
  -        bindingTypes.put(BaseBindingLoader.pair(bType.getJavaName(), bType.getXmlName()), bType);
  -        if (fromJavaDefault)
  +        addBindingType(bType);
  +        if (fromXmlDefault)
           {
  -            if (bType.isXmlObject())
  -                javaFromXmlObj.put(bType.getXmlName(), bType.getJavaName());
  +            if (bType.getName().getJavaName().isXmlObject())
  +                addXmlObjectFor(bType.getName().getXmlName(), bType.getName());
               else
  -                javaFromXmlPojo.put(bType.getXmlName(), bType.getJavaName());
  +                addPojoFor(bType.getName().getXmlName(), bType.getName());
           }
  -        if (fromXmlDefault)
  +        if (fromJavaDefault)
           {
  -            xmlFromJava.put(bType.getJavaName(),
  -                            pair(bType.getJavaName(),bType.getXmlName()));
  +            if (bType.getName().getXmlName().getComponentType() == XmlName.ELEMENT)
  +                addElementFor(bType.getName().getJavaName(), bType.getName());
  +            else
  +                addTypeFor(bType.getName().getJavaName(), bType.getName());
           }
       }
  -
  -    public Collection getMappedJavaNames()
  -    {
  -        return Collections.unmodifiableCollection(this.xmlFromJava.keySet());
  -    }
  -
  -    public Collection getPojoMappedXmlNames()
  -    {
  -        return Collections.unmodifiableCollection(this.javaFromXmlPojo.keySet());
  -    }
  -
  -    public Collection getXmlObjectMappedXmlNames()
  -    {
  -        return Collections.unmodifiableCollection(this.javaFromXmlObj.keySet());
  -    }
  -    
  -    public Collection getBindingTypes()
  -    {
  -        return Collections.unmodifiableCollection(bindingTypes.values());
  -    }
  -
   }
  
  
  
  1.2       +6 -4      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingLoader.java
  
  Index: BindingLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BindingLoader.java	10 Oct 2003 20:09:27 -0000	1.1
  +++ BindingLoader.java	28 Oct 2003 17:51:26 -0000	1.2
  @@ -64,11 +64,13 @@
    */
   public interface BindingLoader
   {
  -    BindingType getBindingType(JavaName jName, XmlName xName);
  +    BindingType getBindingType(BindingTypeName btName);
   
  -    BindingType getBindingTypeForXmlPojo(XmlName xName);
  +    BindingTypeName lookupPojoFor(XmlName xName);
   
  -    BindingType getBindingTypeForXmlObj(XmlName xName);
  +    BindingTypeName lookupXmlObjectFor(XmlName xName);
   
  -    BindingType getBindingTypeForJava(JavaName jName);
  +    BindingTypeName lookupTypeFor(JavaName jName);
  +
  +    BindingTypeName lookupElementFor(JavaName jName);
   }
  
  
  
  1.3       +9 -21     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingProperty.java
  
  Index: BindingProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingProperty.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BindingProperty.java	27 Oct 2003 19:17:21 -0000	1.2
  +++ BindingProperty.java	28 Oct 2003 17:51:26 -0000	1.3
  @@ -57,7 +57,6 @@
   package org.apache.xmlbeans.impl.binding.bts;
   
   import org.apache.xmlbeans.SchemaType;
  -import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   
   /**
    * Represents a property.  Every property corresponds to a
  @@ -67,8 +66,7 @@
    */ 
   public abstract class BindingProperty
   {
  -    private JavaName tJava;
  -    protected XmlName tXml;
  +    private BindingTypeName btName;
       private String getter;
       private String setter;
       private String field;
  @@ -90,8 +88,9 @@
        */ 
       protected BindingProperty(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingProperty node)
       {
  -        this.tJava = JavaName.forString(node.getJavatype());
  -        this.tXml = XmlName.forString(node.getXmlcomponent());
  +        this.btName = BindingTypeName.forPair(
  +                        JavaName.forString(node.getJavatype()),
  +                        XmlName.forString(node.getXmlcomponent()));
           this.getter = node.getGetter();
           this.setter = node.getSetter();
           this.field = node.getField();
  @@ -109,8 +108,8 @@
       {
           node = (org.apache.xmlbeans.x2003.x09.bindingConfig.BindingProperty)node.changeType(kinds.typeForClass(this.getClass()));
           
  -        node.setJavatype(tJava.toString());
  -        node.setXmlcomponent(tXml.toString());
  +        node.setJavatype(btName.getJavaName().toString());
  +        node.setXmlcomponent(btName.getXmlName().toString());
           if (getFieldName() != null)
               node.setField(getFieldName());
           if (getGetterName() != null)
  @@ -127,25 +126,14 @@
           return field != null;
       }
       
  -    public BindingType getBindingType(BindingLoader loader)
  +    public BindingTypeName getTypeName()
       {
  -        return loader.getBindingType(tJava, tXml);
  -    }
  -    
  -    public JavaName getJavaTypeName()
  -    {
  -        return tJava;
  -    }
  -    
  -    public XmlName getXmlTypeName()
  -    {
  -        return tXml;
  +        return btName;
       }
       
       public void setBindingType(BindingType bType)
       {
  -        this.tJava = bType.getJavaName();
  -        this.tXml = bType.getXmlName();
  +        btName = bType.getName();
       }
       
       public String getGetterName()
  
  
  
  1.4       +11 -27    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingType.java
  
  Index: BindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingType.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BindingType.java	27 Oct 2003 19:17:21 -0000	1.3
  +++ BindingType.java	28 Oct 2003 17:51:26 -0000	1.4
  @@ -56,7 +56,6 @@
   package org.apache.xmlbeans.impl.binding.bts;
   
   import org.apache.xmlbeans.SchemaType;
  -import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   
   /**
    * Represents a Java+XML component and a rule for getting between
  @@ -64,20 +63,16 @@
    */
   public abstract class BindingType
   {
  -    private JavaName jName;
  -    private XmlName xName;
  -    private boolean isXmlObj;
  +    private final BindingTypeName btName;
   
       /**
        * This kind of constructor is used when making a new one out of the blue.
        *
        * Subclasses should call super(..) when defining constructors that init new BindingTypes.
        */
  -    protected BindingType(JavaName jName, XmlName xName, boolean isXmlObj)
  +    protected BindingType(BindingTypeName btName)
       {
  -        this.jName = jName;
  -        this.xName = xName;
  -        this.isXmlObj = isXmlObj;
  +        this.btName = btName;
       }
   
       /**
  @@ -87,9 +82,9 @@
        */
       protected BindingType(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
       {
  -        this.jName = JavaName.forString(node.getJavatype());
  -        this.xName = XmlName.forString(node.getXmlcomponent());
  -        this.isXmlObj = node.getXmlobj();
  +        this.btName = BindingTypeName.forPair(
  +                JavaName.forString(node.getJavatype()),
  +                XmlName.forString(node.getXmlcomponent()));
       }
   
       /**
  @@ -100,32 +95,21 @@
       protected org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType write(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
       {
           node = (org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType)node.changeType(kinds.typeForClass(this.getClass()));
  -        node.setJavatype(jName.toString());
  -        node.setXmlcomponent(xName.toString());
  -        node.setXmlobj(isXmlObj);
  +        node.setJavatype(btName.getJavaName().toString());
  +        node.setXmlcomponent(btName.getXmlName().toString());
           return node;
       }
   
  -    public final JavaName getJavaName()
  +    public final BindingTypeName getName()
       {
  -        return jName;
  -    }
  -
  -    public final XmlName getXmlName()
  -    {
  -        return xName;
  -    }
  -
  -    public final boolean isXmlObject()
  -    {
  -        return isXmlObj;
  +        return btName;
       }
   
       /* REGISTRY OF SUBCLASSES */
   
       private static final Class[] ctorArgs = new Class[] {org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType.class};
   
  -    public static BindingType loadFromBindingTypeNode(BindingLoader bLoader, org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
  +    public static BindingType loadFromBindingTypeNode(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
       {
           try
           {
  
  
  
  1.4       +21 -17    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BuiltinBindingLoader.java
  
  Index: BuiltinBindingLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BuiltinBindingLoader.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BuiltinBindingLoader.java	16 Oct 2003 00:02:49 -0000	1.3
  +++ BuiltinBindingLoader.java	28 Oct 2003 17:51:26 -0000	1.4
  @@ -58,11 +58,9 @@
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
   
   import javax.xml.namespace.QName;
  -import java.util.Map;
  -import java.util.LinkedHashMap;
   
   /**
  - * 
  + * Represents builtin bindings. 
    */ 
   public class BuiltinBindingLoader extends BaseBindingLoader
   {
  @@ -75,42 +73,48 @@
   
       private static final BuiltinBindingLoader INSTANCE = new BuiltinBindingLoader();
       
  -    private void addMapping(String xmlType, String javaName, boolean pojo, boolean defaultForJava, boolean defaultForXml)
  +    private void addMapping(String xmlType, String javaName, boolean fromJavaDefault, boolean fromXmlDefault)
       {
           XmlName xn = XmlName.forTypeNamed(new QName(xsns, xmlType));
           JavaName jn = JavaName.forString(javaName);
  -        BindingType bt = new BuiltinBindingType(jn, xn, !pojo);
  -        NamePair pair = pair(jn, xn);
  -        bindingTypes.put(pair, bt);
  -        if (defaultForJava)
  -            xmlFromJava.put(jn, pair);
  -        if (defaultForXml)
  +        BindingTypeName btName = BindingTypeName.forPair(jn, xn);
  +        BindingType bType = new BuiltinBindingType(btName);
  +        
  +        addBindingType(bType);
  +        if (fromJavaDefault)
           {
  -            if (pojo)
  -                javaFromXmlPojo.put(xn, pair);
  +            if (bType.getName().getXmlName().getComponentType() == XmlName.ELEMENT)
  +                addElementFor(bType.getName().getJavaName(), bType.getName());
               else
  -                javaFromXmlObj.put(xn, pair);
  +                addTypeFor(bType.getName().getJavaName(), bType.getName());
  +        }
  +        if (fromXmlDefault)
  +        {
  +            if (bType.getName().getJavaName().isXmlObject())
  +                addXmlObjectFor(bType.getName().getXmlName(), bType.getName());
  +            else
  +                addPojoFor(bType.getName().getXmlName(), bType.getName());
           }
       }
       
       private void addPojoTwoWay(String xmlType, String javaName)
       {
  -        addMapping(xmlType, javaName, true, true, true);
  +        addMapping(xmlType, javaName, true, true);
       }
   
       private void addPojoXml(String xmlType, String javaName)
       {
  -        addMapping(xmlType, javaName, true, false, true);
  +        addMapping(xmlType, javaName, false, true);
       }
       
       private void addPojoJava(String xmlType, String javaName)
       {
  -        addMapping(xmlType, javaName, true, true, false);
  +        addMapping(xmlType, javaName, true, false);
       }
       
       private void addPojo(String xmlType, String javaName)
       {
  -        addMapping(xmlType, javaName, true, true, false);
  +        addMapping(xmlType, javaName, true, false);
       }
   
       private BuiltinBindingLoader()
  
  
  
  1.2       +2 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BuiltinBindingType.java
  
  Index: BuiltinBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BuiltinBindingType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BuiltinBindingType.java	10 Oct 2003 20:09:27 -0000	1.1
  +++ BuiltinBindingType.java	28 Oct 2003 17:51:26 -0000	1.2
  @@ -66,8 +66,8 @@
   public class BuiltinBindingType extends BindingType
   {
       // note: only this one constructor; builtin binding types can't be loaded
  -    public BuiltinBindingType(JavaName jName, XmlName xName, boolean isXmlObj)
  +    public BuiltinBindingType(BindingTypeName btName)
       {
  -        super(jName, xName, isXmlObj);
  +        super(btName);
       }
   }
  
  
  
  1.2       +2 -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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ByNameBean.java	10 Oct 2003 20:09:27 -0000	1.1
  +++ ByNameBean.java	28 Oct 2003 17:51:26 -0000	1.2
  @@ -78,9 +78,9 @@
       Map eltProps = new HashMap(); // QName -> prop (elts)
       Map attProps = new HashMap(); // QName -> prop (attrs)
       
  -    public ByNameBean(JavaName jName, XmlName xName, boolean isXmlObj)
  +    public ByNameBean(BindingTypeName btName)
       {
  -        super(jName, xName, isXmlObj);
  +        super(btName);
       }
   
       public ByNameBean(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
  
  
  
  1.3       +30 -3     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JavaName.java
  
  Index: JavaName.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JavaName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaName.java	27 Oct 2003 19:17:21 -0000	1.2
  +++ JavaName.java	28 Oct 2003 17:51:26 -0000	1.3
  @@ -63,11 +63,17 @@
    * "int[]"
    * "java.lang.String"
    * "com.myco.MyClass$MyInnerClass$InnerInnerClass[][]"
  + * 
  + * The classname is preceded by an "x=" if it is an XmlObject
  + * subclass, i.e., if it's an XmlBeans-style class, for example:
  + * 
  + * "x=org.apache.xmlbeans.XmlInt"
    */
   public final class JavaName
   {
       private final String className;
       private final String arrayString;
  +    private final boolean isXmlObject;
   
       /**
        * Returns a JavaName object for a fully-qualified class name.
  @@ -92,7 +98,7 @@
       {
           // efficiency later
           String arrayBrackets = "";
  -        while (depth > 0)
  +        while (depth-- > 0)
               arrayBrackets += "[]";
           return forString(itemType.toString() + arrayBrackets);
       }
  @@ -105,6 +111,16 @@
           if (className == null)
               throw new IllegalArgumentException();
           
  +        if (className.startsWith("x="))
  +        {
  +            this.isXmlObject = true;
  +            className = className.substring(2);
  +        }
  +        else
  +        {
  +            this.isXmlObject = false;
  +        }
  +        
           int arrayDepth = 0;
           for (int i = className.length() - 2; i >= 0; i -= 2)
           {
  @@ -121,10 +137,20 @@
        */ 
       public String toString()
       {
  +        if (isXmlObject)
  +            return "x=" + className + arrayString;
           return className + arrayString;
       }
       
       /**
  +     * True for classnames that are XmlObjects.
  +     */ 
  +    public boolean isXmlObject()
  +    {
  +        return isXmlObject;
  +    }
  +    
  +    /**
        * Returns the array depth, 0 for non-arrays, 1 for [], 2 for [][], etc.
        */ 
       public int getArrayDepth()
  @@ -193,7 +219,8 @@
           if (!(o instanceof JavaName)) return false;
   
           final JavaName javaName = (JavaName) o;
  -
  +        
  +        if (isXmlObject != javaName.isXmlObject) return false;
           if (!className.equals(javaName.className)) return false;
           if (!arrayString.equals(javaName.arrayString)) return false;
   
  @@ -202,6 +229,6 @@
   
       public int hashCode()
       {
  -        return className.hashCode() + arrayString.length();
  +        return className.hashCode() + arrayString.length() + (isXmlObject ? 1 : 0);
       }
   }
  
  
  
  1.2       +2 -3      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JaxbBean.java
  
  Index: JaxbBean.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JaxbBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JaxbBean.java	10 Oct 2003 20:09:27 -0000	1.1
  +++ JaxbBean.java	28 Oct 2003 17:51:26 -0000	1.2
  @@ -57,7 +57,6 @@
   
   import org.apache.xmlbeans.impl.binding.bts.BindingProperty;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
  -import org.apache.xmlbeans.impl.binding.bts.JavaName;
   
   import javax.xml.namespace.QName;
   import java.util.List;
  @@ -79,9 +78,9 @@
       Map eltProps = new LinkedHashMap(); // QName -> prop (elts)
       Map attProps = new LinkedHashMap(); // QName -> prop (attrs)
       
  -    public JaxbBean(JavaName jName, XmlName xName)
  +    public JaxbBean(BindingTypeName btName)
       {
  -        super(jName, xName, false);
  +        super(btName);
       }
   
       public JaxbBean(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
  
  
  
  1.2       +1 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ParticleProperty.java
  
  Index: ParticleProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ParticleProperty.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ParticleProperty.java	10 Oct 2003 20:09:27 -0000	1.1
  +++ ParticleProperty.java	28 Oct 2003 17:51:26 -0000	1.2
  @@ -74,6 +74,6 @@
       
       public XmlName getXmlName()
       {
  -        return this.tXml;
  +        return getTypeName().getXmlName();
       }
   }
  
  
  
  1.2       +23 -11    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/PathBindingLoader.java
  
  Index: PathBindingLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/PathBindingLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PathBindingLoader.java	10 Oct 2003 20:09:27 -0000	1.1
  +++ PathBindingLoader.java	28 Oct 2003 17:51:26 -0000	1.2
  @@ -115,48 +115,60 @@
           loaderPath = Collections.unmodifiableList(path);
       }
       
  -    public BindingType getBindingType(JavaName jName, XmlName xName)
  +    public BindingType getBindingType(BindingTypeName btName)
       {
           BindingType result = null;
           for (Iterator i = loaderPath.iterator(); i.hasNext(); )
           {
  -            result = ((BindingLoader)i.next()).getBindingType(jName, xName);
  +            result = ((BindingLoader)i.next()).getBindingType(btName);
               if (result != null)
                   return result;
           }
           return null;
       }
   
  -    public BindingType getBindingTypeForXmlPojo(XmlName xName)
  +    public BindingTypeName lookupPojoFor(XmlName xName)
       {
  -        BindingType result = null;
  +        BindingTypeName result = null;
           for (Iterator i = loaderPath.iterator(); i.hasNext(); )
           {
  -            result = ((BindingLoader)i.next()).getBindingTypeForXmlPojo(xName);
  +            result = ((BindingLoader)i.next()).lookupPojoFor(xName);
               if (result != null)
                   return result;
           }
           return null;
       }
   
  -    public BindingType getBindingTypeForXmlObj(XmlName xName)
  +    public BindingTypeName lookupXmlObjectFor(XmlName xName)
       {
  -        BindingType result = null;
  +        BindingTypeName result = null;
           for (Iterator i = loaderPath.iterator(); i.hasNext(); )
           {
  -            result = ((BindingLoader)i.next()).getBindingTypeForXmlObj(xName);
  +            result = ((BindingLoader)i.next()).lookupXmlObjectFor(xName);
               if (result != null)
                   return result;
           }
           return null;
       }
   
  -    public BindingType getBindingTypeForJava(JavaName jName)
  +    public BindingTypeName lookupTypeFor(JavaName jName)
       {
  -        BindingType result = null;
  +        BindingTypeName result = null;
  +        for (Iterator i = loaderPath.iterator(); i.hasNext(); )
  +        {
  +            result = ((BindingLoader)i.next()).lookupTypeFor(jName);
  +            if (result != null)
  +                return result;
  +        }
  +        return null;
  +    }
  +
  +    public BindingTypeName lookupElementFor(JavaName jName)
  +    {
  +        BindingTypeName result = null;
           for (Iterator i = loaderPath.iterator(); i.hasNext(); )
           {
  -            result = ((BindingLoader)i.next()).getBindingTypeForJava(jName);
  +            result = ((BindingLoader)i.next()).lookupElementFor(jName);
               if (result != null)
                   return result;
           }
  
  
  
  1.2       +4 -6      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/SimpleBindingType.java
  
  Index: SimpleBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/SimpleBindingType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleBindingType.java	10 Oct 2003 20:09:27 -0000	1.1
  +++ SimpleBindingType.java	28 Oct 2003 17:51:26 -0000	1.2
  @@ -55,9 +55,7 @@
   */
   package org.apache.xmlbeans.impl.binding.bts;
   
  -import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
  -import org.apache.xmlbeans.impl.binding.bts.JavaName;
   
   /**
    * A binding of a simple user-defined type that operates by
  @@ -65,9 +63,9 @@
    */ 
   public class SimpleBindingType extends BindingType
   {
  -    public SimpleBindingType(JavaName jName, XmlName xName, boolean isXmlObj)
  +    public SimpleBindingType(BindingTypeName btName)
       {
  -        super(jName, xName, isXmlObj);
  +        super(btName);
       }
   
       public SimpleBindingType(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
  @@ -99,8 +97,8 @@
       
       // question: do we want an "as if Java type" as well?
       
  -    public BindingType getAsIfBindingType(BindingLoader loader)
  +    public BindingTypeName getAsIfBindingTypeName()
       {
  -        return loader.getBindingType(getJavaName(), asIfXmlType);
  +        return BindingTypeName.forPair(getName().getJavaName(), asIfXmlType);
       }
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingTypeName.java
  
  Index: BindingTypeName.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.binding.bts;
  
  public final class BindingTypeName
  {
      private final JavaName jName;
      private final XmlName xName;
      
      public static BindingTypeName forPair(JavaName jName, XmlName xName)
      {
          return new BindingTypeName(jName, xName);
      }
  
      private BindingTypeName(JavaName jName, XmlName xName)
      {
          this.jName = jName;
          this.xName = xName;
      }
  
      public JavaName getJavaName()
      {
          return jName;
      }
  
      public XmlName getXmlName()
      {
          return xName;
      }
      
      public boolean equals(Object o)
      {
          if (this == o) return true;
          if (!(o instanceof BindingTypeName)) return false;
  
          final BindingTypeName bindingTypeName = (BindingTypeName) o;
  
          if (!jName.equals(bindingTypeName.jName)) return false;
          if (!xName.equals(bindingTypeName.xName)) return false;
  
          return true;
      }
  
      public int hashCode()
      {
          int result;
          result = jName.hashCode();
          result = 29 * result + xName.hashCode();
          return result;
      }
  }
  
  
  
  1.2       +43 -19    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JAXRPCSchemaBinder.java
  
  Index: JAXRPCSchemaBinder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JAXRPCSchemaBinder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JAXRPCSchemaBinder.java	27 Oct 2003 19:17:21 -0000	1.1
  +++ JAXRPCSchemaBinder.java	28 Oct 2003 17:51:27 -0000	1.2
  @@ -64,6 +64,7 @@
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
   import org.apache.xmlbeans.impl.binding.bts.QNameProperty;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
  +import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.compile.BindingFileGenerator;
   import org.apache.xmlbeans.impl.binding.compile.JavaCodeGenerator;
   import org.apache.xmlbeans.impl.binding.compile.JavaCodePrinter;
  @@ -194,7 +195,7 @@
               }
               else if (sType.isAttributeType())
               {
  -                scratch = new Scratch(sType, XmlName.forGlobalName(XmlName.ATTRIBUTE, sType.getDocumentElementName()), Scratch.ELEMENT);
  +                scratch = new Scratch(sType, XmlName.forGlobalName(XmlName.ATTRIBUTE, sType.getDocumentElementName()), Scratch.ATTRIBUTE);
               }
               else if (isSoapArray(sType))
               {
  @@ -269,6 +270,7 @@
                       Scratch arrayScratch = scratchForXmlName(soapArrayName);
                       resolveJavaName(arrayScratch);
                       scratch.setJavaName(arrayScratch.getJavaName());
  +                    scratch.setAsIf(arrayScratch.getXmlName());
                       return;
                   }
                   
  @@ -289,6 +291,7 @@
                       Scratch contentScratch = scratchForSchemaType(contentType);
                       resolveJavaName(contentScratch);
                       scratch.setJavaName(contentScratch.getJavaName());
  +                    scratch.setAsIf(contentScratch.getXmlName());
                       return;
                   }
                   
  @@ -304,17 +307,22 @@
       {
           assert(scratch.getBindingType() == null);
           
  +        BindingTypeName btName = BindingTypeName.forPair(scratch.getJavaName(), scratch.getXmlName());
  +        
           switch (scratch.getCategory())
           {
               case Scratch.ATOMIC_TYPE:
  -                SimpleBindingType simpleResult = new SimpleBindingType(scratch.getJavaName(), scratch.getXmlName(), false);
  +            case Scratch.ELEMENT:
  +            case Scratch.SOAPARRAY_REF:
  +            case Scratch.ATTRIBUTE:
  +                SimpleBindingType simpleResult = new SimpleBindingType(btName);
                   simpleResult.setAsIfXmlType(scratch.getAsIf());
                   scratch.setBindingType(simpleResult);
  -                bindingFile.addBindingType(simpleResult, false, true);
  +                bindingFile.addBindingType(simpleResult, shouldBeFromJavaDefault(btName), true);
                   break;
                   
               case Scratch.STRUCT_TYPE:
  -                ByNameBean byNameResult = new ByNameBean(scratch.getJavaName(), scratch.getXmlName(), false);
  +                ByNameBean byNameResult = new ByNameBean(btName);
                   scratch.setBindingType(byNameResult);
                   bindingFile.addBindingType(byNameResult, true, true);
                   break;
  @@ -322,20 +330,35 @@
               case Scratch.LITERALARRAY_TYPE:
                   throw new UnsupportedOperationException();
                   
  -            case Scratch.SOAPARRAY_REF:
  -                throw new UnsupportedOperationException();
  -                
               case Scratch.SOAPARRAY:
                   throw new UnsupportedOperationException();
                   
  -            case Scratch.ELEMENT:
  -            case Scratch.ATTRIBUTE:
  -                throw new UnsupportedOperationException();
  -                
               default:
                   throw new IllegalStateException("Unrecognized category");
           }
       }
  +    
  +    /**
  +     * Returns true if the given btName would be the first (unique)
  +     * default java->xml binding to be entered in the java-to-type or
  +     * java-to-element tables.
  +     */ 
  +    private boolean shouldBeFromJavaDefault(BindingTypeName btName)
  +    {
  +        JavaName jName = btName.getJavaName();
  +        XmlName xName = btName.getXmlName();
  +        if (xName.isSchemaType())
  +        {
  +            return (bindingFile.lookupTypeFor(jName) == null &&
  +                    path.lookupTypeFor(jName) == null);
  +        }
  +        if (xName.getComponentType() == XmlName.ELEMENT)
  +        {
  +            return (bindingFile.lookupElementFor(jName) == null &&
  +                    path.lookupElementFor(jName) == null);
  +        }
  +        return false;
  +    }
   
       /**
        * Now we resolve the structural aspects (property names) for each
  @@ -407,7 +430,7 @@
                   boolean isMultiple = isMultiple(props[i]);
                   JavaName collection = null;
                   if (isMultiple)
  -                    collection = JavaName.forArray(bType.getJavaName(), 1);
  +                    collection = JavaName.forArray(bType.getName().getJavaName(), 1);
                   
                   prop = new QNameProperty();
                   prop.setQName(props[i].getName());
  @@ -479,7 +502,7 @@
           }
           
           // case 2: it's in the path
  -        BindingType bType = path.getBindingTypeForXmlPojo(XmlName.forSchemaType(sType));
  +        BindingType bType = path.getBindingType(path.lookupPojoFor(XmlName.forSchemaType(sType)));
           if (!(bType instanceof ByNameBean))
           {
               return null;
  @@ -629,10 +652,10 @@
               
               // or if not within this type system, find the base type on the path
               XmlName treatAs = XmlName.forSchemaType(baseType);
  -            BindingType basedOnBinding = path.getBindingTypeForXmlPojo(treatAs);
  +            BindingType basedOnBinding = path.getBindingType(path.lookupPojoFor(treatAs));
               if (basedOnBinding != null)
               {
  -                scratch.setJavaName(basedOnBinding.getJavaName());
  +                scratch.setJavaName(basedOnBinding.getName().getJavaName());
                   scratch.setAsIf(treatAs);
                   return;
               }
  @@ -655,7 +678,7 @@
           Scratch scratch = scratchForSchemaType(sType);
           if (scratch != null)
               return scratch.getBindingType();
  -        return path.getBindingTypeForXmlPojo(XmlName.forSchemaType(sType));
  +        return path.getBindingType(path.lookupPojoFor(XmlName.forSchemaType(sType)));
       }
   
       /**
  @@ -885,6 +908,7 @@
   
           public Object next()
           {
  +            // todo: need to strip off x= from xmlobject name
               String result = next.getJavaName().toString();
               next = nextStructure();
               return result;
  @@ -966,7 +990,7 @@
               String baseJavaname = null;
               if (baseType != null)
               {
  -                baseJavaname = baseType.getJavaName().toString();
  +                baseJavaname = baseType.getName().getJavaName().toString();
                   if (baseJavaname.equals("java.lang.Object"))
                       baseJavaname = null;
               }
  @@ -992,7 +1016,7 @@
               for (Iterator i = props.iterator(); i.hasNext(); )
               {
                   QNameProperty prop = (QNameProperty)i.next();
  -                JavaName jType = prop.getJavaTypeName();
  +                JavaName jType = prop.getTypeName().getJavaName();
                   if (prop.getCollectionClass() != null)
                       jType = prop.getCollectionClass();
                   
  @@ -1003,7 +1027,7 @@
               for (Iterator i = props.iterator(); i.hasNext(); )
               {
                   QNameProperty prop = (QNameProperty)i.next();
  -                JavaName jType = prop.getJavaTypeName();
  +                JavaName jType = prop.getTypeName().getJavaName();
                   if (prop.getCollectionClass() != null)
                       jType = prop.getCollectionClass();
                   String fieldName = (String)fieldNames.get(prop);
  
  
  
  1.3       +4 -6      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Java2Schema.java	22 Oct 2003 19:03:09 -0000	1.2
  +++ Java2Schema.java	28 Oct 2003 17:51:27 -0000	1.3
  @@ -124,7 +124,7 @@
     }
   
     private BindingType getBindingTypeFor(JClass clazz) {
  -    BindingType out = mLoader.getBindingTypeForJava(getJavaName(clazz));
  +    BindingType out = mLoader.getBindingType(mLoader.lookupTypeFor(getJavaName(clazz)));
       if (out == null) {
         out = createBindingTypeFor(clazz);
       }
  @@ -142,9 +142,7 @@
       QName qname = new QName(tns,xsdName);
       xsdType.setName(xsdName);
       // create a binding type
  -    ByNameBean bindType = new ByNameBean(getJavaName(clazz),
  -                                         XmlName.forTypeNamed(qname),
  -                                         isXmlObj(clazz));
  +    ByNameBean bindType = new ByNameBean(BindingTypeName.forPair(getJavaName(clazz), XmlName.forTypeNamed(qname)));
       mBindingFile.addBindingType(bindType,true,true);
       // run through the class' properties to populate the binding and xsdtypes
       //FIXME this is going to have to change to take inheritance into account
  @@ -202,8 +200,8 @@
   
     private QName getBuiltinTypeNameFor(JClass clazz) {
       BindingType bt =
  -            mLoader.getBindingTypeForJava(JavaName.forString(clazz.getQualifiedName()));
  -    if (bt != null) return bt.getXmlName().getQName();
  +            mLoader.getBindingType(mLoader.lookupTypeFor(JavaName.forString(clazz.getQualifiedName())));
  +    if (bt != null) return bt.getName().getXmlName().getQName();
       System.out.println("no type found for "+clazz.getQualifiedName());
       return null; //FIXME
     }
  
  
  
  1.4       +1 -0      xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd
  
  Index: binding-config.xsd
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- binding-config.xsd	22 Oct 2003 02:32:44 -0000	1.3
  +++ binding-config.xsd	28 Oct 2003 17:51:27 -0000	1.4
  @@ -11,6 +11,7 @@
           <xs:element name="xml-to-pojo" type="tns:mapping-table"/>
           <xs:element name="xml-to-xmlobj" type="tns:mapping-table"/>
           <xs:element name="java-to-xml" type="tns:mapping-table"/>
  +        <xs:element name="java-to-element" type="tns:mapping-table"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
  
  
  
  1.3       +2 -2      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextFactory.java
  
  Index: BindingContextFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BindingContextFactory.java	23 Oct 2003 23:49:03 -0000	1.2
  +++ BindingContextFactory.java	28 Oct 2003 17:51:27 -0000	1.3
  @@ -115,7 +115,7 @@
       {
           RuntimeBindingTypeTable tbl = new RuntimeBindingTypeTable();
   
  -        for (Iterator itr = bf.getBindingTypes().iterator(); itr.hasNext();) {
  +        for (Iterator itr = bf.bindingTypes().iterator(); itr.hasNext();) {
               BindingType type = (BindingType)itr.next();
   
               TypeUnmarshaller um = createTypeUnmarshaller(type, loader, tbl);
  @@ -151,7 +151,7 @@
   
           if (um == null) {
               //let's try using the as if type
  -            BindingType asif = stype.getAsIfBindingType(loader);
  +            BindingType asif = loader.getBindingType(stype.getAsIfBindingTypeName());
               if (asif == null) {
                   throw new AssertionError("unable to get asif type for " + stype);
               }
  
  
  
  1.2       +5 -5      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameRuntimeBindingType.java
  
  Index: ByNameRuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameRuntimeBindingType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ByNameRuntimeBindingType.java	23 Oct 2003 23:49:03 -0000	1.1
  +++ ByNameRuntimeBindingType.java	28 Oct 2003 17:51:27 -0000	1.2
  @@ -84,7 +84,7 @@
               javaClass = getJavaClass(btype, getClass().getClassLoader());
           }
           catch (ClassNotFoundException e) {
  -            final String msg = "failed to load " + btype.getJavaName();
  +            final String msg = "failed to load " + btype.getName().getJavaName();
               throw (RuntimeException)(new RuntimeException(msg).initCause(e));
           }
   
  @@ -111,7 +111,7 @@
       private static Class getJavaClass(BindingType btype, ClassLoader backup)
           throws ClassNotFoundException
       {
  -        final JavaName javaName = btype.getJavaName();
  +        final JavaName javaName = btype.getName().getJavaName();
           String jclass = javaName.toString();
           return ClassLoadingUtils.loadClass(jclass, backup);
       }
  @@ -172,12 +172,12 @@
           {
               this.bindingProperty = prop;
               this.unmarshaller = lookupUnmarshaller(prop, typeTable, loader);
  -            final BindingType bindingType = prop.getBindingType(loader);
  +            final BindingType bindingType = loader.getBindingType(prop.getTypeName());
               try {
                   this.propertyClass = getJavaClass(bindingType, getClass().getClassLoader());
               }
               catch (ClassNotFoundException e) {
  -                final String msg = "error loading " + bindingType.getJavaName();
  +                final String msg = "error loading " + bindingType.getName().getJavaName();
                   throw (RuntimeException)(new RuntimeException(msg).initCause(e));
               }
   
  @@ -191,7 +191,7 @@
                                                       BindingLoader bindingLoader)
           {
               final BindingType bindingType =
  -                prop.getBindingType(bindingLoader);
  +                bindingLoader.getBindingType(prop.getTypeName());
               TypeUnmarshaller um = typeTable.getTypeUnmarshaller(bindingType);
               if (um == null) {
                   throw new AssertionError("failed to get unmarshaller for " + prop);
  
  
  
  1.3       +2 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingTypeTable.java
  
  Index: RuntimeBindingTypeTable.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingTypeTable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RuntimeBindingTypeTable.java	23 Oct 2003 23:49:03 -0000	1.2
  +++ RuntimeBindingTypeTable.java	28 Oct 2003 17:51:27 -0000	1.3
  @@ -61,6 +61,7 @@
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.JavaName;
   import org.apache.xmlbeans.impl.binding.bts.XmlName;
  +import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   
   import javax.xml.namespace.QName;
   import java.util.Collections;
  @@ -159,7 +160,7 @@
           QName xml_type = new QName(XSD_NS, xsdType);
           JavaName jName = JavaName.forString(javaType);
           XmlName xName = XmlName.forTypeNamed(xml_type);
  -        BindingType btype = bindingLoader.getBindingType(jName, xName);
  +        BindingType btype = bindingLoader.getBindingType(BindingTypeName.forPair(jName, xName));
           if (btype == null) {
               throw new AssertionError("failed to find builtin for java:" + jName +
                                        " - xsd:" + xName);
  
  
  
  1.2       +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalContext.java
  
  Index: UnmarshalContext.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnmarshalContext.java	23 Oct 2003 23:49:03 -0000	1.1
  +++ UnmarshalContext.java	28 Oct 2003 17:51:27 -0000	1.2
  @@ -110,7 +110,7 @@
       {
           XmlName xname = XmlName.forTypeNamed(xsi_type);
           BindingType binding_type =
  -            bindingLoader.getBindingTypeForXmlPojo(xname);
  +            bindingLoader.getBindingType(bindingLoader.lookupPojoFor(xname));
           if (binding_type == null) {
               String msg = "unable to locate binding type for " + xsi_type;
               throw new XmlRuntimeException(msg);
  
  
  
  1.2       +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshallerImpl.java
  
  Index: UnmarshallerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshallerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnmarshallerImpl.java	23 Oct 2003 23:49:03 -0000	1.1
  +++ UnmarshallerImpl.java	28 Oct 2003 17:51:27 -0000	1.2
  @@ -190,7 +190,7 @@
           XmlName type_name = XmlName.forTypeNamed(xsi_type);
   
           BindingType bt =
  -            bindingLoader.getBindingTypeForXmlPojo(type_name);
  +            bindingLoader.getBindingType(bindingLoader.lookupPojoFor(type_name));
   
           if (bt == null) {
               throw new XmlException("failed to load BindingType for XmlName: " +
  
  
  
  1.2       +4 -0      xml-xmlbeans/v2/test/cases/schema/typesonly/typesonly.xsd
  
  Index: typesonly.xsd
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/schema/typesonly/typesonly.xsd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- typesonly.xsd	27 Oct 2003 19:17:22 -0000	1.1
  +++ typesonly.xsd	28 Oct 2003 17:51:27 -0000	1.2
  @@ -19,6 +19,8 @@
           </xs:element>
           <xs:element name="birthday" type="xs:date"/>
         </xs:choice>
  +        
  +      <xs:element minOccurs="0" maxOccurs="unbounded" type="mt:person" name="child"/>
       </xs:sequence>
         
       <xs:attribute name="gender">
  @@ -32,5 +34,7 @@
         
     </xs:complexType>
   
  +  <xs:element name="record" type="mt:person"/>
  +    
   </xs:schema>
   
  
  
  
  1.6       +14 -13    xml-xmlbeans/v2/test/src/drt/drtcases/BindingTests.java
  
  Index: BindingTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/BindingTests.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BindingTests.java	27 Oct 2003 19:17:22 -0000	1.5
  +++ BindingTests.java	28 Oct 2003 17:51:27 -0000	1.6
  @@ -19,6 +19,7 @@
   import org.apache.xmlbeans.impl.binding.bts.QNameProperty;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
   import org.apache.xmlbeans.impl.binding.bts.XmlName;
  +import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.compile.JAXRPCSchemaBinder;
   import org.apache.xmlbeans.impl.binding.compile.SchemaToJavaResult;
   import org.apache.xmlbeans.impl.binding.compile.JavaCodeGenerator;
  @@ -61,13 +62,13 @@
           BindingLoader builtins = BuiltinBindingLoader.getInstance();
   
           // some complex types
  -        ByNameBean bnb = new ByNameBean(JavaName.forString("com.mytest.MyClass"), XmlName.forString("t=my-type@http://www.mytest.com/"), false);
  +        ByNameBean bnb = new ByNameBean(BindingTypeName.forPair(JavaName.forString("com.mytest.MyClass"), XmlName.forString("t=my-type@http://www.mytest.com/")));
           bf.addBindingType(bnb, true, true);
  -        ByNameBean bnb2 = new ByNameBean(JavaName.forString("com.mytest.YourClass"), XmlName.forString("t=your-type@http://www.mytest.com/"), false);
  +        ByNameBean bnb2 = new ByNameBean(BindingTypeName.forPair(JavaName.forString("com.mytest.YourClass"), XmlName.forString("t=your-type@http://www.mytest.com/")));
           bf.addBindingType(bnb2, true, true);
   
           // a custom simple type
  -        SimpleBindingType sbt = new SimpleBindingType(JavaName.forString("java.lang.String"), XmlName.forString("t=custom-string@http://www.mytest.com/"), false);
  +        SimpleBindingType sbt = new SimpleBindingType(BindingTypeName.forPair(JavaName.forString("java.lang.String"), XmlName.forString("t=custom-string@http://www.mytest.com/")));
           bf.addBindingType(sbt, false, true); // note not from-java-default for String
   
   
  @@ -120,9 +121,9 @@
           // now load
           BindingFile bfc = BindingFile.forDoc(doc);
           BindingLoader lc = PathBindingLoader.forPath(new BindingLoader[] {builtins, bfc});
  -        ByNameBean bnbc = (ByNameBean)bfc.getBindingType(JavaName.forString("com.mytest.MyClass"), XmlName.forString("t=my-type@http://www.mytest.com/"));
  -        ByNameBean bnb2c = (ByNameBean)bfc.getBindingType(JavaName.forString("com.mytest.YourClass"), XmlName.forString("t=your-type@http://www.mytest.com/"));
  -        SimpleBindingType sbtc = (SimpleBindingType)bfc.getBindingType(JavaName.forString("java.lang.String"), XmlName.forString("t=custom-string@http://www.mytest.com/"));
  +        ByNameBean bnbc = (ByNameBean)bfc.getBindingType(BindingTypeName.forPair(JavaName.forString("com.mytest.MyClass"), XmlName.forString("t=my-type@http://www.mytest.com/")));
  +        ByNameBean bnb2c = (ByNameBean)bfc.getBindingType(BindingTypeName.forPair(JavaName.forString("com.mytest.YourClass"), XmlName.forString("t=your-type@http://www.mytest.com/")));
  +        SimpleBindingType sbtc = (SimpleBindingType)bfc.getBindingType(BindingTypeName.forPair(JavaName.forString("java.lang.String"), XmlName.forString("t=custom-string@http://www.mytest.com/")));
   
           // check loading xsd:float
           {
  @@ -131,7 +132,7 @@
               XmlName xns = XmlName.forString("t=float@http://www.w3.org/2001/XMLSchema");
               Assert.assertEquals(xn, xns);
               Assert.assertEquals(xn.hashCode(), xns.hashCode());
  -            BindingType btype = lc.getBindingTypeForXmlPojo(xn);
  +            BindingType btype = lc.getBindingType(lc.lookupPojoFor(xn));
               Assert.assertNotNull(btype);
           }
   
  @@ -142,7 +143,7 @@
               XmlName xns = XmlName.forString("t=string@http://www.w3.org/2001/XMLSchema");
               Assert.assertEquals(xn, xns);
               Assert.assertEquals(xn.hashCode(), xns.hashCode());
  -            BindingType btype = lc.getBindingTypeForXmlPojo(xn);
  +            BindingType btype = lc.getBindingType(lc.lookupPojoFor(xn));
               Assert.assertNotNull(btype);
           }
   
  @@ -150,28 +151,28 @@
           prop = bnbc.getPropertyForElement(new QName("http://www.mytest.com/", "myelt"));
           Assert.assertEquals("setMyelt", prop.getSetterName());
           Assert.assertEquals("getMyelt", prop.getGetterName());
  -        Assert.assertEquals(bnb2c, prop.getBindingType(lc));
  +        Assert.assertEquals(bnb2c, lc.getBindingType(prop.getTypeName()));
   
           prop = bnbc.getPropertyForElement(new QName("http://www.mytest.com/", "myelt2"));
           Assert.assertEquals("setMyelt2", prop.getSetterName());
           Assert.assertEquals("getMyelt2", prop.getGetterName());
  -        Assert.assertEquals(bnbc, prop.getBindingType(lc));
  +        Assert.assertEquals(bnbc, lc.getBindingType(prop.getTypeName()));
   
           prop = bnbc.getPropertyForElement(new QName("http://www.mytest.com/", "myatt"));
           Assert.assertEquals("setMyatt", prop.getSetterName());
           Assert.assertEquals("getMyatt", prop.getGetterName());
  -        Assert.assertEquals(sbtc, prop.getBindingType(lc));
  +        Assert.assertEquals(sbtc, lc.getBindingType(prop.getTypeName()));
   
           // check bnb2
           prop = bnb2c.getPropertyForElement(new QName("http://www.mytest.com/", "yourelt"));
           Assert.assertEquals("setYourelt", prop.getSetterName());
           Assert.assertEquals("getYourelt", prop.getGetterName());
  -        Assert.assertEquals(bnb2c, prop.getBindingType(lc));
  +        Assert.assertEquals(bnb2c, lc.getBindingType(prop.getTypeName()));
   
           prop = bnb2c.getPropertyForElement(new QName("http://www.mytest.com/", "yourelt2"));
           Assert.assertEquals("setYourelt2", prop.getSetterName());
           Assert.assertEquals("getYourelt2", prop.getGetterName());
  -        Assert.assertEquals(bnbc, prop.getBindingType(lc));
  +        Assert.assertEquals(bnbc, lc.getBindingType(prop.getTypeName()));
   
           // check sbtc
           Assert.assertEquals(XmlName.forString("t=string@http://www.w3.org/2001/XMLSchema"), sbtc.getAsIfXmlType());
  
  
  

---------------------------------------------------------------------
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