xml-xmlbeans-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases MarshalTests.java
Date Tue, 09 Mar 2004 23:50:54 GMT
zieg        2004/03/09 15:50:54

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        BindingProperty.java BindingType.java
                        BindingTypeVisitor.java
               v2/src/configschema/schema binding-config.xsd
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        ByNameRuntimeBindingType.java
                        ByNameTypeVisitor.java ByNameUnmarshaller.java
                        MarshalResult.java RuntimeBindingType.java
                        RuntimeBindingTypeTable.java
                        RuntimeTypeFactory.java SimpleTypeVisitor.java
                        TypeMarshaller.java
               v2/test/cases/marshal doc.xml example_config.xml
               v2/test/cases/marshal/com/mytest YourClass.java
               v2/test/src/drt/drtcases MarshalTests.java
  Added:       v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        AttributeRuntimeBindingType.java
                        AttributeUnmarshaller.java
                        IntermediateResolver.java
                        SimpleContentBeanMarshaller.java
                        SimpleContentRuntimeBindingType.java
                        SimpleContentTypeVisitor.java
                        SimpleContentUnmarshaller.java
                        SimpleContentVisitor.java
               v2/test/cases/marshal/com/mytest SimpleContentExample.java
  Log:
  implement complexTypes with simple content which involves a serious
  refactoring of the runtime type code (a good thing in the long run).
  
  Update drt tests to test new code, at least somewhat.
  
  Revision  Changes    Path
  1.12      +1 -0      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BindingProperty.java	6 Mar 2004 21:25:25 -0000	1.11
  +++ BindingProperty.java	9 Mar 2004 23:50:53 -0000	1.12
  @@ -196,6 +196,7 @@
   
     static {
       registerClassAndType(QNameProperty.class, org.apache.xml.xmlbeans.bindingConfig.QnameProperty.type);
  +    registerClassAndType(SimpleContentProperty.class, org.apache.xml.xmlbeans.bindingConfig.SimpleContentProperty.type);
       registerClassAndType(ParticleProperty.class, org.apache.xml.xmlbeans.bindingConfig.ParticleProperty.type);
     }
   
  
  
  
  1.14      +1 -0      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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- BindingType.java	6 Mar 2004 01:46:00 -0000	1.13
  +++ BindingType.java	9 Mar 2004 23:50:53 -0000	1.14
  @@ -112,6 +112,7 @@
     static {
       registerClassAndType(JaxbBean.class, org.apache.xml.xmlbeans.bindingConfig.JaxbBean.type);
       registerClassAndType(ByNameBean.class, org.apache.xml.xmlbeans.bindingConfig.ByNameBean.type);
  +    registerClassAndType(SimpleContentBean.class, org.apache.xml.xmlbeans.bindingConfig.SimpleContentBean.type);
       registerClassAndType(WrappedArrayType.class, org.apache.xml.xmlbeans.bindingConfig.WrappedArray.type);
       registerClassAndType(SimpleBindingType.class, org.apache.xml.xmlbeans.bindingConfig.SimpleType.type);
       registerClassAndType(SimpleDocumentBinding.class, org.apache.xml.xmlbeans.bindingConfig.SimpleDocumentBinding.type);
  
  
  
  1.2       +3 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingTypeVisitor.java
  
  Index: BindingTypeVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingTypeVisitor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BindingTypeVisitor.java	6 Mar 2004 01:46:00 -0000	1.1
  +++ BindingTypeVisitor.java	9 Mar 2004 23:50:53 -0000	1.2
  @@ -24,6 +24,9 @@
   
       void visit(ByNameBean byNameBean)
           throws XmlException;
  +  
  +    void visit(SimpleContentBean simpleContentBean)
  +        throws XmlException;
   
       void visit(SimpleBindingType simpleBindingType)
           throws XmlException;
  @@ -33,5 +36,4 @@
   
       void visit(WrappedArrayType wrappedArrayType)
           throws XmlException;
  -
   }
  
  
  
  1.15      +22 -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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- binding-config.xsd	2 Mar 2004 02:54:07 -0000	1.14
  +++ binding-config.xsd	9 Mar 2004 23:50:53 -0000	1.15
  @@ -74,6 +74,18 @@
       </xs:complexContent>
     </xs:complexType>
   
  +  <xs:complexType name="simple-content-bean">
  +    <xs:complexContent>
  +      <xs:extension base="tns:binding-type">
  +        <xs:sequence>
  +          <xs:element name="simple-content-property" type="tns:simple-content-property"/>
  +          <xs:element name="attribute-property" type="tns:qname-property"
  +            minOccurs="0" maxOccurs="unbounded"/>
  +        </xs:sequence>
  +      </xs:extension>
  +    </xs:complexContent>
  +  </xs:complexType>
  +
     <xs:complexType name="wrapped-array">
       <xs:complexContent>
         <xs:extension base="tns:binding-type">
  @@ -112,6 +124,16 @@
         </xs:choice>
         <xs:element name="collection" type="tns:java-class-name" minOccurs="0"/>
       </xs:sequence>
  +  </xs:complexType>
  +
  +  <!--  type must be a simple or builtin type-->
  +  <xs:complexType name="simple-content-property">
  +    <xs:complexContent>
  +      <xs:extension base="tns:binding-property">
  +        <xs:sequence>
  +        </xs:sequence>
  +      </xs:extension>
  +    </xs:complexContent>
     </xs:complexType>
   
     <xs:complexType name="qname-property">
  
  
  
  1.35      +61 -435   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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ByNameRuntimeBindingType.java	2 Mar 2004 04:23:24 -0000	1.34
  +++ ByNameRuntimeBindingType.java	9 Mar 2004 23:50:53 -0000	1.35
  @@ -16,42 +16,29 @@
   package org.apache.xmlbeans.impl.marshal;
   
   import org.apache.xmlbeans.XmlException;
  -import org.apache.xmlbeans.XmlRuntimeException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  -import org.apache.xmlbeans.impl.binding.bts.BindingType;
  -import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
  -import org.apache.xmlbeans.impl.binding.bts.JavaTypeName;
  -import org.apache.xmlbeans.impl.binding.bts.MethodName;
   import org.apache.xmlbeans.impl.binding.bts.QNameProperty;
   import org.apache.xmlbeans.impl.marshal.util.collections.Accumulator;
   import org.apache.xmlbeans.impl.marshal.util.collections.AccumulatorFactory;
  +import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils;
   
   import javax.xml.namespace.QName;
  -import javax.xml.stream.XMLStreamException;
  -import javax.xml.stream.XMLStreamReader;
  -import java.io.StringReader;
  -import java.lang.reflect.InvocationTargetException;
  -import java.lang.reflect.Method;
   import java.util.Collection;
   import java.util.Iterator;
   
   
   final class ByNameRuntimeBindingType
  -    extends RuntimeBindingType
  +    extends AttributeRuntimeBindingType
   {
  -    private final ByNameBean byNameBean;
  -    private final Property[] attributeProperties;
  -    private final Property[] elementProperties;
  +    private final ElementQNameProperty[] elementProperties;
       private final boolean hasMulti;  //has any multi properties
  -    private final boolean hasDefaultAttributes;  //has any attributes with defaults
   
       //DO NOT CALL THIS CONSTRUCTOR, use the RuntimeTypeFactory
       ByNameRuntimeBindingType(ByNameBean btype)
           throws XmlException
       {
           super(btype);
  -        byNameBean = btype;
   
           final Class java_type = getJavaType();
           if (java_type.isPrimitive() || java_type.isArray()) {
  @@ -61,53 +48,52 @@
           }
   
           int elem_prop_cnt = 0;
  -        int att_prop_cnt = 0;
           boolean has_multi = false;
  -        boolean has_attribute_defaults = false;
  -        final Collection type_props = btype.getProperties();
  +        final Collection type_props = getQNameProperties();
           for (Iterator itr = type_props.iterator(); itr.hasNext();) {
  -            QNameProperty p = (QNameProperty)itr.next();
  +            QNameProperty p =
  +                (QNameProperty)itr.next();
  +            if (p.isAttribute()) continue;
               if (p.isMultiple()) has_multi = true;
  -            if (p.isAttribute()) {
  -                att_prop_cnt++;
  -                if (p.getDefault() != null) {
  -                    has_attribute_defaults = true;
  -                }
  -            } else {
  -                elem_prop_cnt++;
  -            }
  +            elem_prop_cnt++;
           }
   
  -        attributeProperties = new Property[att_prop_cnt];
  -        elementProperties = new Property[elem_prop_cnt];
  +        elementProperties = new ElementQNameProperty[elem_prop_cnt];
           hasMulti = has_multi;
  -        hasDefaultAttributes = has_attribute_defaults;
       }
   
  -    //prepare internal data structures for use
  -    public void initialize(RuntimeBindingTypeTable typeTable,
  -                           BindingLoader loader,
  -                           RuntimeTypeFactory rttFactory)
  -        throws XmlException
  +
  +    public Object getObjectFromIntermediate(Object inter)
       {
  -        int att_idx = 0;
  -        int elem_idx = 0;
  -        for (Iterator itr = byNameBean.getProperties().iterator(); itr.hasNext();) {
  -            QNameProperty bprop = (QNameProperty)itr.next();
  -            final boolean is_att = bprop.isAttribute();
  +        if (hasMulti()) {
  +            UResultHolder res = (UResultHolder)inter;
  +            return res.getValue();
  +        } else {
  +            return inter;
  +        }
  +    }
   
  -            final Property prop = new Property(is_att ? att_idx : elem_idx,
  -                                               getJavaType(), hasMulti, bprop,
  -                                               typeTable, loader, rttFactory);
  -            if (is_att)
  -                attributeProperties[att_idx++] = prop;
  -            else
  -                elementProperties[elem_idx++] = prop;
   
  -        }
  +    protected Collection getQNameProperties()
  +    {
  +        ByNameBean narrowed_type = (ByNameBean)getBindingType();
  +        return narrowed_type.getProperties();
       }
   
  -    Object createIntermediary(UnmarshalResult context)
  +
  +    protected void initElementProperty(QNameProperty prop,
  +                                       int elem_idx,
  +                                       RuntimeBindingTypeTable typeTable,
  +                                       BindingLoader loader,
  +                                       RuntimeTypeFactory rttFactory)
  +        throws XmlException
  +    {
  +        elementProperties[elem_idx] =
  +            new ElementQNameProperty(elem_idx, getJavaType(), hasMulti(), prop,
  +                                     this, typeTable, loader, rttFactory);
  +    }
  +
  +    protected Object createIntermediary(UnmarshalResult context)
       {
           if (hasMulti) {
               return new UResultHolder(this);
  @@ -116,8 +102,8 @@
           }
       }
   
  -    Object getFinalObjectFromIntermediary(Object retval,
  -                                          UnmarshalResult context)
  +    protected Object getFinalObjectFromIntermediary(Object retval,
  +                                                    UnmarshalResult context)
           throws XmlException
       {
           if (hasMulti) {
  @@ -133,17 +119,12 @@
           return elementProperties[index];
       }
   
  -    RuntimeBindingProperty getAttributeProperty(int index)
  -    {
  -        return attributeProperties[index];
  -    }
  -
       //TODO: optimize this linear scan
       RuntimeBindingProperty getMatchingElementProperty(String uri,
                                                         String localname)
       {
           for (int i = 0, len = elementProperties.length; i < len; i++) {
  -            final Property prop = elementProperties[i];
  +            final ElementQNameProperty prop = elementProperties[i];
   
               if (doesPropMatch(uri, localname, prop))
                   return prop;
  @@ -151,27 +132,10 @@
           return null;
       }
   
  -    //TODO: optimize this linear scan
  -    RuntimeBindingProperty getMatchingAttributeProperty(String uri,
  -                                                        String localname,
  -                                                        UnmarshalResult context)
  -    {
  -        for (int i = 0, len = attributeProperties.length; i < len; i++) {
  -            final Property prop = attributeProperties[i];
  -
  -            if (doesPropMatch(uri, localname, prop)) {
  -                if (hasDefaultAttributes && (prop.typedDefaultValue != null)) {
  -                    context.attributePresent(i);
  -                }
  -                return prop;
  -            }
  -        }
  -        return null;
  -    }
   
       private static boolean doesPropMatch(String uri,
                                            String localname,
  -                                         Property prop)
  +                                         QNamePropertyBase prop)
       {
           assert localname != null;
   
  @@ -185,205 +149,31 @@
           return elementProperties.length;
       }
   
  -    public int getAttributePropertyCount()
  +    protected boolean hasMulti()
       {
  -        return attributeProperties.length;
  +        return hasMulti;
       }
   
  -    public void fillDefaultAttributes(Object inter, UnmarshalResult context)
  -        throws XmlException
  -    {
  -        if (!hasDefaultAttributes) return;
  -
  -        for (int aidx = 0, alen = attributeProperties.length; aidx < alen; aidx++) {
  -            final Property p = attributeProperties[aidx];
  -
  -            if (p.typedDefaultValue == null) continue;
  -            if (context.isAttributePresent(aidx)) continue;
  -
  -            p.fillDefaultValue(inter);
  -        }
  -    }
   
  -
  -    private static final class Property implements RuntimeBindingProperty
  +    protected static final class ElementQNameProperty
  +        extends QNamePropertyBase
       {
  -        private final int propertyIndex;
  -        private final Class beanClass;
  -        private final boolean beanHasMulti;          //consider a subclass
  -        private final QNameProperty bindingProperty;
  -        private final RuntimeBindingType runtimeBindingType;
  -        private final Class propertyClass;
  -        private final Class collectionElementClass; //null for non collections
  -        private final TypeUnmarshaller unmarshaller;
  -        private final TypeMarshaller marshaller; // used only for simple types
  -        private final Method getMethod;
  -        private final Method setMethod;
  -        private final Method issetMethod;
  -        private final String lexicalDefaultValue;
  -        private final Object typedDefaultValue;
  -
  -        private static final Object[] EMPTY_OBJECT_ARRAY = new Object[]{};
  -
  -        Property(int property_index,
  -                 Class beanClass,
  -                 boolean bean_has_multis,
  -                 QNameProperty prop,
  -                 RuntimeBindingTypeTable typeTable,
  -                 BindingLoader loader,
  -                 RuntimeTypeFactory rttFactory)
  +        ElementQNameProperty(int property_index,
  +                             Class beanClass,
  +                             boolean bean_has_multis,
  +                             QNameProperty prop,
  +                             IntermediateResolver intermediateResolver,
  +                             RuntimeBindingTypeTable typeTable,
  +                             BindingLoader loader,
  +                             RuntimeTypeFactory rttFactory)
               throws XmlException
           {
  -            if (prop.getQName() == null) {
  -                final String msg = "property " + property_index + " of " +
  -                    beanClass + " has no qname";
  -                throw new IllegalArgumentException(msg);
  -            }
  -
  -            this.propertyIndex = property_index;
  -            this.beanClass = beanClass;
  -            this.beanHasMulti = bean_has_multis;
  -            this.bindingProperty = prop;
  -            final BindingTypeName type_name = prop.getTypeName();
  -            this.unmarshaller = typeTable.lookupUnmarshaller(type_name, loader);
  -            this.marshaller = typeTable.lookupMarshaller(type_name, loader);
  -
  -            final BindingType binding_type = loader.getBindingType(type_name);
  -            if (binding_type == null) {
  -                throw new XmlException("unable to load " + type_name);
  -            }
  -            runtimeBindingType =
  -                rttFactory.createRuntimeType(binding_type, typeTable, loader);
  -            assert runtimeBindingType != null;
  -
  -            propertyClass = getPropertyClass(prop, binding_type);
  -            collectionElementClass = getCollectionElementClass(prop, binding_type);
  -            getMethod = getGetterMethod(prop, beanClass);
  -            setMethod = getSetterMethod(prop, beanClass);
  -            issetMethod = getIssetterMethod(prop, beanClass);
  -
  -            lexicalDefaultValue = bindingProperty.getDefault();
  -            if (lexicalDefaultValue != null) {
  -                typedDefaultValue = extractDefaultObject(lexicalDefaultValue,
  -                                                         binding_type,
  -                                                         typeTable, loader);
  -            } else {
  -                typedDefaultValue = null;
  -            }
  +            super(property_index, beanClass, bean_has_multis,
  +                  prop, intermediateResolver, typeTable, loader, rttFactory);
  +            assert !prop.isAttribute();
           }
   
   
  -        //REVIEW: find a shorter path to our goal.
  -        private static Object extractDefaultObject(String value,
  -                                                   BindingType bindingType,
  -                                                   RuntimeBindingTypeTable typeTable,
  -                                                   BindingLoader loader)
  -            throws XmlException
  -        {
  -            final String xmldoc = "<a>" + value + "</a>";
  -            try {
  -                final UnmarshallerImpl um = new UnmarshallerImpl(loader, typeTable);
  -                final StringReader sr = new StringReader(xmldoc);
  -                final XMLStreamReader reader =
  -                    um.getXmlInputFactory().createXMLStreamReader(sr);
  -                boolean ok =
  -                    MarshalStreamUtils.advanceToNextStartElement(reader);
  -                assert ok;
  -                final BindingTypeName btname = bindingType.getName();
  -                final Object obj =
  -                    um.unmarshalType(reader, btname.getXmlName().getQName(),
  -                                     btname.getJavaName().toString());
  -                reader.close();
  -                sr.close();
  -                return obj;
  -            }
  -            catch (XmlRuntimeException re) {
  -                //TODO: improve error handling using custom error handler
  -                //esp nice to provide error info from config file
  -                final String msg = "invalid default value: " + value +
  -                    " for type " + bindingType.getName();
  -                throw new XmlException(msg, re);
  -            }
  -            catch (XMLStreamException e) {
  -                throw new XmlException(e);
  -            }
  -        }
  -
  -        private Class getPropertyClass(QNameProperty prop, BindingType btype)
  -            throws XmlException
  -        {
  -            assert btype != null;
  -
  -            final Class propertyClass;
  -            try {
  -                final ClassLoader our_cl = getClass().getClassLoader();
  -                final JavaTypeName collectionClass = prop.getCollectionClass();
  -
  -                if (collectionClass == null) {
  -                    propertyClass = getJavaClass(btype, our_cl);
  -                } else {
  -                    final String col = collectionClass.toString();
  -                    propertyClass = ClassLoadingUtils.loadClass(col, our_cl);
  -                }
  -            }
  -            catch (ClassNotFoundException ex) {
  -                throw new XmlException(ex);
  -            }
  -            return propertyClass;
  -        }
  -
  -
  -        private Class getCollectionElementClass(QNameProperty prop,
  -                                                BindingType btype)
  -            throws XmlException
  -        {
  -            assert btype != null;
  -
  -            try {
  -                final JavaTypeName collectionClass = prop.getCollectionClass();
  -
  -                if (collectionClass == null) {
  -                    return null;
  -                } else {
  -                    final ClassLoader our_cl = getClass().getClassLoader();
  -                    return getJavaClass(btype, our_cl);
  -                }
  -            }
  -            catch (ClassNotFoundException ex) {
  -                throw new XmlException(ex);
  -            }
  -        }
  -
  -
  -        public RuntimeBindingType getRuntimeBindingType()
  -        {
  -            return runtimeBindingType;
  -        }
  -
  -        public RuntimeBindingType getActualRuntimeType(Object property_value,
  -                                                       MarshalResult result)
  -            throws XmlException
  -        {
  -            return MarshalResult.findActualRuntimeType(property_value,
  -                                                       runtimeBindingType,
  -                                                       result);
  -        }
  -
  -        public QName getName()
  -        {
  -            return bindingProperty.getQName();
  -        }
  -
  -
  -        public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  -            throws XmlException
  -        {
  -            //don't need any xsi stuff for attributes.
  -            if (bindingProperty.isAttribute()) return unmarshaller;
  -
  -            return context.determineTypeUnmarshaller(unmarshaller);
  -        }
  -
           public void fill(final Object inter, final Object prop_obj)
               throws XmlException
           {
  @@ -399,181 +189,18 @@
                   if (isMultiple()) {
                       rh.addItem(propertyIndex, prop_obj);
                   } else {
  -                    invokeMethod(rh.getValue(), setMethod,
  +                    ReflectionUtils.invokeMethod(rh.getValue(), setMethod,
                                    new Object[]{prop_obj});
                   }
               } else {
  -                invokeMethod(inter, setMethod, new Object[]{prop_obj});
  -            }
  -        }
  -
  -        public void fillDefaultValue(Object inter)
  -            throws XmlException
  -        {
  -            assert (typedDefaultValue != null);
  -
  -            this.fill(inter, typedDefaultValue);
  -        }
  -
  -        public void fillCollection(final Object inter, final Object prop_obj)
  -            throws XmlException
  -        {
  -            assert isMultiple();
  -            invokeMethod(inter, setMethod, new Object[]{prop_obj});
  -        }
  -
  -        public CharSequence getLexical(Object value, MarshalResult result)
  -            throws XmlException
  -        {
  -            assert value != null :
  -                "null value for " + bindingProperty + " class=" + beanClass;
  -
  -            assert  result != null :
  -                "null value for " + bindingProperty + " class=" + beanClass;
  -
  -            assert marshaller != null :
  -                "null marshaller for prop=" + bindingProperty + " class=" +
  -                beanClass + " propType=" + bindingProperty.getTypeName();
  -
  -            return marshaller.print(value, result);
  -        }
  -
  -        public Object getValue(Object parentObject, MarshalResult result)
  -            throws XmlException
  -        {
  -            assert parentObject != null;
  -            assert beanClass.isAssignableFrom(parentObject.getClass()) :
  -                parentObject.getClass() + " is not a " + beanClass;
  -
  -            return invokeMethod(parentObject, getMethod, EMPTY_OBJECT_ARRAY);
  -        }
  -
  -        public boolean isSet(Object parentObject, MarshalResult result)
  -            throws XmlException
  -        {
  -            if (issetMethod == null)
  -                return isSetFallback(parentObject, result);
  -
  -            final Boolean isset =
  -                (Boolean)invokeMethod(parentObject, issetMethod,
  -                                      EMPTY_OBJECT_ARRAY);
  -            return isset.booleanValue();
  -        }
  -
  -        private static Object invokeMethod(Object target,
  -                                           Method method,
  -                                           Object[] params)
  -            throws XmlException
  -        {
  -            try {
  -                return method.invoke(target, params);
  -            }
  -            catch (IllegalAccessException e) {
  -                throw new XmlException(e);
  -            }
  -            catch (IllegalArgumentException e) {
  -                throw new XmlException(e);
  +                ReflectionUtils.invokeMethod(inter, setMethod, new Object[]{prop_obj});
               }
  -            catch (InvocationTargetException e) {
  -                throw new XmlException(e);
  -            }
  -        }
  -
  -        private boolean isSetFallback(Object parentObject, MarshalResult result)
  -            throws XmlException
  -        {
  -            //REVIEW: nillable is winning over minOccurs="0".  Is this correct?
  -            if (bindingProperty.isNillable())
  -                return true;
  -
  -            Object val = getValue(parentObject, result);
  -            return (val != null);
           }
   
  -        public boolean isMultiple()
  -        {
  -            return bindingProperty.isMultiple();
  -        }
  -
  -        public boolean isNillable()
  -        {
  -            return bindingProperty.isNillable();
  -        }
  -
  -        public String getLexicalDefault()
  -        {
  -            return lexicalDefaultValue;
  -        }
  -
  -        private static Method getSetterMethod(QNameProperty binding_prop,
  -                                              Class beanClass)
  -            throws XmlException
  -        {
  -            if (!binding_prop.hasSetter()) return null;
  -
  -            MethodName setterName = binding_prop.getSetterName();
  -            return getMethodOnClass(setterName, beanClass);
  -        }
  -
  -        private static Method getIssetterMethod(QNameProperty binding_prop,
  -                                                Class clazz)
  -            throws XmlException
  -        {
  -            if (!binding_prop.hasIssetter())
  -                return null;
  -
  -            Method isset_method =
  -                getMethodOnClass(binding_prop.getIssetterName(), clazz);
  -
  -            if (!isset_method.getReturnType().equals(Boolean.TYPE)) {
  -                String msg = "invalid isset method: " + isset_method +
  -                    " -- return type must be boolean not " +
  -                    isset_method.getReturnType().getName();
  -                throw new XmlException(msg);
  -            }
  -
  -            return isset_method;
  -        }
  -
  -
  -        private static Method getGetterMethod(QNameProperty binding_prop,
  -                                              Class beanClass)
  -            throws XmlException
  -        {
  -            MethodName getterName = binding_prop.getGetterName();
  -            return getMethodOnClass(getterName, beanClass);
  -        }
  -
  -
  -        private static Method getMethodOnClass(MethodName method_name,
  -                                               Class clazz)
  -            throws XmlException
  -        {
  -            try {
  -                return method_name.getMethodOn(clazz);
  -            }
  -            catch (NoSuchMethodException e) {
  -                throw new XmlException(e);
  -            }
  -            catch (SecurityException se) {
  -                throw new XmlException(se);
  -            }
  -            catch (ClassNotFoundException cnfe) {
  -                throw new XmlException(cnfe);
  -            }
  -        }
  -
  -
  -        QName getQName()
  -        {
  -            return bindingProperty.getQName();
  -        }
  -
  -
       }
   
   
  -    private static final class UResultHolder
  +    protected static final class UResultHolder
       {
           private final ByNameRuntimeBindingType runtimeBindingType;
           private final Object value;
  @@ -589,11 +216,11 @@
           Object getFinalValue() throws XmlException
           {
               if (accumulators != null) {
  -                final Property[] props = runtimeBindingType.elementProperties;
  +                final QNamePropertyBase[] props = runtimeBindingType.elementProperties;
                   for (int i = 0, len = accumulators.length; i < len; i++) {
                       final Accumulator accum = accumulators[i];
                       if (accum != null) {
  -                        final Property prop = props[i];
  +                        final QNamePropertyBase prop = props[i];
                           prop.fillCollection(value, accum.getFinalArray());
                       }
                   }
  @@ -615,7 +242,7 @@
                   accumulators = accs;
               }
               if (accs[elem_idx] == null) {
  -                final Property p = runtimeBindingType.elementProperties[elem_idx];
  +                final QNamePropertyBase p = runtimeBindingType.elementProperties[elem_idx];
                   accs[elem_idx] =
                       AccumulatorFactory.createAccumulator(p.propertyClass,
                                                            p.collectionElementClass);
  @@ -626,7 +253,6 @@
           {
               return value;
           }
  -
   
       }
   
  
  
  
  1.21      +41 -26    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameTypeVisitor.java
  
  Index: ByNameTypeVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameTypeVisitor.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ByNameTypeVisitor.java	6 Mar 2004 01:46:00 -0000	1.20
  +++ ByNameTypeVisitor.java	9 Mar 2004 23:50:53 -0000	1.21
  @@ -31,8 +31,7 @@
       private final int maxElementPropCount;
       private final int maxAttributePropCount;
       private int elemPropIdx = -1;
  -    private List attributeNames;
  -    private List attributeValues;
  +    private List attributes; //name, value, name, value...
       private Iterator currMultipleIterator;
       private Object currMultipleItem;
       private boolean haveMultipleItem;
  @@ -164,38 +163,50 @@
       protected int getAttributeCount()
           throws XmlException
       {
  -        assert attributeNames.size() == attributeValues.size();
  -
  -        return attributeValues.size();
  +        final int sz = ((attributes.size()) / 2);
  +        return sz;
       }
   
       protected void initAttributes()
           throws XmlException
       {
  -        assert attributeNames == null;
  -        assert attributeValues == null;
  +        attributes = new ArrayList();
  +        initAttributesInternal(this,
  +                               attributes,
  +                               type,
  +                               maxAttributePropCount,
  +                               marshalResult);
  +
  +    }
  +
  +    static void initAttributesInternal(NamedXmlTypeVisitor typeVisitor,
  +                                       List atts,
  +                                       AttributeRuntimeBindingType rtt,
  +                                       int maxAttributePropCount,
  +                                       MarshalResult marshalResult)
  +        throws XmlException
  +    {
  +        assert atts != null;
  +        atts.clear();
   
  -        final List vals = new ArrayList();
  -        final List names = new ArrayList();
   
  -        final Object parent = getParentObject();
  +        final Object parent = typeVisitor.getParentObject();
           if (parent == null) {
  -            QName nil_qn = fillPrefix(MarshalStreamUtils.XSI_NIL_QNAME);
  -            names.add(nil_qn);
  -            vals.add(XsTypeConverter.printBoolean(true));
  +            QName nil_qn = typeVisitor.fillPrefix(MarshalStreamUtils.XSI_NIL_QNAME);
  +            addAttribute(atts, nil_qn, XsTypeConverter.printBoolean(true));
           } else {
  -            if (needsXsiType()) {
  -                QName aname = fillPrefix(MarshalStreamUtils.XSI_TYPE_QNAME);
  -                names.add(aname);
  -                QName tn = fillPrefix(type.getSchemaTypeName());
  +            if (typeVisitor.needsXsiType()) {
  +                QName aname = typeVisitor.fillPrefix(MarshalStreamUtils.XSI_TYPE_QNAME);
  +                QName tn = typeVisitor.fillPrefix(rtt.getSchemaTypeName());
                   String aval = XsTypeConverter.getQNameString(tn.getNamespaceURI(),
                                                                tn.getLocalPart(),
                                                                tn.getPrefix());
  -                vals.add(aval);
  +
  +                addAttribute(atts, aname, aval);
               }
   
               for (int i = 0, len = maxAttributePropCount; i < len; i++) {
  -                final RuntimeBindingProperty prop = type.getAttributeProperty(i);
  +                final RuntimeBindingProperty prop = rtt.getAttributeProperty(i);
   
                   if (!prop.isSet(parent, marshalResult)) continue;
   
  @@ -207,26 +218,30 @@
   
                   if (val == null) continue;
   
  -                vals.add(val);
  -                names.add(fillPrefix(prop.getName()));
  +                addAttribute(atts, typeVisitor.fillPrefix(prop.getName()), val);
               }
           }
   
  -        attributeNames = names;
  -        attributeValues = vals;
  +        assert (atts.size() % 2) == 0;
  +    }
   
  -        assert attributeNames.size() == attributeValues.size();
  +    static void addAttribute(List atts, QName name, CharSequence value) {
  +        atts.add(name);
  +        atts.add(value);
  +
  +        assert (atts.size() % 2) == 0;
       }
   
  +
       protected String getAttributeValue(int idx)
       {
  -        CharSequence val = (CharSequence)attributeValues.get(idx);
  +        CharSequence val = (CharSequence)attributes.get(1 + (idx * 2));
           return val.toString();
       }
   
       protected QName getAttributeName(int idx)
       {
  -        QName an = (QName)attributeNames.get(idx);
  +        QName an = (QName)attributes.get(idx * 2);
   
           //make sure we have a valid prefix
           assert ((an.getPrefix().length() == 0) ==
  
  
  
  1.17      +7 -50     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameUnmarshaller.java
  
  Index: ByNameUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameUnmarshaller.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ByNameUnmarshaller.java	2 Mar 2004 02:54:07 -0000	1.16
  +++ ByNameUnmarshaller.java	9 Mar 2004 23:50:53 -0000	1.17
  @@ -18,32 +18,19 @@
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   
  -final class ByNameUnmarshaller implements TypeUnmarshaller
  +final class ByNameUnmarshaller
  +    extends AttributeUnmarshaller
   {
  -    private final ByNameRuntimeBindingType type;
  +    private final ByNameRuntimeBindingType byNameType;
   
       public ByNameUnmarshaller(ByNameRuntimeBindingType type)
       {
  -        this.type = type;
  -    }
  -
  -    public Object unmarshal(UnmarshalResult context)
  -        throws XmlException
  -    {
  -        final Object inter = type.createIntermediary(context);
  -        deserializeAttributes(inter, context);
  -        deserializeContents(inter, context);
  -        return type.getFinalObjectFromIntermediary(inter, context);
  -    }
  -
  -    public Object unmarshalAttribute(UnmarshalResult context)
  -    {
  -        throw new UnsupportedOperationException("not an attribute: " +
  -                                                type.getSchemaTypeName());
  +        super(type);
  +        this.byNameType = type;
       }
   
       //TODO: cleanup this code.  We are doing extra work for assertion checking
  -    private void deserializeContents(Object inter, UnmarshalResult context)
  +    protected void deserializeContents(Object inter, UnmarshalResult context)
           throws XmlException
       {
           assert context.isStartElement();
  @@ -75,43 +62,13 @@
       }
   
   
  -    private void deserializeAttributes(Object inter, UnmarshalResult context)
  -        throws XmlException
  -    {
  -        while (context.hasMoreAttributes()) {
  -            RuntimeBindingProperty prop = findMatchingAttributeProperty(context);
  -
  -            if (prop != null) {
  -                UnmarshalResult.fillAttributeProp(prop, context, inter);
  -            }
  -
  -            context.advanceAttribute();
  -        }
  -
  -        type.fillDefaultAttributes(inter, context);
  -    }
  -
  -    private RuntimeBindingProperty findMatchingAttributeProperty(UnmarshalResult context)
  -    {
  -        String uri = context.getCurrentAttributeNamespaceURI();
  -        String lname = context.getCurrentAttributeLocalName();
  -
  -        return type.getMatchingAttributeProperty(uri, lname, context);
  -    }
  -
       private RuntimeBindingProperty findMatchingElementProperty(UnmarshalResult context)
       {
           String uri = context.getNamespaceURI();
           String lname = context.getLocalName();
  -        return type.getMatchingElementProperty(uri, lname);
  +        return byNameType.getMatchingElementProperty(uri, lname);
       }
   
  -    //prepare internal data structures for use
  -    public void initialize(RuntimeBindingTypeTable typeTable,
  -                           BindingLoader bindingLoader)
  -    {
  -        //type.initialize(typeTable, bindingLoader);
  -    }
   
   
   }
  
  
  
  1.18      +22 -1     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java
  
  Index: MarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MarshalResult.java	6 Mar 2004 01:46:00 -0000	1.17
  +++ MarshalResult.java	9 Mar 2004 23:50:53 -0000	1.18
  @@ -18,12 +18,14 @@
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.XmlOptions;
   import org.apache.xmlbeans.XmlRuntimeException;
  +import org.apache.xmlbeans.XmlError;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
   import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingType;
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
  +import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
   import org.apache.xmlbeans.impl.common.XmlStreamUtils;
  @@ -592,7 +594,7 @@
           if (property_value == null)
               return expected_type;
   
  -        if (expected_type.isJavaPrimitive())
  +        if (expected_type.isJavaPrimitive() || expected_type.isJavaFinal())
               return expected_type;
   
           final Class instance_class = property_value.getClass();
  @@ -616,6 +618,17 @@
           this.currIndex = currIndex;
       }
   
  +    BindingLoader getBindingLoader()
  +    {
  +        return bindingLoader;
  +    }
  +
  +    public void addWarning(String msg)
  +    {
  +        XmlError e = XmlError.forMessage(msg, XmlError.SEVERITY_WARNING);
  +        getErrorCollection().add(e);
  +    }
  +
       private static final class BindingTypeVisitor
           implements org.apache.xmlbeans.impl.binding.bts.BindingTypeVisitor
       {
  @@ -660,6 +673,14 @@
               xmlTypeVisitor = new ByNameTypeVisitor(runtimeBindingProperty,
                                                      parentObject,
                                                      marshalResult);
  +        }
  +
  +        public void visit(SimpleContentBean simpleContentBean)
  +            throws XmlException
  +        {
  +            xmlTypeVisitor = new SimpleContentTypeVisitor(runtimeBindingProperty,
  +                                                          parentObject,
  +                                                          marshalResult);
           }
   
           public void visit(SimpleBindingType simpleBindingType)
  
  
  
  1.10      +229 -0    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingType.java
  
  Index: RuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingType.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RuntimeBindingType.java	19 Feb 2004 18:43:56 -0000	1.9
  +++ RuntimeBindingType.java	9 Mar 2004 23:50:53 -0000	1.10
  @@ -16,11 +16,19 @@
   package org.apache.xmlbeans.impl.marshal;
   
   import org.apache.xmlbeans.XmlException;
  +import org.apache.xmlbeans.XmlRuntimeException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  +import org.apache.xmlbeans.impl.binding.bts.BindingProperty;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
  +import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.bts.JavaTypeName;
  +import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils;
   
   import javax.xml.namespace.QName;
  +import javax.xml.stream.XMLStreamException;
  +import javax.xml.stream.XMLStreamReader;
  +import java.io.StringReader;
  +import java.lang.reflect.Method;
   
   /**
    * what we need to know about a binding type at runtime.
  @@ -32,6 +40,7 @@
       private final BindingType bindingType;
       private final Class javaClass;
       private final boolean javaPrimitive;
  +    private final boolean javaFinal;
   
       RuntimeBindingType(BindingType binding_type)
           throws XmlException
  @@ -49,6 +58,7 @@
           }
   
           javaPrimitive = javaClass.isPrimitive();
  +        javaFinal = ReflectionUtils.isClassFinal(javaClass);
       }
   
   
  @@ -78,6 +88,11 @@
           return javaPrimitive;
       }
   
  +    final boolean isJavaFinal()
  +    {
  +        return javaFinal;
  +    }
  +
       protected static Class getJavaClass(BindingType btype, ClassLoader backup)
           throws ClassNotFoundException
       {
  @@ -90,5 +105,219 @@
       {
           return getBindingType().getName().getXmlName().getQName();
       }
  +
  +    //REVIEW: find a shorter path to our goal.
  +    protected static Object extractDefaultObject(String value,
  +                                                 BindingType bindingType,
  +                                                 RuntimeBindingTypeTable typeTable,
  +                                                 BindingLoader loader)
  +        throws XmlException
  +    {
  +        final String xmldoc = "<a>" + value + "</a>";
  +        try {
  +            final UnmarshallerImpl um = new UnmarshallerImpl(loader, typeTable);
  +            final StringReader sr = new StringReader(xmldoc);
  +            final XMLStreamReader reader =
  +                um.getXmlInputFactory().createXMLStreamReader(sr);
  +            boolean ok =
  +                MarshalStreamUtils.advanceToNextStartElement(reader);
  +            assert ok;
  +            final BindingTypeName btname = bindingType.getName();
  +            final Object obj =
  +                um.unmarshalType(reader, btname.getXmlName().getQName(),
  +                                 btname.getJavaName().toString());
  +            reader.close();
  +            sr.close();
  +            return obj;
  +        }
  +        catch (XmlRuntimeException re) {
  +            //TODO: improve error handling using custom error handler
  +            //esp nice to provide error info from config file
  +            final String msg = "invalid default value: " + value +
  +                " for type " + bindingType.getName();
  +            throw new XmlException(msg, re);
  +        }
  +        catch (XMLStreamException e) {
  +            throw new XmlException(e);
  +        }
  +    }
  +
  +    public String toString()
  +    {
  +        return this.getClass().getName() +
  +            "{" +
  +            "bindingType=" + bindingType +
  +            "}";
  +    }
  +
  +
  +    protected abstract static class RuntimePropertyBase
  +        implements RuntimeBindingProperty
  +    {
  +        protected final Class beanClass;
  +        protected final IntermediateResolver intermediateResolver;
  +        protected final Method getMethod;
  +        protected final Method setMethod;
  +        protected final Method issetMethod;
  +        protected final RuntimeBindingType runtimeBindingType;
  +        protected final Class propertyClass;
  +        protected final Class collectionElementClass; //null for non collections
  +        protected final TypeUnmarshaller unmarshaller;
  +        protected final TypeMarshaller marshaller; // used only for simple types
  +
  +
  +        RuntimePropertyBase(Class beanClass,
  +                            BindingProperty prop,
  +                            IntermediateResolver intermediateResolver,
  +                            RuntimeBindingTypeTable typeTable,
  +                            BindingLoader loader,
  +                            RuntimeTypeFactory rttFactory)
  +            throws XmlException
  +        {
  +            this.beanClass = beanClass;
  +            this.intermediateResolver = intermediateResolver;
  +            final BindingTypeName type_name = prop.getTypeName();
  +            this.unmarshaller = typeTable.lookupUnmarshaller(type_name, loader);
  +            this.marshaller = typeTable.lookupMarshaller(type_name, loader);
  +
  +            final BindingType binding_type = loader.getBindingType(type_name);
  +            if (binding_type == null) {
  +                throw new XmlException("unable to load " + type_name);
  +            }
  +            runtimeBindingType =
  +                rttFactory.createRuntimeType(binding_type, typeTable, loader);
  +            assert runtimeBindingType != null;
  +
  +            propertyClass = getPropertyClass(prop, binding_type);
  +            collectionElementClass = getCollectionElementClass(prop, binding_type);
  +            getMethod = ReflectionUtils.getGetterMethod(prop, beanClass);
  +            setMethod = ReflectionUtils.getSetterMethod(prop, beanClass);
  +            issetMethod = ReflectionUtils.getIssetterMethod(prop, beanClass);
  +        }
  +
  +
  +        public void fill(final Object inter, final Object prop_obj)
  +            throws XmlException
  +        {
  +            Object inst = intermediateResolver.getObjectFromIntermediate(inter);
  +            ReflectionUtils.invokeMethod(inst, setMethod, new Object[]{prop_obj});
  +        }
  +
  +        public final Object getValue(Object parentObject, MarshalResult result)
  +            throws XmlException
  +        {
  +            assert parentObject != null;
  +            assert beanClass.isAssignableFrom(parentObject.getClass()) :
  +                parentObject.getClass() + " is not a " + beanClass;
  +
  +            return ReflectionUtils.invokeMethod(parentObject, getMethod);
  +        }
  +
  +        protected Class getPropertyClass(BindingProperty prop, BindingType btype)
  +            throws XmlException
  +        {
  +            assert btype != null;
  +
  +            final Class propertyClass;
  +            try {
  +                final ClassLoader our_cl = getClass().getClassLoader();
  +                final JavaTypeName collectionClass = prop.getCollectionClass();
  +
  +                if (collectionClass == null) {
  +                    propertyClass = getJavaClass(btype, our_cl);
  +                } else {
  +                    final String col = collectionClass.toString();
  +                    propertyClass = ClassLoadingUtils.loadClass(col, our_cl);
  +                }
  +            }
  +            catch (ClassNotFoundException ex) {
  +                throw new XmlException(ex);
  +            }
  +            return propertyClass;
  +        }
  +
  +        protected Class getCollectionElementClass(BindingProperty prop,
  +                                                  BindingType btype)
  +            throws XmlException
  +        {
  +            assert btype != null;
  +
  +            try {
  +                final JavaTypeName collectionClass = prop.getCollectionClass();
  +
  +                if (collectionClass == null) {
  +                    return null;
  +                } else {
  +                    final ClassLoader our_cl = getClass().getClassLoader();
  +                    return getJavaClass(btype, our_cl);
  +                }
  +            }
  +            catch (ClassNotFoundException ex) {
  +                throw new XmlException(ex);
  +            }
  +        }
  +
  +        public final RuntimeBindingType getRuntimeBindingType()
  +        {
  +            return runtimeBindingType;
  +        }
  +
  +        public final RuntimeBindingType getActualRuntimeType(Object property_value,
  +                                                             MarshalResult result)
  +            throws XmlException
  +        {
  +            return MarshalResult.findActualRuntimeType(property_value,
  +                                                       runtimeBindingType,
  +                                                       result);
  +        }
  +
  +
  +        public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  +            throws XmlException
  +        {
  +            return context.determineTypeUnmarshaller(unmarshaller);
  +        }
  +
  +        public final boolean isSet(Object parentObject, MarshalResult result)
  +            throws XmlException
  +        {
  +            if (issetMethod == null)
  +                return isSetFallback(parentObject, result);
  +
  +            final Boolean isset =
  +                (Boolean)ReflectionUtils.invokeMethod(parentObject, issetMethod);
  +            return isset.booleanValue();
  +        }
  +
  +        private boolean isSetFallback(Object parentObject, MarshalResult result)
  +            throws XmlException
  +        {
  +            //REVIEW: nillable is winning over minOccurs="0".  Is this correct?
  +            if (isNillable())
  +                return true;
  +
  +            Object val = getValue(parentObject, result);
  +            return (val != null);
  +        }
  +
  +        public final CharSequence getLexical(Object value,
  +                                             MarshalResult result)
  +            throws XmlException
  +        {
  +            assert value != null :
  +                "null value for " + getName() + " class=" + beanClass;
  +
  +            assert  result != null :
  +                "null value for " + getName() + " class=" + beanClass;
  +
  +            assert marshaller != null :
  +                "null marshaller for prop=" + getName() + " class=" +
  +                beanClass + " propType=" + runtimeBindingType;
  +
  +            return marshaller.print(value, result);
  +        }
  +
  +    }
  +
   
   }
  
  
  
  1.18      +24 -0     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- RuntimeBindingTypeTable.java	6 Mar 2004 01:46:00 -0000	1.17
  +++ RuntimeBindingTypeTable.java	9 Mar 2004 23:50:53 -0000	1.18
  @@ -25,9 +25,11 @@
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
   import org.apache.xmlbeans.impl.binding.bts.JavaTypeName;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
  +import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
   import org.apache.xmlbeans.impl.binding.bts.XmlTypeName;
  +import org.apache.xmlbeans.impl.binding.bts.SimpleContentProperty;
   import org.apache.xmlbeans.impl.common.ConcurrentReaderHashMap;
   import org.apache.xmlbeans.impl.common.XmlWhitespace;
   
  @@ -390,6 +392,16 @@
           TypeMarshaller m = this.getTypeMarshaller(binding_type);
           if (m != null) return m;
   
  +        if (binding_type instanceof SimpleContentBean) {
  +            SimpleContentBean scb = (SimpleContentBean)binding_type;
  +            final SimpleContentRuntimeBindingType rtt =
  +                runtimeTypeFactory.createRuntimeType(scb, this, loader);
  +            m = new SimpleContentBeanMarshaller(rtt, this, loader);
  +            putTypeMarshaller(scb, m);
  +            return m;
  +        }
  +
  +
           if (binding_type instanceof SimpleBindingType) {
               SimpleBindingType stype = (SimpleBindingType)binding_type;
   
  @@ -439,6 +451,18 @@
                                                        loader);
   
               typeUnmarshaller = new ByNameUnmarshaller(rtt);
  +        }
  +
  +
  +        public void visit(SimpleContentBean simpleContentBean)
  +            throws XmlException
  +        {
  +            SimpleContentRuntimeBindingType rtt =
  +                runtimeTypeFactory.createRuntimeType(simpleContentBean,
  +                                                     runtimeBindingTypeTable,
  +                                                     loader);
  +
  +            typeUnmarshaller = new SimpleContentUnmarshaller(rtt);
           }
   
           public void visit(SimpleBindingType simpleBindingType)
  
  
  
  1.12      +19 -2     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeTypeFactory.java
  
  Index: RuntimeTypeFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeTypeFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RuntimeTypeFactory.java	6 Mar 2004 01:46:00 -0000	1.11
  +++ RuntimeTypeFactory.java	9 Mar 2004 23:50:53 -0000	1.12
  @@ -18,12 +18,13 @@
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
  +import org.apache.xmlbeans.impl.binding.bts.BindingTypeVisitor;
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingType;
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
  -import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
  -import org.apache.xmlbeans.impl.binding.bts.BindingTypeVisitor;
  +import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
  +import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
   import org.apache.xmlbeans.impl.common.ConcurrentReaderHashMap;
   
   import java.util.HashMap;
  @@ -118,6 +119,16 @@
           return (ByNameRuntimeBindingType)rtt;
       }
   
  +    public SimpleContentRuntimeBindingType createRuntimeType(SimpleContentBean type,
  +                                                             RuntimeBindingTypeTable type_table,
  +                                                             BindingLoader binding_loader)
  +        throws XmlException
  +    {
  +        final RuntimeBindingType rtt =
  +            createRuntimeTypeInternal(type, type_table, binding_loader);
  +        return (SimpleContentRuntimeBindingType)rtt;
  +    }
  +
   
       //avoids a cast to deal with overloaded methods
       private RuntimeBindingType createRuntimeTypeInternal(BindingType type,
  @@ -156,6 +167,12 @@
               throws XmlException
           {
               runtimeBindingType = new ByNameRuntimeBindingType(byNameBean);
  +        }
  +
  +        public void visit(SimpleContentBean simpleContentBean)
  +            throws XmlException
  +        {
  +            runtimeBindingType = new SimpleContentRuntimeBindingType(simpleContentBean);
           }
   
           public void visit(SimpleBindingType simpleBindingType)
  
  
  
  1.14      +2 -45     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleTypeVisitor.java
  
  Index: SimpleTypeVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleTypeVisitor.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SimpleTypeVisitor.java	2 Mar 2004 02:54:07 -0000	1.13
  +++ SimpleTypeVisitor.java	9 Mar 2004 23:50:53 -0000	1.14
  @@ -21,11 +21,8 @@
   import javax.xml.namespace.QName;
   
   final class SimpleTypeVisitor
  -    extends NamedXmlTypeVisitor
  +    extends SimpleContentVisitor
   {
  -    private final CharacterVisitor charVisitor;
  -
  -    private int state = START;
       private QName attributeName;
       private String xsiTypeAttVal;
   
  @@ -33,43 +30,9 @@
                                MarshalResult result)
           throws XmlException
       {
  -        super(obj, property, result);
  -        charVisitor = new CharacterVisitor(property, obj, result);
  -    }
  -
  -    protected int getState()
  -    {
  -        return state;
  -    }
  -
  -    protected int advance()
  -        throws XmlException
  -    {
  -        final int newstate;
  -        switch (state) {
  -            case START:
  -                if (getParentObject() == null) {
  -                    newstate = END;
  -                } else {
  -                    newstate = CHARS;
  -                }
  -                break;
  -            case CHARS:
  -                newstate = END;
  -                break;
  -            default:
  -                throw new AssertionError("invalid state: " + state);
  -        }
  -        state = newstate;
  -        return newstate;
  +        super(property, obj, result);
       }
   
  -    public XmlTypeVisitor getCurrentChild()
  -        throws XmlException
  -    {
  -        assert state == CHARS;
  -        return charVisitor;
  -    }
   
       protected void initAttributes()
           throws XmlException
  @@ -109,11 +72,5 @@
           assert attributeName != null;
           return attributeName;
       }
  -
  -    protected CharSequence getCharData()
  -    {
  -        throw new AssertionError("not text");
  -    }
  -
   
   }
  
  
  
  1.8       +4 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TypeMarshaller.java
  
  Index: TypeMarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TypeMarshaller.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TypeMarshaller.java	12 Feb 2004 20:06:16 -0000	1.7
  +++ TypeMarshaller.java	9 Mar 2004 23:50:53 -0000	1.8
  @@ -15,6 +15,8 @@
   
   package org.apache.xmlbeans.impl.marshal;
   
  +import org.apache.xmlbeans.XmlException;
  +
   
   /**
    * A TypeMarshaller knows how to marshal a java object into xml.
  @@ -22,5 +24,6 @@
   interface TypeMarshaller
   {
       //non simple types can throw a runtime exception
  -    CharSequence print(Object value, MarshalResult result);
  +    CharSequence print(Object value, MarshalResult result)
  +        throws XmlException;
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeRuntimeBindingType.java
  
  Index: AttributeRuntimeBindingType.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  import org.apache.xmlbeans.impl.binding.bts.BindingType;
  import org.apache.xmlbeans.impl.binding.bts.QNameProperty;
  import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils;
  
  import javax.xml.namespace.QName;
  import java.util.Collection;
  import java.util.Iterator;
  
  /**
   * base type for complex types with attributes (with QNameProperties)
   */
  abstract class AttributeRuntimeBindingType
      extends RuntimeBindingType
      implements IntermediateResolver
  {
      private final AttributeQNameProperty[] attributeProperties;
      private final boolean hasDefaultAttributes;  //has any attributes with defaults
  
      AttributeRuntimeBindingType(BindingType btype)
          throws XmlException
      {
          super(btype);
  
          final Class java_type = getJavaType();
          if (java_type.isPrimitive() || java_type.isArray()) {
              final String msg = "invalid ByNameBean java type: " + java_type +
                  " found in " + btype;
              throw new XmlException(msg);
          }
  
          int att_prop_cnt = 0;
          boolean has_attribute_defaults = false;
          final Collection type_props = getQNameProperties();
          for (Iterator itr = type_props.iterator(); itr.hasNext();) {
              QNameProperty p =
                  (QNameProperty)itr.next();
              if (p.isAttribute()) {
                  att_prop_cnt++;
                  if (p.getDefault() != null) {
                      has_attribute_defaults = true;
                  }
              }
          }
  
          attributeProperties = new AttributeQNameProperty[att_prop_cnt];
          hasDefaultAttributes = has_attribute_defaults;
      }
  
      public Object getObjectFromIntermediate(Object inter)
      {
          return inter;
      }
  
      //prepare internal data structures for use
      public void initialize(RuntimeBindingTypeTable typeTable,
                             BindingLoader loader,
                             RuntimeTypeFactory rttFactory)
          throws XmlException
      {
          int att_idx = 0;
          int elem_idx = 0;
          Collection properties = getQNameProperties();
          for (Iterator itr = properties.iterator(); itr.hasNext();) {
              QNameProperty bprop = (QNameProperty)itr.next();
              final boolean is_att = bprop.isAttribute();
  
              if (is_att) {
                  final AttributeQNameProperty aprop =
                      new AttributeQNameProperty(att_idx,
                                                 getJavaType(), hasMulti(),
                                                 bprop, this,
                                                 typeTable, loader, rttFactory);
                  initAttributeProperty(aprop, att_idx++);
              } else {
                  initElementProperty(bprop, elem_idx++,
                                      typeTable, loader, rttFactory);
              }
  
          }
      }
  
      protected abstract void initElementProperty(final QNameProperty prop,
                                                  int elem_idx,
                                                  RuntimeBindingTypeTable typeTable,
                                                  BindingLoader loader,
                                                  RuntimeTypeFactory rttFactory)
          throws XmlException;
  
      private void initAttributeProperty(final AttributeQNameProperty prop,
                                         int att_idx)
      {
          attributeProperties[att_idx] = prop;
      }
  
      protected abstract Collection getQNameProperties();
  
      protected abstract Object createIntermediary(UnmarshalResult context);
  
      protected abstract Object getFinalObjectFromIntermediary(Object retval,
                                                               UnmarshalResult context)
          throws XmlException;
  
  
      final RuntimeBindingProperty getAttributeProperty(int index)
      {
          return attributeProperties[index];
      }
  
      //TODO: optimize this linear scan
      final RuntimeBindingProperty getMatchingAttributeProperty(String uri,
                                                                String localname,
                                                                UnmarshalResult context)
      {
          for (int i = 0, len = attributeProperties.length; i < len; i++) {
              final QNamePropertyBase prop = attributeProperties[i];
  
              if (doesPropMatch(uri, localname, prop)) {
                  if (hasDefaultAttributes && (prop.typedDefaultValue != null)) {
                      context.attributePresent(i);
                  }
                  return prop;
              }
          }
          return null;
      }
  
      private static boolean doesPropMatch(String uri,
                                           String localname,
                                           QNamePropertyBase prop)
      {
          assert localname != null;
  
          final QName qn = prop.getQName();
  
          return UnmarshalResult.doesElementMatch(qn, localname, uri);
      }
  
      public abstract int getElementPropertyCount();
  
      public final int getAttributePropertyCount()
      {
          return attributeProperties.length;
      }
  
      public final void fillDefaultAttributes(Object inter,
                                              UnmarshalResult context)
          throws XmlException
      {
          if (!hasDefaultAttributes) return;
  
          for (int aidx = 0, alen = attributeProperties.length; aidx < alen; aidx++) {
              final QNamePropertyBase p = attributeProperties[aidx];
  
              if (p.typedDefaultValue == null) continue;
              if (context.isAttributePresent(aidx)) continue;
  
              p.fillDefaultValue(inter);
          }
      }
  
      protected abstract boolean hasMulti();
  
      protected static final class AttributeQNameProperty
          extends QNamePropertyBase
      {
          AttributeQNameProperty(int property_index,
                                 Class beanClass,
                                 boolean bean_has_multis,
                                 QNameProperty prop,
                                 IntermediateResolver intermediateResolver,
                                 RuntimeBindingTypeTable typeTable,
                                 BindingLoader loader,
                                 RuntimeTypeFactory rttFactory)
              throws XmlException
          {
              super(property_index, beanClass, bean_has_multis,
                    prop, intermediateResolver, typeTable, loader, rttFactory);
              assert prop.isAttribute();
          }
  
  
          public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
              throws XmlException
          {
              assert bindingProperty.isAttribute();
              //don't need any xsi stuff for attributes.
              return unmarshaller;
          }
      }
  
  
      protected static abstract class QNamePropertyBase
          extends RuntimePropertyBase
      {
          //TODO: push index down to element subclass
          protected final int propertyIndex;
          protected final boolean beanHasMulti;          //consider a subclass
          protected final QNameProperty bindingProperty;
          protected final String lexicalDefaultValue;
          protected final Object typedDefaultValue;
  
          QNamePropertyBase(int property_index,
                            Class beanClass,
                            boolean bean_has_multis,
                            QNameProperty prop,
                            IntermediateResolver intermediateResolver,
                            RuntimeBindingTypeTable typeTable,
                            BindingLoader loader,
                            RuntimeTypeFactory rttFactory)
              throws XmlException
          {
              super(beanClass, prop, intermediateResolver, typeTable, loader, rttFactory);
  
              if (prop.getQName() == null) {
                  final String msg = "property " + property_index + " of " +
                      beanClass + " has no qname";
                  throw new IllegalArgumentException(msg);
              }
  
              this.propertyIndex = property_index;
              this.beanHasMulti = bean_has_multis;
              this.bindingProperty = prop;
  
              lexicalDefaultValue = bindingProperty.getDefault();
              if (lexicalDefaultValue != null) {
                  typedDefaultValue = extractDefaultObject(lexicalDefaultValue,
                                                           runtimeBindingType.getBindingType(),
                                                           typeTable, loader);
              } else {
                  typedDefaultValue = null;
              }
          }
  
  
          public final QName getName()
          {
              return bindingProperty.getQName();
          }
  
  
          public final void fillDefaultValue(Object inter)
              throws XmlException
          {
              assert (typedDefaultValue != null);
  
              this.fill(inter, typedDefaultValue);
          }
  
          public final void fillCollection(final Object inter,
                                           final Object prop_obj)
              throws XmlException
          {
              assert isMultiple();
              ReflectionUtils.invokeMethod(inter, setMethod, new Object[]{prop_obj});
          }
  
          public final boolean isMultiple()
          {
              return bindingProperty.isMultiple();
          }
  
          public final boolean isNillable()
          {
              return bindingProperty.isNillable();
          }
  
          public final String getLexicalDefault()
          {
              return lexicalDefaultValue;
          }
  
          final QName getQName()
          {
              return bindingProperty.getQName();
          }
      }
  
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeUnmarshaller.java
  
  Index: AttributeUnmarshaller.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  
  abstract class AttributeUnmarshaller implements TypeUnmarshaller
  {
      private final AttributeRuntimeBindingType type;
  
      public AttributeUnmarshaller(AttributeRuntimeBindingType type)
      {
          this.type = type;
      }
  
      public Object unmarshal(UnmarshalResult context)
          throws XmlException
      {
          final Object inter = type.createIntermediary(context);
          deserializeAttributes(inter, context);
          deserializeContents(inter, context);
          return type.getFinalObjectFromIntermediary(inter, context);
      }
  
      public Object unmarshalAttribute(UnmarshalResult context)
      {
          throw new UnsupportedOperationException("not an attribute: " +
                                                  type.getSchemaTypeName());
      }
  
      //TODO: cleanup this code.  We are doing extra work for assertion checking
      protected abstract void deserializeContents(Object inter,
                                                  UnmarshalResult context)
          throws XmlException;
  
  
      protected void deserializeAttributes(Object inter, UnmarshalResult context)
          throws XmlException
      {
          while (context.hasMoreAttributes()) {
              RuntimeBindingProperty prop = findMatchingAttributeProperty(context);
  
              if (prop != null) {
                  UnmarshalResult.fillAttributeProp(prop, context, inter);
              }
  
              context.advanceAttribute();
          }
  
          type.fillDefaultAttributes(inter, context);
      }
  
      protected RuntimeBindingProperty findMatchingAttributeProperty(UnmarshalResult context)
      {
          String uri = context.getCurrentAttributeNamespaceURI();
          String lname = context.getCurrentAttributeLocalName();
  
          return type.getMatchingAttributeProperty(uri, lname, context);
      }
  
      //prepare internal data structures for use
      public void initialize(RuntimeBindingTypeTable typeTable,
                             BindingLoader bindingLoader)
      {
      }
  
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/IntermediateResolver.java
  
  Index: IntermediateResolver.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.xmlbeans.impl.marshal;
  
  interface IntermediateResolver
  {
      Object getObjectFromIntermediate(Object inter);
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentBeanMarshaller.java
  
  Index: SimpleContentBeanMarshaller.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) 2000-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.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  import org.apache.xmlbeans.impl.binding.bts.BindingType;
  
  final class SimpleContentBeanMarshaller implements TypeMarshaller
  {
      private final SimpleContentRuntimeBindingType simpleContentType;
      private final TypeMarshaller contentMarshaller;
  
      public SimpleContentBeanMarshaller(SimpleContentRuntimeBindingType rtt,
                                         RuntimeBindingTypeTable table,
                                         BindingLoader loader)
          throws XmlException
      {
          simpleContentType = rtt;
          final BindingType content_binding_type =
              rtt.getSimpleContentProperty().getRuntimeBindingType().getBindingType();
          final TypeMarshaller marshaller =
              table.lookupMarshaller(content_binding_type, loader);
          if (marshaller == null) {
              String e = "failed to find marshaller for " + content_binding_type;
              throw new AssertionError(e);
          }
          contentMarshaller = marshaller;
      }
  
      //non simple types can throw a runtime exception
      public CharSequence print(Object value, MarshalResult result)
          throws XmlException
      {
          final Object simple_content_val =
              simpleContentType.getSimpleContentProperty().getValue(value, result);
  
          final RuntimeBindingType prop_rtt =
              simpleContentType.getSimpleContentProperty().getRuntimeBindingType();
          final RuntimeBindingType actualRuntimeType =
              MarshalResult.findActualRuntimeType(simple_content_val,
                                                  prop_rtt, result);
  
          TypeMarshaller content_marshaller;
          if (actualRuntimeType == prop_rtt) {
              content_marshaller = contentMarshaller;
          } else {
              RuntimeBindingTypeTable table = result.getTypeTable();
              BindingLoader loader = result.getBindingLoader();
              content_marshaller =
                  table.lookupMarshaller(prop_rtt.getBindingType(), loader);
              if (content_marshaller == null) {
                  String msg = "unable to find marshaller for " +
                      prop_rtt.getBindingType() + ".  Using default marshaller";
                  result.addWarning(msg);
                  content_marshaller = contentMarshaller;
              }
          }
          return content_marshaller.print(simple_content_val, result);
      }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentRuntimeBindingType.java
  
  Index: SimpleContentRuntimeBindingType.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  import org.apache.xmlbeans.impl.binding.bts.BindingProperty;
  import org.apache.xmlbeans.impl.binding.bts.QNameProperty;
  import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
  import org.apache.xmlbeans.impl.binding.bts.SimpleContentProperty;
  
  import javax.xml.namespace.QName;
  import java.util.Collection;
  
  public class SimpleContentRuntimeBindingType
      extends AttributeRuntimeBindingType
  {
      private SimpleContentRuntimeProperty simpleTypeProperty;
  
      public SimpleContentRuntimeBindingType(SimpleContentBean simpleContentBean)
          throws XmlException
      {
          super(simpleContentBean);
      }
  
      //prepare internal data structures for use
      public final void initialize(RuntimeBindingTypeTable typeTable,
                                   BindingLoader loader,
                                   RuntimeTypeFactory rttFactory)
          throws XmlException
      {
          super.initialize(typeTable, loader, rttFactory);
          SimpleContentBean scb = getSimpleContentBean();
          final SimpleContentProperty simpleContentProperty =
              scb.getSimpleContentProperty();
          simpleTypeProperty =
              new SimpleContentRuntimeProperty(getJavaType(),
                                               simpleContentProperty, this,
                                               typeTable, loader, rttFactory);
      }
  
      private SimpleContentBean getSimpleContentBean()
      {
          return (SimpleContentBean)getBindingType();
      }
  
      protected void initElementProperty(QNameProperty prop,
                                         int elem_idx,
                                         RuntimeBindingTypeTable typeTable,
                                         BindingLoader loader,
                                         RuntimeTypeFactory rttFactory)
          throws XmlException
      {
          throw new AssertionError("invalid property for this type: " + prop);
      }
  
      protected Collection getQNameProperties()
      {
          SimpleContentBean narrowed_type = (SimpleContentBean)getBindingType();
          return narrowed_type.getAttributeProperties();
      }
  
      protected Object createIntermediary(UnmarshalResult context)
      {
          return ClassLoadingUtils.newInstance(getJavaType());
      }
  
      protected Object getFinalObjectFromIntermediary(Object retval,
                                                      UnmarshalResult context)
          throws XmlException
      {
          return retval;
      }
  
      public int getElementPropertyCount()
      {
          return 0;
      }
  
      protected boolean hasMulti()
      {
          return false;
      }
  
      public RuntimeBindingProperty getSimpleContentProperty()
      {
          return simpleTypeProperty;
      }
  
      private static final class SimpleContentRuntimeProperty
          extends RuntimePropertyBase
      {
  
          SimpleContentRuntimeProperty(Class beanClass,
                                       BindingProperty prop,
                                       IntermediateResolver intermediateResolver,
                                       RuntimeBindingTypeTable typeTable,
                                       BindingLoader loader,
                                       RuntimeTypeFactory rttFactory)
              throws XmlException
          {
              super(beanClass, prop, intermediateResolver, typeTable, loader, rttFactory);
  
          }
  
          public QName getName()
          {
              throw new AssertionError("prop has no name by design");
          }
  
          public boolean isMultiple()
          {
              return false;
          }
  
          public boolean isNillable()
          {
              return false;
          }
  
          public String getLexicalDefault()
          {
              return null;
          }
      }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentTypeVisitor.java
  
  Index: SimpleContentTypeVisitor.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  
  import javax.xml.namespace.QName;
  import java.util.ArrayList;
  import java.util.List;
  
  final class SimpleContentTypeVisitor
      extends SimpleContentVisitor
  {
      private final SimpleContentRuntimeBindingType type;
      private final int maxAttributePropCount;
      private List attributes; //name, value, name, value...
  
      public SimpleContentTypeVisitor(RuntimeBindingProperty property,
                                      Object obj,
                                      MarshalResult result)
          throws XmlException
      {
          super(property, obj, result);
  
          type = (SimpleContentRuntimeBindingType)getActualRuntimeBindingType();
          maxAttributePropCount =
              obj == null ? 0 : type.getAttributePropertyCount();
      }
  
      protected int getAttributeCount()
          throws XmlException
      {
          return attributes.size() / 2;
      }
  
      protected void initAttributes()
          throws XmlException
      {
          attributes = new ArrayList();
          ByNameTypeVisitor.initAttributesInternal(this,
                                                   attributes,
                                                   type,
                                                   maxAttributePropCount,
                                                   marshalResult);
  
      }
  
  
      protected String getAttributeValue(int idx)
      {
          CharSequence val = (CharSequence)attributes.get(1 + (idx * 2));
          return val.toString();
      }
  
      protected QName getAttributeName(int idx)
      {
          QName an = (QName)attributes.get(idx * 2);
  
          //make sure we have a valid prefix
          assert ((an.getPrefix().length() == 0) ==
              (an.getNamespaceURI().length() == 0));
  
          return an;
      }
  
      protected CharSequence getCharData()
      {
          throw new IllegalStateException("not text: " + this);
      }
  
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentUnmarshaller.java
  
  Index: SimpleContentUnmarshaller.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  
  public class SimpleContentUnmarshaller
      extends AttributeUnmarshaller
  {
  
      private final SimpleContentRuntimeBindingType simpleContentRuntimeBindingType;
  
      public SimpleContentUnmarshaller(SimpleContentRuntimeBindingType type)
      {
          super(type);
          simpleContentRuntimeBindingType = type;
      }
  
  
      //TODO: cleanup this code.  We are doing extra work for assertion checking
      protected void deserializeContents(Object inter,
                                         UnmarshalResult context)
          throws XmlException
      {
          RuntimeBindingProperty scprop =
              simpleContentRuntimeBindingType.getSimpleContentProperty();
          UnmarshalResult.fillElementProp(scprop, context, inter);
      }
  
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentVisitor.java
  
  Index: SimpleContentVisitor.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  
  abstract class SimpleContentVisitor
      extends NamedXmlTypeVisitor
  {
      private final CharacterVisitor charVisitor;
  
      private int state = START;
  
      public SimpleContentVisitor(RuntimeBindingProperty property, Object obj,
                                  MarshalResult result)
          throws XmlException
      {
          super(obj, property, result);
          charVisitor = new CharacterVisitor(property, obj, result);
      }
  
      protected int getState()
      {
          return state;
      }
  
      protected int advance()
          throws XmlException
      {
          final int newstate;
          switch (state) {
              case START:
                  if (getParentObject() == null) {
                      newstate = END;
                  } else {
                      newstate = CHARS;
                  }
                  break;
              case CHARS:
                  newstate = END;
                  break;
              default:
                  throw new AssertionError("invalid state: " + state);
          }
          state = newstate;
          return newstate;
      }
  
      public XmlTypeVisitor getCurrentChild()
          throws XmlException
      {
          assert state == CHARS;
          return charVisitor;
      }
  
      protected CharSequence getCharData()
      {
          throw new AssertionError("not text");
      }
  
  
  }
  
  
  
  1.13      +1 -1      xml-xmlbeans/v2/test/cases/marshal/doc.xml
  
  Index: doc.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/doc.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- doc.xml	23 Feb 2004 17:18:13 -0000	1.12
  +++ doc.xml	9 Mar 2004 23:50:54 -0000	1.13
  @@ -30,7 +30,7 @@
               <n1:BigInt>2222222222</n1:BigInt>
           </n1:MyClassArray>
   
  -
  +        <n1:simpleContentExample someAtt="1.23">testing</n1:simpleContentExample>
   
       </My:Myelt>
   
  
  
  
  1.23      +55 -8     xml-xmlbeans/v2/test/cases/marshal/example_config.xml
  
  Index: example_config.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/example_config.xml,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- example_config.xml	2 Mar 2004 04:23:25 -0000	1.22
  +++ example_config.xml	9 Mar 2004 23:50:54 -0000	1.23
  @@ -1,13 +1,13 @@
  -<bin:binding-config xmlns:java="java:com.mytest" xmlns:bin="http://xml.apache.org/xmlbeans/binding-config">
  +<bin:binding-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="java:com.mytest" xmlns:bin="http://xml.apache.org/xmlbeans/binding-config">
       <bin:bindings>
   
  -        <bin:binding-type xsi:type="bin:simple-type" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +        <bin:binding-type xsi:type="bin:simple-type">
               <bin:xmlcomponent>t=custom-string@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>java.lang.String</bin:javatype>
               <bin:as-xml whitespace="collapse">t=string@http://www.w3.org/2001/XMLSchema</bin:as-xml>
           </bin:binding-type>
   
  -        <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +        <bin:binding-type xsi:type="bin:by-name-bean">
               <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>com.mytest.YourClass</bin:javatype>
   
  @@ -199,10 +199,57 @@
                   <bin:qname>java:WrappedArrayTwo</bin:qname>
               </bin:qname-property>
   
  +            <bin:qname-property>
  +                <bin:xmlcomponent>t=SimpleContentExample@java:com.mytest</bin:xmlcomponent>
  +                <bin:javatype>com.mytest.SimpleContentExample</bin:javatype>
  +                <bin:getter>
  +                    <bin:method-name>getSimpleContentExample</bin:method-name>
  +                </bin:getter>
  +                <bin:setter>
  +                    <bin:method-name>setSimpleContentExample</bin:method-name>
  +                    <bin:param-type>com.mytest.SimpleContentExample</bin:param-type>
  +                </bin:setter>
  +                <bin:qname>java:simpleContentExample</bin:qname>
  +            </bin:qname-property>
  +
  +
  +
  +        </bin:binding-type>
  +
  +
  +        <bin:binding-type xsi:type="bin:simple-content-bean">
  +            <bin:xmlcomponent>t=SimpleContentExample@java:com.mytest</bin:xmlcomponent>
  +            <bin:javatype>com.mytest.SimpleContentExample</bin:javatype>
  +
  +            <bin:simple-content-property>
  +                <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +                <bin:javatype>java.lang.String</bin:javatype>
  +                <bin:getter>
  +                    <bin:method-name>getSimpleContent</bin:method-name>
  +                </bin:getter>
  +                <bin:setter>
  +                    <bin:method-name>setSimpleContent</bin:method-name>
  +                    <bin:param-type>java.lang.String</bin:param-type>
  +                </bin:setter>
  +            </bin:simple-content-property>
  +
  +            <bin:attribute-property>
  +                <bin:xmlcomponent>t=float@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +                <bin:javatype>float</bin:javatype>
  +                <bin:getter>
  +                    <bin:method-name>getFloatAttOne</bin:method-name>
  +                </bin:getter>
  +                <bin:setter>
  +                    <bin:method-name>setFloatAttOne</bin:method-name>
  +                    <bin:param-type>float</bin:param-type>
  +                </bin:setter>
  +                <bin:qname>someAtt</bin:qname>
  +                <bin:attribute>true</bin:attribute>
  +            </bin:attribute-property>
           </bin:binding-type>
   
   
  -        <bin:binding-type xsi:type="bin:wrapped-array" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +        <bin:binding-type xsi:type="bin:wrapped-array">
               <bin:xmlcomponent>t=ArrayOfString@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>java.lang.String[]</bin:javatype>
               <bin:item-name>item</bin:item-name>
  @@ -213,7 +260,7 @@
               <bin:nillable>true</bin:nillable>
           </bin:binding-type>
   
  -        <bin:binding-type xsi:type="bin:wrapped-array" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +        <bin:binding-type xsi:type="bin:wrapped-array">
               <bin:xmlcomponent>t=ArrayOfArrayOfString@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>java.lang.String[][]</bin:javatype>
               <bin:item-name>aos</bin:item-name>
  @@ -224,7 +271,7 @@
           </bin:binding-type>
   
   
  -        <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +        <bin:binding-type xsi:type="bin:by-name-bean">
               <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>com.mytest.MyClass</bin:javatype>
               <bin:qname-property>
  @@ -254,12 +301,12 @@
                   <bin:nillable>true</bin:nillable>
               </bin:qname-property>
           </bin:binding-type>
  -        <bin:binding-type xsi:type="bin:simple-document-binding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +        <bin:binding-type xsi:type="bin:simple-document-binding">
               <bin:xmlcomponent>e=load@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>com.mytest.MyClass</bin:javatype>
               <bin:type-of-element>t=MyClass@java:com.mytest</bin:type-of-element>
           </bin:binding-type>
  -        <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +        <bin:binding-type xsi:type="bin:by-name-bean">
               <bin:xmlcomponent>t=MySubClass@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>com.mytest.MySubClass</bin:javatype>
               <bin:qname-property>
  
  
  
  1.13      +18 -0     xml-xmlbeans/v2/test/cases/marshal/com/mytest/YourClass.java
  
  Index: YourClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/com/mytest/YourClass.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- YourClass.java	2 Mar 2004 04:23:25 -0000	1.12
  +++ YourClass.java	9 Mar 2004 23:50:54 -0000	1.13
  @@ -48,6 +48,7 @@
       private String[] wrappedArrayOne = {"W1", "W2"};
       private String[][] wrappedArrayTwo = {wrappedArrayOne, null, wrappedArrayOne};
   
  +    private SimpleContentExample simpleContentExample;
   
       //hack alert
       static final Random RND = new Random();
  @@ -239,6 +240,16 @@
           this.wrappedArrayTwo = wrappedArrayTwo;
       }
   
  +    public SimpleContentExample getSimpleContentExample()
  +    {
  +        return simpleContentExample;
  +    }
  +
  +    public void setSimpleContentExample(SimpleContentExample simpleContentExample)
  +    {
  +        this.simpleContentExample = simpleContentExample;
  +    }
  +
       public boolean equals(Object o)
       {
           if (this == o) return true;
  @@ -246,6 +257,8 @@
   
           final YourClass yourClass = (YourClass)o;
   
  +
  +
           if (attrib != yourClass.attrib) return false;
           if (myFloat != yourClass.myFloat) return false;
           if (someBool != yourClass.someBool) return false;
  @@ -261,6 +274,10 @@
           if (qn != null ? !qn.equals(yourClass.qn) : yourClass.qn != null) return false;
           if (qn2 != null ? !qn2.equals(yourClass.qn2) : yourClass.qn2 != null) return false;
   
  +        if (simpleContentExample != null ?
  +            !simpleContentExample.equals(yourClass.simpleContentExample) : yourClass.simpleContentExample != null)
  +            return false;
  +
   
           return true;
       }
  @@ -289,6 +306,7 @@
               ", someBool=" + someBool +
               ", qn=" + qn +
               ", qn2=" + qn2 +
  +            ", simpleContentExample=" + simpleContentExample +
   //            ", bools=" + (bools == null ? null : "size:" + bools.size() + bools) +
   //            ", strs=" + (strs == null ? null : "size:" + strs.size() + strs) +
               ", longArray=" + ArrayUtils.arrayToString(longArray) +
  
  
  
  1.1                  xml-xmlbeans/v2/test/cases/marshal/com/mytest/SimpleContentExample.java
  
  Index: SimpleContentExample.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package com.mytest;
  
  public class SimpleContentExample
  {
      private String simpleContent;
  
      private float floatAttOne;
  
  
      public String getSimpleContent()
      {
          return simpleContent;
      }
  
      public void setSimpleContent(String simpleContent)
      {
          this.simpleContent = simpleContent;
      }
  
      public float getFloatAttOne()
      {
          return floatAttOne;
      }
  
      public void setFloatAttOne(float floatAttOne)
      {
          this.floatAttOne = floatAttOne;
      }
  
      public boolean equals(Object o)
      {
          if (this == o) return true;
          if (!(o instanceof SimpleContentExample)) return false;
  
          final SimpleContentExample simpleContentExample = (SimpleContentExample)o;
  
          if (floatAttOne != simpleContentExample.floatAttOne) return false;
          if (simpleContent != null ? !simpleContent.equals(simpleContentExample.simpleContent) :
              simpleContentExample.simpleContent != null)
              return false;
  
          return true;
      }
  
      public int hashCode()
      {
          int result;
          result = (simpleContent != null ? simpleContent.hashCode() : 0);
          result = 29 * result + Float.floatToIntBits(floatAttOne);
          return result;
      }
  
      public String toString()
      {
          return "com.mytest.SimpleContentExample{" +
              "simpleContent=" + simpleContent +
              ", floatAttOne=" + floatAttOne +
              "}";
      }
  
  }
  
  
  
  1.42      +12 -1     xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java
  
  Index: MarshalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- MarshalTests.java	6 Mar 2004 01:46:00 -0000	1.41
  +++ MarshalTests.java	9 Mar 2004 23:50:54 -0000	1.42
  @@ -18,6 +18,7 @@
   import com.mytest.MyClass;
   import com.mytest.MySubClass;
   import com.mytest.MySubSubClass;
  +import com.mytest.SimpleContentExample;
   import junit.framework.Assert;
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -336,6 +337,12 @@
   
   
           myelt.setMyClass(sub);
  +
  +        SimpleContentExample se = new SimpleContentExample();
  +        se.setFloatAttOne(44.33f);
  +        se.setSimpleContent("someSimpleContentOkay");
  +        myelt.setSimpleContentExample(se);
  +
           mc.setMyelt(myelt);
   
           myelt.setStringArray(new String[]{"one", "two", "three"});
  @@ -370,7 +377,7 @@
   //                            new QName("java:com.mytest", "MySubClass"),
   //                            "MyClass", null);
   
  -        inform("=======IN-OBJ: " + mc);
  +        inform("=======IN-OBJA: " + mc);
   
           dumpReader(reader);
           Assert.assertTrue(errors.isEmpty());
  @@ -514,9 +521,13 @@
           com.mytest.MyClass curr = top_obj;
   
           boolean[] bools = createRandomBooleanArray(rnd, boolean_array_size);
  +        SimpleContentExample sce = new SimpleContentExample();
  +        sce.setFloatAttOne(-4.234f);
  +        sce.setSimpleContent("simple simple simple");
   
           for (int i = 0; i < depth; i++) {
               com.mytest.YourClass myelt = new com.mytest.YourClass();
  +            myelt.setSimpleContentExample(sce);
               myelt.setAttrib(rnd.nextFloat());
               myelt.setMyFloat(rnd.nextFloat());
               myelt.setBooleanArray(bools);
  
  
  

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