You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by zi...@apache.org on 2004/03/25 04:19:29 UTC

cvs commit: xml-xmlbeans/v2/test/cases/marshal/com/mytest MyClass.java YourClass.java

zieg        2004/03/24 19:19:28

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        BindingProperty.java JaxrpcEnumType.java
                        QNameProperty.java
               v2/src/configschema/schema binding-config.xsd
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        AttributeRuntimeBindingType.java
                        AttributeUnmarshaller.java
                        BaseSimpleTypeConverter.java
                        ByNameRuntimeBindingType.java
                        ByNameUnmarshaller.java EmptyLocation.java
                        JaxrpcEnumUnmarshaller.java MarshallerImpl.java
                        NullUnmarshaller.java ObjectAnyTypeConverter.java
                        RuntimeBindingProperty.java RuntimeBindingType.java
                        RuntimeBindingTypeTable.java
                        RuntimeGlobalProperty.java
                        ScopedNamespaceContext.java
                        SimpleContentRuntimeBindingType.java
                        SimpleContentUnmarshaller.java
                        TypeUnmarshaller.java UnmarshalResult.java
                        WrappedArrayRuntimeBindingType.java
                        WrappedArrayUnmarshaller.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal/util
                        ArrayUtils.java ReflectionUtils.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections
                        ReflectiveArrayIterator.java
               v2/test/cases/marshal example_config.xml
               v2/test/cases/marshal/com/mytest MyClass.java YourClass.java
  Added:       v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        JavaInstanceFactory.java ParentInstanceFactory.java
  Removed:     v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        IntermediateResolver.java
  Log:
  refactor property classes to allow per property object factory as an
  optional customization.
  
  Revision  Changes    Path
  1.15      +214 -165  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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BindingProperty.java	13 Mar 2004 00:33:21 -0000	1.14
  +++ BindingProperty.java	25 Mar 2004 03:19:28 -0000	1.15
  @@ -23,173 +23,222 @@
    * are different forms of properties, some which bind based
    * on sequencing, and others which bind based on name.
    */
  -public abstract class BindingProperty {
  +public abstract class BindingProperty
  +{
   
  -  // ========================================================================
  -  // Variables
  +    // ========================================================================
  +    // Variables
   
  -  private BindingTypeName btName;
  -  private MethodName getter;
  -  private MethodName setter;
  -  private MethodName issetter;
  -  private String field;
  -  private JavaTypeName collection;
  -
  -  // ========================================================================
  -  // Constructors
  -
  -  /**
  -   * This kind of constructor is used when making a new one out of the blue.
  -   *
  -   * Subclasses should call super(..) when defining constructors that init new BindingTypes.
  -   */
  -  protected BindingProperty() {
  -  }
  -
  -  /**
  -   * This constructor loads an instance from an XML file
  -   *
  -   * Subclasses should have ctors of the same signature and call super(..) first.
  -   */
  -  protected BindingProperty(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node) {
  -    this.btName = BindingTypeName.forPair(
  +    private BindingTypeName btName;
  +    private MethodName getter;
  +    private MethodName setter;
  +    private MethodName issetter;
  +    private String field;
  +    private JavaTypeName collection;
  +    protected JavaInstanceFactory javaInstanceFactory;
  +
  +    // ========================================================================
  +    // Constructors
  +
  +    /**
  +     * This kind of constructor is used when making a new one out of the blue.
  +     *
  +     * Subclasses should call super(..) when defining constructors that init new BindingTypes.
  +     */
  +    protected BindingProperty()
  +    {
  +    }
  +
  +    /**
  +     * This constructor loads an instance from an XML file
  +     *
  +     * Subclasses should have ctors of the same signature and call super(..) first.
  +     */
  +    protected BindingProperty(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node)
  +    {
  +        this.btName = BindingTypeName.forPair(
               JavaTypeName.forString(node.getJavatype()),
               XmlTypeName.forString(node.getXmlcomponent()));
  -    this.getter = MethodName.create(node.getGetter());
  -    this.setter = MethodName.create(node.getSetter());
  -    this.issetter = MethodName.create(node.getIssetter());
  -    this.field = node.getField();
  -    String collection = node.getCollection();
  -    if (collection != null)
  -      this.collection = JavaTypeName.forString(collection);
  -  }
  -
  -  // ========================================================================
  -  // Protected methods
  -
  -  /**
  -   * This function copies an instance back out to the relevant part of the XML file.
  -   *
  -   * Subclasses should override and call super.write first.
  -   */
  -  protected org.apache.xml.xmlbeans.bindingConfig.BindingProperty write(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node) {
  -    node = (org.apache.xml.xmlbeans.bindingConfig.BindingProperty) node.changeType(kinds.typeForClass(this.getClass()));
  -
  -    node.setJavatype(btName.getJavaName().toString());
  -    node.setXmlcomponent(btName.getXmlName().toString());
  -    if (getFieldName() != null)
  -      node.setField(getFieldName());
  -    if (getGetterName() != null) {
  -      getGetterName().write(node.addNewGetter());
  -    }
  -    if (getSetterName() != null) {
  -      getSetterName().write(node.addNewSetter());
  -    }
  -    if (getCollectionClass() != null)
  -      node.setCollection(getCollectionClass().toString());
  -    return node;
  -  }
  -
  -  // ========================================================================
  -  // Public methods
  -
  -  public boolean isField() {
  -    return field != null;
  -  }
  -
  -  public BindingTypeName getTypeName() {
  -    return btName;
  -  }
  -
  -  public void setBindingType(BindingType bType) {
  -    btName = bType.getName();
  -  }
  -
  -  public MethodName getGetterName() {
  -    return isField() ? null : getter;
  -  }
  -
  -  public void setGetterName(MethodName mn) {
  -    getter = mn;
  -  }
  -
  -  public boolean hasSetter() {
  -    return !isField() && setter != null;
  -  }
  -
  -  public MethodName getSetterName() {
  -    return isField() ? null : setter;
  -  }
  -
  -  public void setSetterName(MethodName mn) {
  -    setter = mn;
  -  }
  -
  -  public boolean hasIssetter() {
  -    return !isField() && issetter != null;
  -  }
  -
  -  public MethodName getIssetterName() {
  -    return isField() ? null : issetter;
  -  }
  -
  -  public void setIssetterName(MethodName mn) {
  -    issetter = mn;
  -  }
  -
  -  public String getFieldName() {
  -    return field;
  -  }
  -
  -  public void setFieldName(String field) {
  -    this.field = field;
  -  }
  -
  -  public JavaTypeName getCollectionClass() {
  -    return collection;
  -  }
  -
  -  public void setCollectionClass(JavaTypeName jName) {
  -    collection = jName;
  -  }
  -
  -  // ========================================================================
  -  // Static initialization
  -
  -  /* REGISTRY OF SUBCLASSES */
  -
  -  private static final Class[] ctorArgs = new Class[]{org.apache.xml.xmlbeans.bindingConfig.BindingProperty.class};
  -
  -  public static BindingProperty forNode(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node) {
  -    try {
  -      Class clazz = kinds.classForType(node.schemaType());
  -      return (BindingProperty) clazz.getConstructor(ctorArgs).newInstance(new Object[]{node});
  -    } catch (Exception e) {
  -      throw (IllegalStateException) new IllegalStateException("Cannot load class for " + node.schemaType() + ": should be registered.").initCause(e);
  -    }
  -  }
  -
  -
  -  /**
  -   * Should only be called by BindingFile, when loading up bindingtypes
  -   */
  -  static KindRegistry kinds = new KindRegistry();
  -
  -  public static void registerClassAndType(Class clazz, SchemaType type) {
  -    if (!BindingProperty.class.isAssignableFrom(clazz))
  -      throw new IllegalArgumentException("Classes must inherit from BindingProperty");
  -    if (!org.apache.xml.xmlbeans.bindingConfig.BindingProperty.type.isAssignableFrom(type))
  -      throw new IllegalArgumentException("Schema types must inherit from binding-property");
  -    kinds.registerClassAndType(clazz, type);
  -  }
  -
  -  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);
  -  }
  -
  -  public String toString() {
  -    return getClass().getName() + " [" + getGetterName().getSimpleName() + "]";
  -  }
  +        this.getter = MethodName.create(node.getGetter());
  +        this.setter = MethodName.create(node.getSetter());
  +        this.issetter = MethodName.create(node.getIssetter());
  +        this.field = node.getField();
  +        String collection = node.getCollection();
  +        if (collection != null)
  +            this.collection = JavaTypeName.forString(collection);
  +
  +        final org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory factory =
  +            node.getFactory();
  +        if (factory != null) {
  +            javaInstanceFactory = JavaInstanceFactory.forNode(factory);
  +        }
  +
  +    }
  +
  +    // ========================================================================
  +    // Protected methods
  +
  +    /**
  +     * This function copies an instance back out to the relevant part of the XML file.
  +     *
  +     * Subclasses should override and call super.write first.
  +     */
  +    protected org.apache.xml.xmlbeans.bindingConfig.BindingProperty write(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node)
  +    {
  +        node = (org.apache.xml.xmlbeans.bindingConfig.BindingProperty)node.changeType(kinds.typeForClass(this.getClass()));
  +
  +        node.setJavatype(btName.getJavaName().toString());
  +        node.setXmlcomponent(btName.getXmlName().toString());
  +        if (getFieldName() != null)
  +            node.setField(getFieldName());
  +        if (getGetterName() != null) {
  +            getGetterName().write(node.addNewGetter());
  +        }
  +        if (getSetterName() != null) {
  +            getSetterName().write(node.addNewSetter());
  +        }
  +        if (getCollectionClass() != null)
  +            node.setCollection(getCollectionClass().toString());
  +
  +        if (javaInstanceFactory != null) {
  +            org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory jif_node =
  +                node.addNewFactory();
  +            javaInstanceFactory.write(jif_node);
  +        }
  +
  +        return node;
  +    }
  +
  +    // ========================================================================
  +    // Public methods
  +
  +    public boolean isField()
  +    {
  +        return field != null;
  +    }
  +
  +    public BindingTypeName getTypeName()
  +    {
  +        return btName;
  +    }
  +
  +    public void setBindingType(BindingType bType)
  +    {
  +        btName = bType.getName();
  +    }
  +
  +    public MethodName getGetterName()
  +    {
  +        return isField() ? null : getter;
  +    }
  +
  +    public void setGetterName(MethodName mn)
  +    {
  +        getter = mn;
  +    }
  +
  +    public boolean hasSetter()
  +    {
  +        return !isField() && setter != null;
  +    }
  +
  +    public MethodName getSetterName()
  +    {
  +        return isField() ? null : setter;
  +    }
  +
  +    public void setSetterName(MethodName mn)
  +    {
  +        setter = mn;
  +    }
  +
  +    public boolean hasIssetter()
  +    {
  +        return !isField() && issetter != null;
  +    }
  +
  +    public MethodName getIssetterName()
  +    {
  +        return isField() ? null : issetter;
  +    }
  +
  +    public void setIssetterName(MethodName mn)
  +    {
  +        issetter = mn;
  +    }
  +
  +    public String getFieldName()
  +    {
  +        return field;
  +    }
  +
  +    public void setFieldName(String field)
  +    {
  +        this.field = field;
  +    }
  +
  +    public JavaTypeName getCollectionClass()
  +    {
  +        return collection;
  +    }
  +
  +    public void setCollectionClass(JavaTypeName jName)
  +    {
  +        collection = jName;
  +    }
  +
  +    // ========================================================================
  +    // Static initialization
  +
  +    /* REGISTRY OF SUBCLASSES */
  +
  +    private static final Class[] ctorArgs = new Class[]{org.apache.xml.xmlbeans.bindingConfig.BindingProperty.class};
  +
  +    public static BindingProperty forNode(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node)
  +    {
  +        try {
  +            Class clazz = kinds.classForType(node.schemaType());
  +            return (BindingProperty)clazz.getConstructor(ctorArgs).newInstance(new Object[]{node});
  +        }
  +        catch (Exception e) {
  +            throw (IllegalStateException)new IllegalStateException("Cannot load class for " + node.schemaType() + ": should be registered.").initCause(e);
  +        }
  +    }
  +
  +
  +    /**
  +     * Should only be called by BindingFile, when loading up bindingtypes
  +     */
  +    static KindRegistry kinds = new KindRegistry();
  +
  +    public static void registerClassAndType(Class clazz, SchemaType type)
  +    {
  +        if (!BindingProperty.class.isAssignableFrom(clazz))
  +            throw new IllegalArgumentException("Classes must inherit from BindingProperty");
  +        if (!org.apache.xml.xmlbeans.bindingConfig.BindingProperty.type.isAssignableFrom(type))
  +            throw new IllegalArgumentException("Schema types must inherit from binding-property");
  +        kinds.registerClassAndType(clazz, type);
  +    }
  +
  +    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);
  +    }
  +
  +    public String toString()
  +    {
  +        return getClass().getName() + " [" + getGetterName().getSimpleName() + "]";
  +    }
  +
  +    public JavaInstanceFactory getJavaInstanceFactory()
  +    {
  +        return javaInstanceFactory;
  +    }
  +
  +    public void setJavaInstanceFactory(JavaInstanceFactory javaInstanceFactory)
  +    {
  +        this.javaInstanceFactory = javaInstanceFactory;
  +    }
   }
  
  
  
  1.3       +2 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JaxrpcEnumType.java
  
  Index: JaxrpcEnumType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JaxrpcEnumType.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JaxrpcEnumType.java	21 Mar 2004 01:58:27 -0000	1.2
  +++ JaxrpcEnumType.java	25 Mar 2004 03:19:28 -0000	1.3
  @@ -18,8 +18,8 @@
   import org.apache.xmlbeans.XmlException;
   
   /**
  - * A binding of a simple user-defined type that operates by
  - * delegating to another well-known (e.g., builtin) binding.
  + * A representation of the JAX-RPC 1.1 rules for binding a
  + * schema enumeration into java
    */
   public class JaxrpcEnumType extends BindingType
   {
  
  
  
  1.6       +123 -105  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/QNameProperty.java
  
  Index: QNameProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/QNameProperty.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- QNameProperty.java	12 Feb 2004 20:06:06 -0000	1.5
  +++ QNameProperty.java	25 Mar 2004 03:19:28 -0000	1.6
  @@ -23,113 +23,131 @@
    * A property that addresses an XML element or attribute by name
    * rather than by position.
    */
  -public class QNameProperty extends BindingProperty {
  +public class QNameProperty extends BindingProperty
  +{
   
  -  // ========================================================================
  -  // Variables
  +    // ========================================================================
  +    // Variables
   
  -  private QName theName;
  -  private boolean isAttribute;
  -  private boolean isMultiple;
  -  private boolean isOptional;
  -  private boolean isNillable;
  -  private String defaultValue;
  -
  -  // ========================================================================
  -  // Constructors
  -
  -  public QNameProperty() {
  -    super();
  -  }
  -
  -  public QNameProperty(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node) {
  -    super(node);
  -    org.apache.xml.xmlbeans.bindingConfig.QnameProperty qpNode =
  -            (org.apache.xml.xmlbeans.bindingConfig.QnameProperty) node;
  -    theName = qpNode.getQname();
  -    isAttribute = qpNode.getAttribute();
  -    isMultiple = qpNode.getMultiple();
  -    isNillable = qpNode.getNillable();
  -    isOptional = qpNode.getOptional();
  -    defaultValue = qpNode.getDefault();
  -  }
  -
  -  // ========================================================================
  -  // Public methods
  -
  -  public QName getQName() {
  -    return theName;
  -  }
  -
  -  public void setQName(QName theName) {
  -    this.theName = theName;
  -  }
  -
  -  public boolean isAttribute() {
  -    return isAttribute;
  -  }
  -
  -  public void setAttribute(boolean attribute) {
  -    isAttribute = attribute;
  -  }
  -
  -  public boolean isMultiple() {
  -    return isMultiple;
  -  }
  -
  -  public void setMultiple(boolean multiple) {
  -    isMultiple = multiple;
  -  }
  -
  -  public boolean isOptional() {
  -    return isOptional;
  -  }
  -
  -  public void setOptional(boolean optional) {
  -    isOptional = optional;
  -  }
  -
  -  public boolean isNillable() {
  -    return isNillable;
  -  }
  -
  -  public void setNillable(boolean nillable) {
  -    isNillable = nillable;
  -  }
  -
  -  public String getDefault() {
  -    return defaultValue;
  -  }
  -
  -  public void setDefault(String default_value) {
  -    defaultValue = default_value;
  -  }
  -
  -  // ========================================================================
  -  // BindingType implementation
  -
  -  /**
  -   * This function copies an instance back out to the relevant part of the XML file.
  -   *
  -   * Subclasses should override and call super.write first.
  -   */
  -  protected org.apache.xml.xmlbeans.bindingConfig.BindingProperty write(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node) {
  -    node = super.write(node);
  -
  -    org.apache.xml.xmlbeans.bindingConfig.QnameProperty qpNode =
  -            (org.apache.xml.xmlbeans.bindingConfig.QnameProperty) node;
  -
  -    qpNode.setQname(theName);
  -    if (isAttribute)
  -      qpNode.setAttribute(true);
  -    if (isMultiple)
  -      qpNode.setMultiple(true);
  -    if (isOptional)
  -      qpNode.setOptional(true);
  -    if (isNillable)
  -      qpNode.setNillable(true);
  -    return qpNode;
  -  }
  +    private QName theName;
  +    private boolean isAttribute;
  +    private boolean isMultiple;
  +    private boolean isOptional;
  +    private boolean isNillable;
  +    private String defaultValue;
  +
  +
  +    // ========================================================================
  +    // Constructors
  +
  +    public QNameProperty()
  +    {
  +        super();
  +    }
  +
  +    public QNameProperty(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node)
  +    {
  +        super(node);
  +        org.apache.xml.xmlbeans.bindingConfig.QnameProperty qpNode =
  +            (org.apache.xml.xmlbeans.bindingConfig.QnameProperty)node;
  +        theName = qpNode.getQname();
  +        isAttribute = qpNode.getAttribute();
  +        isMultiple = qpNode.getMultiple();
  +        isNillable = qpNode.getNillable();
  +        isOptional = qpNode.getOptional();
  +        defaultValue = qpNode.getDefault();
  +    }
  +
  +    // ========================================================================
  +    // Public methods
  +
  +    public QName getQName()
  +    {
  +        return theName;
  +    }
  +
  +    public void setQName(QName theName)
  +    {
  +        this.theName = theName;
  +    }
  +
  +    public boolean isAttribute()
  +    {
  +        return isAttribute;
  +    }
  +
  +    public void setAttribute(boolean attribute)
  +    {
  +        isAttribute = attribute;
  +    }
  +
  +    public boolean isMultiple()
  +    {
  +        return isMultiple;
  +    }
  +
  +    public void setMultiple(boolean multiple)
  +    {
  +        isMultiple = multiple;
  +    }
  +
  +    public boolean isOptional()
  +    {
  +        return isOptional;
  +    }
  +
  +    public void setOptional(boolean optional)
  +    {
  +        isOptional = optional;
  +    }
  +
  +    public boolean isNillable()
  +    {
  +        return isNillable;
  +    }
  +
  +    public void setNillable(boolean nillable)
  +    {
  +        isNillable = nillable;
  +    }
  +
  +    public String getDefault()
  +    {
  +        return defaultValue;
  +    }
  +
  +    public void setDefault(String default_value)
  +    {
  +        defaultValue = default_value;
  +    }
  +
  +    // ========================================================================
  +    // BindingType implementation
  +
  +    /**
  +     * This function copies an instance back out to the relevant part of the XML file.
  +     *
  +     * Subclasses should override and call super.write first.
  +     */
  +    protected org.apache.xml.xmlbeans.bindingConfig.BindingProperty write(org.apache.xml.xmlbeans.bindingConfig.BindingProperty node)
  +    {
  +        node = super.write(node);
  +
  +        org.apache.xml.xmlbeans.bindingConfig.QnameProperty qpNode =
  +            (org.apache.xml.xmlbeans.bindingConfig.QnameProperty)node;
  +
  +        qpNode.setQname(theName);
  +        if (isAttribute)
  +            qpNode.setAttribute(true);
  +        if (isMultiple)
  +            qpNode.setMultiple(true);
  +        if (isOptional)
  +            qpNode.setOptional(true);
  +        if (isNillable)
  +            qpNode.setNillable(true);
  +
  +        return qpNode;
  +    }
   
   
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JavaInstanceFactory.java
  
  Index: JavaInstanceFactory.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.binding.bts;
  
  import org.apache.xmlbeans.SchemaType;
  
  /**
   Represents a description of a factory that is used to create java objects
   */
  public abstract class JavaInstanceFactory
  {
  
      // ========================================================================
      // Variables
  
      // ========================================================================
      // Constructors
  
      /**
       * This kind of constructor is used when making a new one out of the blue.
       *
       * Subclasses should call super(..) when defining constructors that init new JavaInstanceFactory
       */
      protected JavaInstanceFactory()
      {
      }
  
      /**
       * This constructor loads an instance from an XML file
       *
       * Subclasses should have ctors of the same signature and call super(..) first.
       */
      protected JavaInstanceFactory(org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory node)
      {
  
      }
  
      // ========================================================================
      // Protected methods
  
      /**
       * This function copies an instance back out to the relevant part of the XML file.
       *
       * Subclasses should override and call super.write first.
       */
      protected org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory write(org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory node)
      {
          node = (org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory)node.changeType(kinds.typeForClass(this.getClass()));
  
          return node;
      }
  
      // ========================================================================
      // Public methods
  
  
      // ========================================================================
      // Static initialization
  
      /* REGISTRY OF SUBCLASSES */
  
      private static final Class[] ctorArgs =
          new Class[]{org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory.class};
  
      public static JavaInstanceFactory forNode(org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory node)
      {
          assert node != null;
          try {
              Class clazz = kinds.classForType(node.schemaType());
              return (JavaInstanceFactory)clazz.getConstructor(ctorArgs).newInstance(new Object[]{node});
          }
          catch (Exception e) {
              String msg = "Cannot load class for " + node.schemaType() +
                  ": should be registered.";
              throw (IllegalStateException)new IllegalStateException(msg).initCause(e);
          }
      }
  
  
      /**
       * Should only be called by BindingFile, when loading up bindingtypes
       */
      static KindRegistry kinds = new KindRegistry();
  
      public static void registerClassAndType(Class clazz, SchemaType type)
      {
          if (!JavaInstanceFactory.class.isAssignableFrom(clazz))
              throw new IllegalArgumentException("Classes must inherit from JavaInstanceFactory: " + clazz);
          if (!org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory.type.isAssignableFrom(type))
              throw new IllegalArgumentException("Schema types must inherit from java-instance-factory");
          kinds.registerClassAndType(clazz, type);
      }
  
      static
      {
          registerClassAndType(ParentInstanceFactory.class, org.apache.xml.xmlbeans.bindingConfig.ParentInstanceFactory.type);
      }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ParentInstanceFactory.java
  
  Index: ParentInstanceFactory.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.binding.bts;
  
  import org.apache.xmlbeans.impl.binding.bts.JavaInstanceFactory;
  
  
  /**
   * A property that addresses an XML element or attribute by name
   * rather than by position.
   */
  public class ParentInstanceFactory extends JavaInstanceFactory
  {
  
      // ========================================================================
      // Variables
      private MethodName createObjectMethod;
  
      // ========================================================================
      // Constructors
  
      public ParentInstanceFactory()
      {
          super();
      }
  
      public ParentInstanceFactory(org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory node)
      {
          super(node);
          org.apache.xml.xmlbeans.bindingConfig.ParentInstanceFactory pifNode =
              (org.apache.xml.xmlbeans.bindingConfig.ParentInstanceFactory)node;
          this.createObjectMethod =
              MethodName.create(pifNode.getCreateObjectMethod());
      }
  
      // ========================================================================
      // Public methods
      public MethodName getCreateObjectMethod()
      {
          return createObjectMethod;
      }
  
      public void setCreateObjectMethod(MethodName createObjectMethod)
      {
          this.createObjectMethod = createObjectMethod;
      }
  
      // ========================================================================
      // BindingType implementation
  
      /**
       * This function copies an instance back out to the relevant part of the XML file.
       *
       * Subclasses should override and call super.write first.
       */
      protected org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory write(org.apache.xml.xmlbeans.bindingConfig.JavaInstanceFactory node)
      {
          node = super.write(node);
  
          org.apache.xml.xmlbeans.bindingConfig.ParentInstanceFactory pifNode =
              (org.apache.xml.xmlbeans.bindingConfig.ParentInstanceFactory)node;
  
          if (createObjectMethod != null) {
              createObjectMethod.write(pifNode.addNewCreateObjectMethod());
          }
  
          return pifNode;
      }
  
  
  }
  
  
  
  1.18      +26 -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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- binding-config.xsd	13 Mar 2004 03:46:57 -0000	1.17
  +++ binding-config.xsd	25 Mar 2004 03:19:28 -0000	1.18
  @@ -151,8 +151,34 @@
           <xs:element name="static" type="tns:java-field-name"/>
         </xs:choice>
         <xs:element name="collection" type="tns:java-class-name" minOccurs="0"/>
  +      <xs:element name="factory" type="tns:java-instance-factory" minOccurs="0"/>
       </xs:sequence>
     </xs:complexType>
  +
  +  <xs:complexType name="java-instance-factory" abstract="true">
  +    <xs:sequence>
  +    </xs:sequence>
  +  </xs:complexType>
  +
  +  <xs:complexType name="parent-instance-factory">
  +    <xs:complexContent>
  +      <xs:extension base="tns:java-instance-factory">
  +        <xs:sequence>
  +          <xs:element name="create-object-method" type="tns:java-method-name">
  +            <xs:annotation>
  +              <xs:documentation>
  +                The create method will not be static, and will be invoked on
  +                the parent object.  It can optionally have one argument, which
  +                will be of type java.lang.Class.  The runtime will pass the java
  +                class to be created.
  +              </xs:documentation>
  +            </xs:annotation>
  +          </xs:element>
  +        </xs:sequence>
  +      </xs:extension>
  +    </xs:complexContent>
  +  </xs:complexType>
  +
   
     <!--  type must be a simple or builtin type-->
     <xs:complexType name="simple-content-property">
  
  
  
  1.3       +38 -35    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeRuntimeBindingType.java
  
  Index: AttributeRuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeRuntimeBindingType.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AttributeRuntimeBindingType.java	10 Mar 2004 06:42:19 -0000	1.2
  +++ AttributeRuntimeBindingType.java	25 Mar 2004 03:19:28 -0000	1.3
  @@ -30,7 +30,6 @@
    */
   abstract class AttributeRuntimeBindingType
       extends RuntimeBindingType
  -    implements IntermediateResolver
   {
       private final AttributeQNameProperty[] attributeProperties;
       private final boolean hasDefaultAttributes;  //has any attributes with defaults
  @@ -65,15 +64,11 @@
           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)
  +    void initialize(RuntimeBindingTypeTable typeTable,
  +                    BindingLoader loader,
  +                    RuntimeTypeFactory rttFactory)
           throws XmlException
       {
           int att_idx = 0;
  @@ -115,6 +110,13 @@
   
       protected abstract Object createIntermediary(UnmarshalResult context);
   
  +    //some subclass will certainly need to override this
  +    protected Object createIntermediary(UnmarshalResult context,
  +                                        Object actual_object)
  +    {
  +        return actual_object;
  +    }
  +
       protected abstract Object getFinalObjectFromIntermediary(Object retval,
                                                                UnmarshalResult context)
           throws XmlException;
  @@ -131,7 +133,7 @@
                                                                 UnmarshalResult context)
       {
           for (int i = 0, len = attributeProperties.length; i < len; i++) {
  -            final QNamePropertyBase prop = attributeProperties[i];
  +            final QNameRuntimeProperty prop = attributeProperties[i];
   
               if (doesPropMatch(uri, localname, prop)) {
                   if (hasDefaultAttributes && (prop.typedDefaultValue != null)) {
  @@ -145,7 +147,7 @@
   
       private static boolean doesPropMatch(String uri,
                                            String localname,
  -                                         QNamePropertyBase prop)
  +                                         QNameRuntimeProperty prop)
       {
           assert localname != null;
   
  @@ -154,21 +156,21 @@
           return UnmarshalResult.doesElementMatch(qn, localname, uri);
       }
   
  -    public abstract int getElementPropertyCount();
  +    abstract int getElementPropertyCount();
   
  -    public final int getAttributePropertyCount()
  +    final int getAttributePropertyCount()
       {
           return attributeProperties.length;
       }
   
  -    public final void fillDefaultAttributes(Object inter,
  -                                            UnmarshalResult context)
  +    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];
  +            final QNameRuntimeProperty p = attributeProperties[aidx];
   
               if (p.typedDefaultValue == null) continue;
               if (context.isAttributePresent(aidx)) continue;
  @@ -180,19 +182,19 @@
       protected abstract boolean hasMulti();
   
       protected static final class AttributeQNameProperty
  -        extends QNamePropertyBase
  +        extends QNameRuntimeProperty
       {
           AttributeQNameProperty(Class beanClass,
                                  boolean bean_has_multis,
                                  QNameProperty prop,
  -                               IntermediateResolver intermediateResolver,
  +                               RuntimeBindingType containing_type,
                                  RuntimeBindingTypeTable typeTable,
                                  BindingLoader loader,
                                  RuntimeTypeFactory rttFactory)
               throws XmlException
           {
               super(beanClass, bean_has_multis,
  -                  prop, intermediateResolver, typeTable, loader, rttFactory);
  +                  prop, containing_type, typeTable, loader, rttFactory);
               assert prop.isAttribute();
           }
   
  @@ -207,24 +209,24 @@
       }
   
   
  -    protected static abstract class QNamePropertyBase
  -        extends RuntimePropertyBase
  +    protected static abstract class QNameRuntimeProperty
  +        extends BeanRuntimeProperty
       {
           protected final boolean beanHasMulti;          //consider a subclass
           protected final QNameProperty bindingProperty;
           protected final String lexicalDefaultValue;
           protected final Object typedDefaultValue;
   
  -        QNamePropertyBase(Class beanClass,
  -                          boolean bean_has_multis,
  -                          QNameProperty prop,
  -                          IntermediateResolver intermediateResolver,
  -                          RuntimeBindingTypeTable typeTable,
  -                          BindingLoader loader,
  -                          RuntimeTypeFactory rttFactory)
  +        QNameRuntimeProperty(Class beanClass,
  +                             boolean bean_has_multis,
  +                             QNameProperty prop,
  +                             RuntimeBindingType containing_type,
  +                             RuntimeBindingTypeTable typeTable,
  +                             BindingLoader loader,
  +                             RuntimeTypeFactory rttFactory)
               throws XmlException
           {
  -            super(beanClass, prop, intermediateResolver, typeTable, loader, rttFactory);
  +            super(beanClass, prop, containing_type, typeTable, loader, rttFactory);
   
               if (prop.getQName() == null) {
                   final String msg = "property " + prop + " of " +
  @@ -243,16 +245,17 @@
               } else {
                   typedDefaultValue = null;
               }
  +
           }
   
   
  -        public final QName getName()
  +        final QName getName()
           {
               return bindingProperty.getQName();
           }
   
   
  -        public final void fillDefaultValue(Object inter)
  +        final void fillDefaultValue(Object inter)
               throws XmlException
           {
               assert (typedDefaultValue != null);
  @@ -260,25 +263,25 @@
               this.fill(inter, typedDefaultValue);
           }
   
  -        public final void fillCollection(final Object inter,
  -                                         final Object prop_obj)
  +        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()
  +        final boolean isMultiple()
           {
               return bindingProperty.isMultiple();
           }
   
  -        public final boolean isNillable()
  +        final boolean isNillable()
           {
               return bindingProperty.isNillable();
           }
   
  -        public final String getLexicalDefault()
  +        final String getLexicalDefault()
           {
               return lexicalDefaultValue;
           }
  
  
  
  1.3       +22 -2     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeUnmarshaller.java
  
  Index: AttributeUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeUnmarshaller.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AttributeUnmarshaller.java	10 Mar 2004 06:42:19 -0000	1.2
  +++ AttributeUnmarshaller.java	25 Mar 2004 03:19:28 -0000	1.3
  @@ -18,7 +18,8 @@
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   
  -abstract class AttributeUnmarshaller implements TypeUnmarshaller
  +abstract class AttributeUnmarshaller
  +    implements TypeUnmarshaller
   {
       private final AttributeRuntimeBindingType type;
   
  @@ -36,12 +37,31 @@
           return type.getFinalObjectFromIntermediary(inter, context);
       }
   
  +    public void unmarshal(Object object, UnmarshalResult context)
  +        throws XmlException
  +    {
  +        final Object inter = type.createIntermediary(context, object);
  +        deserializeAttributes(inter, context);
  +        deserializeContents(inter, context);
  +
  +        //this is needed to fill in all the array props
  +        type.getFinalObjectFromIntermediary(inter, context);
  +    }
  +
       public Object unmarshalAttribute(UnmarshalResult context)
       {
           throw new UnsupportedOperationException("not an attribute: " +
                                                   type.getSchemaTypeName());
       }
   
  +
  +    public void unmarshalAttribute(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not an attribute: " +
  +                                                type.getSchemaTypeName());
  +    }
  +
       protected abstract void deserializeContents(Object inter,
                                                   UnmarshalResult context)
           throws XmlException;
  @@ -54,7 +74,7 @@
               RuntimeBindingProperty prop = findMatchingAttributeProperty(context);
   
               if (prop != null) {
  -                UnmarshalResult.fillAttributeProp(prop, context, inter);
  +                prop.extractAndFillAttributeProp(context, inter);
               }
   
               context.advanceAttribute();
  
  
  
  1.9       +16 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BaseSimpleTypeConverter.java
  
  Index: BaseSimpleTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BaseSimpleTypeConverter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BaseSimpleTypeConverter.java	12 Feb 2004 20:06:16 -0000	1.8
  +++ BaseSimpleTypeConverter.java	25 Mar 2004 03:19:28 -0000	1.9
  @@ -51,7 +51,23 @@
           }
       }
   
  +    public void unmarshal(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this="+this);
  +    }
  +
  +    //subclass should override this where appropriate
  +    public void unmarshalAttribute(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
  +    }
  +
  +
       protected abstract Object getObject(UnmarshalResult context)
           throws XmlException;
  +
  +
   
   }
  
  
  
  1.37      +37 -12    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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- ByNameRuntimeBindingType.java	10 Mar 2004 06:42:19 -0000	1.36
  +++ ByNameRuntimeBindingType.java	25 Mar 2004 03:19:28 -0000	1.37
  @@ -63,7 +63,7 @@
       }
   
   
  -    public Object getObjectFromIntermediate(Object inter)
  +    Object getObjectFromIntermediate(Object inter)
       {
           if (hasMulti()) {
               UResultHolder res = (UResultHolder)inter;
  @@ -102,6 +102,17 @@
           }
       }
   
  +    //some subclass will certainly need to override this
  +    protected Object createIntermediary(UnmarshalResult context,
  +                                        Object actual_object)
  +    {
  +        if (hasMulti) {
  +            return new UResultHolder(this, actual_object);
  +        } else {
  +            return actual_object;
  +        }
  +    }
  +
       protected Object getFinalObjectFromIntermediary(Object retval,
                                                       UnmarshalResult context)
           throws XmlException
  @@ -114,6 +125,7 @@
           }
       }
   
  +
       RuntimeBindingProperty getElementProperty(int index)
       {
           return elementProperties[index];
  @@ -135,7 +147,7 @@
   
       private static boolean doesPropMatch(String uri,
                                            String localname,
  -                                         QNamePropertyBase prop)
  +                                         QNameRuntimeProperty prop)
       {
           assert localname != null;
   
  @@ -156,7 +168,7 @@
   
   
       protected static final class ElementQNameProperty
  -        extends QNamePropertyBase
  +        extends QNameRuntimeProperty
       {
           protected final int propertyIndex;
   
  @@ -164,14 +176,14 @@
                                Class beanClass,
                                boolean bean_has_multis,
                                QNameProperty prop,
  -                             IntermediateResolver intermediateResolver,
  +                             RuntimeBindingType containing_type,
                                RuntimeBindingTypeTable typeTable,
                                BindingLoader loader,
                                RuntimeTypeFactory rttFactory)
               throws XmlException
           {
               super(beanClass, bean_has_multis,
  -                  prop, intermediateResolver, typeTable, loader, rttFactory);
  +                  prop, containing_type, typeTable, loader, rttFactory);
               propertyIndex = property_index;
               assert !prop.isAttribute();
           }
  @@ -193,10 +205,11 @@
                       rh.addItem(propertyIndex, prop_obj);
                   } else {
                       ReflectionUtils.invokeMethod(rh.getValue(), setMethod,
  -                                 new Object[]{prop_obj});
  +                                                 new Object[]{prop_obj});
                   }
               } else {
  -                ReflectionUtils.invokeMethod(inter, setMethod, new Object[]{prop_obj});
  +                ReflectionUtils.invokeMethod(inter, setMethod,
  +                                             new Object[]{prop_obj});
               }
           }
   
  @@ -211,19 +224,25 @@
   
           UResultHolder(ByNameRuntimeBindingType type)
           {
  +            this(type, ClassLoadingUtils.newInstance(type.getJavaType()));
  +        }
  +
  +        UResultHolder(ByNameRuntimeBindingType type, Object actual_obj)
  +        {
               runtimeBindingType = type;
  -            value = ClassLoadingUtils.newInstance(type.getJavaType());
  +            value = actual_obj;
           }
   
   
           Object getFinalValue() throws XmlException
           {
               if (accumulators != null) {
  -                final QNamePropertyBase[] props = runtimeBindingType.elementProperties;
  +                final QNameRuntimeProperty[] props =
  +                    runtimeBindingType.elementProperties;
                   for (int i = 0, len = accumulators.length; i < len; i++) {
                       final Accumulator accum = accumulators[i];
                       if (accum != null) {
  -                        final QNamePropertyBase prop = props[i];
  +                        final QNameRuntimeProperty prop = props[i];
                           prop.fillCollection(value, accum.getFinalArray());
                       }
                   }
  @@ -245,16 +264,22 @@
                   accumulators = accs;
               }
               if (accs[elem_idx] == null) {
  -                final QNamePropertyBase p = runtimeBindingType.elementProperties[elem_idx];
  +                final QNameRuntimeProperty p =
  +                    runtimeBindingType.elementProperties[elem_idx];
                   accs[elem_idx] =
                       AccumulatorFactory.createAccumulator(p.propertyClass,
                                                            p.collectionElementClass);
               }
           }
   
  -        public Object getValue()
  +        Object getValue()
           {
               return value;
  +        }
  +
  +        public Object getActualObject()
  +        {
  +            return null;
           }
   
       }
  
  
  
  1.19      +1 -2      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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ByNameUnmarshaller.java	10 Mar 2004 06:42:19 -0000	1.18
  +++ ByNameUnmarshaller.java	25 Mar 2004 03:19:28 -0000	1.19
  @@ -45,7 +45,7 @@
                   context.skipElement();
               } else {
                   //TODO: implement first one wins?, this is last one wins
  -                UnmarshalResult.fillElementProp(prop, context, inter);
  +                prop.extractAndFillElementProp(context, inter);
               }
           }
   
  @@ -67,7 +67,6 @@
           String lname = context.getLocalName();
           return byNameType.getMatchingElementProperty(uri, lname);
       }
  -
   
   
   }
  
  
  
  1.5       +0 -5      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/EmptyLocation.java
  
  Index: EmptyLocation.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/EmptyLocation.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EmptyLocation.java	12 Feb 2004 20:06:16 -0000	1.4
  +++ EmptyLocation.java	25 Mar 2004 03:19:28 -0000	1.5
  @@ -46,11 +46,6 @@
           return -1;
       }
   
  -    public String getLocationURI()
  -    {
  -        return null;
  -    }
  -
       public String getPublicId()
       {
           return null;
  
  
  
  1.2       +13 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumUnmarshaller.java
  
  Index: JaxrpcEnumUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumUnmarshaller.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JaxrpcEnumUnmarshaller.java	13 Mar 2004 03:46:57 -0000	1.1
  +++ JaxrpcEnumUnmarshaller.java	25 Mar 2004 03:19:28 -0000	1.2
  @@ -78,12 +78,25 @@
           return runtimeType.fromValue(itemValue);
       }
   
  +    public void unmarshal(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
  +    }
  +
  +
       public Object unmarshalAttribute(UnmarshalResult result)
           throws XmlException
       {
           final TypeUnmarshaller item_um = runtimeType.getItemUnmarshaller();
           final Object itemValue = item_um.unmarshalAttribute(result);
           return runtimeType.fromValue(itemValue);
  +    }
  +
  +    public void unmarshalAttribute(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
       }
   
       public void initialize(RuntimeBindingTypeTable typeTable,
  
  
  
  1.23      +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshallerImpl.java
  
  Index: MarshallerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshallerImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- MarshallerImpl.java	18 Mar 2004 23:25:35 -0000	1.22
  +++ MarshallerImpl.java	25 Mar 2004 03:19:28 -0000	1.23
  @@ -215,7 +215,7 @@
           }
       }
   
  -    private XMLStreamWriter createXmlStreamWriter(OutputStream out,
  +    private static XMLStreamWriter createXmlStreamWriter(OutputStream out,
                                                     final String encoding)
           throws XMLStreamException
       {
  
  
  
  1.8       +12 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/NullUnmarshaller.java
  
  Index: NullUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/NullUnmarshaller.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NullUnmarshaller.java	12 Feb 2004 20:06:16 -0000	1.7
  +++ NullUnmarshaller.java	25 Mar 2004 03:19:28 -0000	1.8
  @@ -38,9 +38,21 @@
           return null;
       }
   
  +    public void unmarshal(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
  +    }
  +
       public Object unmarshalAttribute(UnmarshalResult context)
       {
           throw new UnsupportedOperationException();
  +    }
  +
  +    public void unmarshalAttribute(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
       }
   
       public void initialize(RuntimeBindingTypeTable typeTable,
  
  
  
  1.2       +13 -1     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ObjectAnyTypeConverter.java
  
  Index: ObjectAnyTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ObjectAnyTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectAnyTypeConverter.java	19 Feb 2004 18:43:56 -0000	1.1
  +++ ObjectAnyTypeConverter.java	25 Mar 2004 03:19:28 -0000	1.2
  @@ -59,7 +59,7 @@
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   
  -public class ObjectAnyTypeConverter
  +public final class ObjectAnyTypeConverter
       implements TypeConverter
   {
       public ObjectAnyTypeConverter()
  @@ -73,10 +73,22 @@
           throw new AssertionError("GENERIC XML UNIMPLEMENTED");
       }
   
  +    public void unmarshal(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
  +    }
  +
       public Object unmarshalAttribute(UnmarshalResult result)
           throws XmlException
       {
           throw new AssertionError("unused");
  +    }
  +
  +    public void unmarshalAttribute(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
       }
   
       public void initialize(RuntimeBindingTypeTable typeTable,
  
  
  
  1.17      +198 -15   xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingProperty.java
  
  Index: RuntimeBindingProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingProperty.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- RuntimeBindingProperty.java	2 Mar 2004 02:54:07 -0000	1.16
  +++ RuntimeBindingProperty.java	25 Mar 2004 03:19:28 -0000	1.17
  @@ -16,45 +16,228 @@
   package org.apache.xmlbeans.impl.marshal;
   
   import org.apache.xmlbeans.XmlException;
  +import org.apache.xmlbeans.impl.common.InvalidLexicalValueException;
  +import org.apache.xmlbeans.impl.binding.bts.BindingProperty;
  +import org.apache.xmlbeans.impl.binding.bts.JavaInstanceFactory;
  +import org.apache.xmlbeans.impl.binding.bts.ParentInstanceFactory;
  +import org.apache.xmlbeans.impl.binding.bts.MethodName;
  +import org.apache.xmlbeans.impl.binding.bts.BindingType;
  +import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils;
   
   import javax.xml.namespace.QName;
  +import java.lang.reflect.Method;
   
   
  -interface RuntimeBindingProperty
  +abstract class RuntimeBindingProperty
   {
  -    RuntimeBindingType getRuntimeBindingType();
  +    protected final RuntimeBindingType containingType;
   
  -    RuntimeBindingType getActualRuntimeType(Object property_value,
  -                                            MarshalResult result)
  -        throws XmlException;
  +    //TODO: when we have other types of factories,
  +    //this will need to more general
  +    private final Method parentFactoryMethod;
  +    private final boolean parentFactoryMethodTakesClassArg;
  +
  +    protected RuntimeBindingProperty(RuntimeBindingType containingType)
  +    {
  +        this.containingType = containingType;
  +        parentFactoryMethod = null;
  +        parentFactoryMethodTakesClassArg = false;
  +    }
  +
  +    protected RuntimeBindingProperty(BindingProperty prop,
  +                                     RuntimeBindingType containingType)
  +        throws XmlException
  +    {
  +        this.containingType = containingType;
  +        final JavaInstanceFactory jif = prop.getJavaInstanceFactory();
  +        if (jif == null) {
  +            parentFactoryMethod = null;
  +            parentFactoryMethodTakesClassArg = false;
  +        } else {
  +            if (jif instanceof ParentInstanceFactory) {
  +                ParentInstanceFactory pif = (ParentInstanceFactory)jif;
  +                final MethodName create_method = pif.getCreateObjectMethod();
  +                final Class container_class = containingType.getJavaType();
  +                parentFactoryMethod =
  +                    ReflectionUtils.getMethodOnClass(create_method,
  +                                                     container_class);
  +                Class[] param_types = parentFactoryMethod.getParameterTypes();
  +                if (param_types.length > 1) {
  +                    String msg = "too many args for parent factory method: " +
  +                        parentFactoryMethod;
  +                    throw new XmlException(msg);
  +                }
  +                if (param_types.length == 1 && !Class.class.equals(param_types[0])) {
  +                    String msg = "arg must be java.lang.Class for " +
  +                        "parent factory method: " + parentFactoryMethod;
  +                    throw new XmlException(msg);
  +                }
  +
  +                parentFactoryMethodTakesClassArg = param_types.length > 0;
  +            } else {
  +                throw new AssertionError("FACTORY UNIMP: " + jif);
  +            }
  +        }
  +    }
   
  -    QName getName();
  +    abstract RuntimeBindingType getRuntimeBindingType();
   
  -    TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  +    abstract RuntimeBindingType getActualRuntimeType(Object property_value,
  +                                                     MarshalResult result)
           throws XmlException;
   
  -    void fill(Object inter, Object prop_obj)
  -        throws XmlException;
  +    abstract QName getName();
   
       //non simple type props can throw an exception
  -    CharSequence getLexical(Object parent, MarshalResult result)
  +    abstract CharSequence getLexical(Object parent, MarshalResult result)
           throws XmlException;
   
  -    Object getValue(Object parentObject, MarshalResult result)
  +    abstract Object getValue(Object parentObject, MarshalResult result)
           throws XmlException;
   
  -    boolean isSet(Object parentObject, MarshalResult result)
  +    abstract boolean isSet(Object parentObject, MarshalResult result)
           throws XmlException;
   
  -    boolean isMultiple();
  +    abstract boolean isMultiple();
   
  -    boolean isNillable();
  +    abstract boolean isNillable();
   
       /**
        * returns null if this property has no default
        *
        * @return
        */
  -    String getLexicalDefault();
  +    abstract String getLexicalDefault();
  +
  +    final void extractAndFillAttributeProp(UnmarshalResult context,
  +                                           Object inter)
  +        throws XmlException
  +    {
  +        final TypeUnmarshaller um = this.getTypeUnmarshaller(context);
  +        assert um != null;
  +
  +        try {
  +            final Object this_val;
  +            if (hasFactory()) {
  +                final Object actual_obj =
  +                    containingType.getObjectFromIntermediate(inter);
  +                if (parentFactoryMethodTakesClassArg) {
  +                    this_val =
  +                        createObjectViaFactory(actual_obj,
  +                                               getRuntimeBindingType().getJavaType());
  +                } else {
  +                    this_val = createObjectViaFactory(actual_obj);
  +                }
  +                um.unmarshalAttribute(this_val, context);
  +            } else {
  +                this_val = um.unmarshalAttribute(context);
  +            }
  +            fill(inter, this_val);
  +        }
  +        catch (InvalidLexicalValueException ilve) {
  +            String msg = "invalid value for " + this.getName() +
  +                ": " + ilve.getMessage();
  +            context.addError(msg, ilve.getLocation());
  +        }
  +    }
  +
  +    final void extractAndFillElementProp(final UnmarshalResult context,
  +                                         Object inter)
  +        throws XmlException
  +    {
  +        try {
  +            final String lexical_default = this.getLexicalDefault();
  +            if (lexical_default != null) {
  +                context.setNextElementDefault(lexical_default);
  +            }
  +            final Object this_val;
  +            if (hasFactory()) {
  +                final TypeUnmarshaller um;
  +                final Class actual_prop_class;
  +                final QName xsi_type = context.getXsiType();
  +                if (xsi_type == null) {
  +                    //REVIEW: we're doing a little extra work here
  +                    um = this.getTypeUnmarshaller(context);
  +                    actual_prop_class =
  +                        this.getRuntimeBindingType().getJavaType();
  +                } else {
  +                    final BindingType actual_binding_type =
  +                        context.lookupBindingType(xsi_type);
  +                    if (actual_binding_type != null) {
  +                        um = context.getTypeUnmarshaller(actual_binding_type);
  +                        actual_prop_class =
  +                            context.getRuntimeType(actual_binding_type).getJavaType();
  +                    } else {
  +                        um = this.getTypeUnmarshaller(context);
  +                        actual_prop_class =
  +                            this.getRuntimeBindingType().getJavaType();
  +                    }
  +                }
  +                if (um == null) {
  +                    //there was a big problem looking up the type,
  +                    //so just skip this element
  +                    context.skipElement();
  +                    return;
  +                }
  +                final Object actual_obj =
  +                    containingType.getObjectFromIntermediate(inter);
  +                if (parentFactoryMethodTakesClassArg) {
  +                    this_val = createObjectViaFactory(actual_obj,
  +                                                      actual_prop_class);
  +                } else {
  +                    //TODO: avoid some of the lookups if we know we have this kind
  +                    //of factory
  +                    this_val = createObjectViaFactory(actual_obj);
  +                }
  +                um.unmarshal(this_val, context);
  +            } else {
  +                this_val = this.getTypeUnmarshaller(context).unmarshal(context);
  +            }
  +            fill(inter, this_val);
  +        }
  +        catch (InvalidLexicalValueException ilve) {
  +            //unlike attributes, the error has been added to the context
  +            //already via BaseSimpleTypeConveter...
  +        }
  +    }
  +
  +    private Object createObjectViaFactory(Object parent,
  +                                          Class actual_prop_class)
  +        throws XmlException
  +    {
  +        assert parent != null;
  +        assert parentFactoryMethod != null;
  +        assert parentFactoryMethodTakesClassArg;
  +
  +        return ReflectionUtils.invokeMethod(parent,
  +                                            parentFactoryMethod,
  +                                            new Object[]{actual_prop_class});
  +    }
  +
  +    private Object createObjectViaFactory(Object parent)
  +        throws XmlException
  +    {
  +        assert parent != null;
  +        assert parentFactoryMethod != null;
  +        assert !parentFactoryMethodTakesClassArg;
  +
  +        return ReflectionUtils.invokeMethod(parent,
  +                                            parentFactoryMethod,
  +                                            null);
  +    }
  +
  +    //these methods should be used only by this type and subclasses
  +    protected abstract void fill(Object inter, Object prop_obj)
  +        throws XmlException;
  +
  +    protected abstract TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  +        throws XmlException;
  +
  +
  +    protected boolean hasFactory()
  +    {
  +        return parentFactoryMethod != null;
  +    }
  +
   
   }
  
  
  
  1.15      +23 -16    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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- RuntimeBindingType.java	18 Mar 2004 23:25:35 -0000	1.14
  +++ RuntimeBindingType.java	25 Mar 2004 03:19:28 -0000	1.15
  @@ -63,6 +63,10 @@
           javaFinal = ReflectionUtils.isClassFinal(javaClass);
       }
   
  +    Object getObjectFromIntermediate(Object inter)
  +    {
  +        return inter;
  +    }
   
       final BindingType getBindingType()
       {
  @@ -156,11 +160,11 @@
       }
   
   
  -    protected abstract static class RuntimePropertyBase
  -        implements RuntimeBindingProperty
  +    protected abstract static class BeanRuntimeProperty
  +        extends RuntimeBindingProperty
       {
           protected final Class beanClass;
  -        protected final IntermediateResolver intermediateResolver;
  +        protected final RuntimeBindingType containingType;
           protected final Method getMethod;
           protected final Method setMethod;
           protected final Method issetMethod;
  @@ -171,16 +175,17 @@
           protected final TypeMarshaller marshaller; // used only for simple types
   
   
  -        RuntimePropertyBase(Class beanClass,
  +        BeanRuntimeProperty(Class beanClass,
                               BindingProperty prop,
  -                            IntermediateResolver intermediateResolver,
  +                            RuntimeBindingType containingType,
                               RuntimeBindingTypeTable typeTable,
                               BindingLoader loader,
                               RuntimeTypeFactory rttFactory)
               throws XmlException
           {
  +            super(prop, containingType);
               this.beanClass = beanClass;
  -            this.intermediateResolver = intermediateResolver;
  +            this.containingType = containingType;
               final BindingTypeName type_name = prop.getTypeName();
               this.unmarshaller = typeTable.lookupUnmarshaller(type_name, loader);
               this.marshaller = typeTable.lookupMarshaller(type_name, loader);
  @@ -210,17 +215,18 @@
                   String e = "no setter found for " + prop + " on " + beanClass;
                   throw new XmlException(e);
               }
  +
           }
   
   
           public void fill(final Object inter, final Object prop_obj)
               throws XmlException
           {
  -            Object inst = intermediateResolver.getObjectFromIntermediate(inter);
  +            Object inst = containingType.getObjectFromIntermediate(inter);
               ReflectionUtils.invokeMethod(inst, setMethod, new Object[]{prop_obj});
           }
   
  -        public final Object getValue(Object parentObject, MarshalResult result)
  +        final Object getValue(Object parentObject, MarshalResult result)
               throws XmlException
           {
               assert parentObject != null;
  @@ -274,13 +280,13 @@
               }
           }
   
  -        public final RuntimeBindingType getRuntimeBindingType()
  +        final RuntimeBindingType getRuntimeBindingType()
           {
               return runtimeBindingType;
           }
   
  -        public final RuntimeBindingType getActualRuntimeType(Object property_value,
  -                                                             MarshalResult result)
  +        final RuntimeBindingType getActualRuntimeType(Object property_value,
  +                                                      MarshalResult result)
               throws XmlException
           {
               return MarshalResult.findActualRuntimeType(property_value,
  @@ -295,9 +301,11 @@
               return context.determineTypeUnmarshaller(unmarshaller);
           }
   
  -        public final boolean isSet(Object parentObject, MarshalResult result)
  +        final boolean isSet(Object parentObject, MarshalResult result)
               throws XmlException
           {
  +            //TODO: can we just return true if this property is not optional?
  +
               if (issetMethod == null)
                   return isSetFallback(parentObject, result);
   
  @@ -310,15 +318,14 @@
               throws XmlException
           {
               //REVIEW: nillable is winning over minOccurs="0".  Is this correct?
  -            if (isNillable())
  -                return true;
  +            if (isNillable()) return true;
   
               Object val = getValue(parentObject, result);
               return (val != null);
           }
   
  -        public final CharSequence getLexical(Object value,
  -                                             MarshalResult result)
  +        final CharSequence getLexical(Object value,
  +                                      MarshalResult result)
               throws XmlException
           {
               assert value != null :
  
  
  
  1.22      +3 -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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- RuntimeBindingTypeTable.java	13 Mar 2004 03:46:57 -0000	1.21
  +++ RuntimeBindingTypeTable.java	25 Mar 2004 03:19:28 -0000	1.22
  @@ -109,6 +109,9 @@
           return type_visitor.getUnmarshaller();
       }
   
  +    RuntimeTypeFactory getRuntimeTypeFactory() {
  +        return runtimeTypeFactory;
  +    }
   
       TypeUnmarshaller getOrCreateTypeUnmarshaller(BindingType type,
                                                    BindingLoader loader)
  
  
  
  1.16      +5 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeGlobalProperty.java
  
  Index: RuntimeGlobalProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeGlobalProperty.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- RuntimeGlobalProperty.java	2 Mar 2004 02:54:07 -0000	1.15
  +++ RuntimeGlobalProperty.java	25 Mar 2004 03:19:28 -0000	1.16
  @@ -21,7 +21,7 @@
   import javax.xml.namespace.QName;
   
   final class RuntimeGlobalProperty
  -    implements RuntimeBindingProperty
  +    extends RuntimeBindingProperty
   {
       private final QName rootElement;
       private final RuntimeBindingType runtimeBindingType;
  @@ -29,6 +29,10 @@
       public RuntimeGlobalProperty(QName rootElement,
                                    RuntimeBindingType runtimeBindingType)
       {
  +        //We can pass null becuase the global element properties never have 
  +        //a parent object, so this resolve should never be needed.
  +        //If it is somehow used we'll find out thanks to NPE.
  +        super(null);
           this.rootElement = rootElement;
           this.runtimeBindingType = runtimeBindingType;
       }
  
  
  
  1.5       +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ScopedNamespaceContext.java
  
  Index: ScopedNamespaceContext.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ScopedNamespaceContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ScopedNamespaceContext.java	12 Feb 2004 20:06:16 -0000	1.4
  +++ ScopedNamespaceContext.java	25 Mar 2004 03:19:28 -0000	1.5
  @@ -205,7 +205,7 @@
           }
       }
   
  -    private static class LLNamespaceContext
  +    private static final class LLNamespaceContext
       {
           private final String prefix;
           private final String namespace;
  
  
  
  1.2       +14 -15    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentRuntimeBindingType.java
  
  Index: SimpleContentRuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentRuntimeBindingType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleContentRuntimeBindingType.java	9 Mar 2004 23:50:53 -0000	1.1
  +++ SimpleContentRuntimeBindingType.java	25 Mar 2004 03:19:28 -0000	1.2
  @@ -25,21 +25,21 @@
   import javax.xml.namespace.QName;
   import java.util.Collection;
   
  -public class SimpleContentRuntimeBindingType
  +class SimpleContentRuntimeBindingType
       extends AttributeRuntimeBindingType
   {
       private SimpleContentRuntimeProperty simpleTypeProperty;
   
  -    public SimpleContentRuntimeBindingType(SimpleContentBean simpleContentBean)
  +    SimpleContentRuntimeBindingType(SimpleContentBean simpleContentBean)
           throws XmlException
       {
           super(simpleContentBean);
       }
   
       //prepare internal data structures for use
  -    public final void initialize(RuntimeBindingTypeTable typeTable,
  -                                 BindingLoader loader,
  -                                 RuntimeTypeFactory rttFactory)
  +    final void initialize(RuntimeBindingTypeTable typeTable,
  +                          BindingLoader loader,
  +                          RuntimeTypeFactory rttFactory)
           throws XmlException
       {
           super.initialize(typeTable, loader, rttFactory);
  @@ -85,7 +85,7 @@
           return retval;
       }
   
  -    public int getElementPropertyCount()
  +    int getElementPropertyCount()
       {
           return 0;
       }
  @@ -95,43 +95,42 @@
           return false;
       }
   
  -    public RuntimeBindingProperty getSimpleContentProperty()
  +    RuntimeBindingProperty getSimpleContentProperty()
       {
           return simpleTypeProperty;
       }
   
       private static final class SimpleContentRuntimeProperty
  -        extends RuntimePropertyBase
  +        extends BeanRuntimeProperty
       {
   
           SimpleContentRuntimeProperty(Class beanClass,
                                        BindingProperty prop,
  -                                     IntermediateResolver intermediateResolver,
  +                                     RuntimeBindingType containing_type,
                                        RuntimeBindingTypeTable typeTable,
                                        BindingLoader loader,
                                        RuntimeTypeFactory rttFactory)
               throws XmlException
           {
  -            super(beanClass, prop, intermediateResolver, typeTable, loader, rttFactory);
  -
  +            super(beanClass, prop, containing_type, typeTable, loader, rttFactory);
           }
   
  -        public QName getName()
  +        QName getName()
           {
               throw new AssertionError("prop has no name by design");
           }
   
  -        public boolean isMultiple()
  +        boolean isMultiple()
           {
               return false;
           }
   
  -        public boolean isNillable()
  +        boolean isNillable()
           {
               return false;
           }
   
  -        public String getLexicalDefault()
  +        String getLexicalDefault()
           {
               return null;
           }
  
  
  
  1.2       +2 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentUnmarshaller.java
  
  Index: SimpleContentUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentUnmarshaller.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleContentUnmarshaller.java	9 Mar 2004 23:50:53 -0000	1.1
  +++ SimpleContentUnmarshaller.java	25 Mar 2004 03:19:28 -0000	1.2
  @@ -17,7 +17,7 @@
   
   import org.apache.xmlbeans.XmlException;
   
  -public class SimpleContentUnmarshaller
  +public final class SimpleContentUnmarshaller
       extends AttributeUnmarshaller
   {
   
  @@ -30,14 +30,13 @@
       }
   
   
  -    //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);
  +        scprop.extractAndFillElementProp(context, inter);
       }
   
   
  
  
  
  1.10      +33 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TypeUnmarshaller.java
  
  Index: TypeUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TypeUnmarshaller.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TypeUnmarshaller.java	12 Feb 2004 20:06:16 -0000	1.9
  +++ TypeUnmarshaller.java	25 Mar 2004 03:19:28 -0000	1.10
  @@ -39,6 +39,21 @@
       Object unmarshal(UnmarshalResult result)
           throws XmlException;
   
  +
  +    /**
  +     * Unmarshal into an existing object (i.e. fill the object's properties).
  +     *
  +     * This method is optional and TypeUnmarshaller's for immutable
  +     * types (e.g. java.lang.String) will throw UnsupportedOperationException
  +     *
  +     * @param object  Object who's properties will be filled.
  +     * @param result
  +     * @throws UnsupportedOperationException  if not appropriate for this type
  +     * @throws XmlException
  +     */
  +    void unmarshal(Object object, UnmarshalResult result)
  +        throws XmlException;
  +
       /**
        * unmarshal the lexical value of an instance of xsd:anySimpleType.
        * This could be called on an attribute value or on element content.
  @@ -51,6 +66,24 @@
        *            by this TypeUnmarshaller.
        */
       Object unmarshalAttribute(UnmarshalResult result)
  +        throws XmlException;
  +
  +    /**
  +     * unmarshal the lexical value of an instance of xsd:anySimpleType into an
  +     * existing object.  This could be called on an attribute value
  +     * or on element content.
  +     *
  +     * This method is optional and TypeUnmarshaller's for immutable
  +     * types (e.g. java.lang.String) will throw UnsupportedOperationException
  +     *
  +     * @param object  Object who's value will be filled.
  +     * @param result
  +     *
  +     * @exception UnsupportedOperationException if the
  +     *            <tt>unmarshalSimpleType</tt> operation is not supported
  +     *            by this TypeUnmarshaller.
  +     */
  +    void unmarshalAttribute(Object object, UnmarshalResult result)
           throws XmlException;
   
   
  
  
  
  1.13      +32 -56    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalResult.java
  
  Index: UnmarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalResult.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- UnmarshalResult.java	18 Mar 2004 23:25:35 -0000	1.12
  +++ UnmarshalResult.java	25 Mar 2004 03:19:28 -0000	1.13
  @@ -87,6 +87,18 @@
       }
   
   
  +    RuntimeTypeFactory getRuntimeTypeFactory()
  +    {
  +        return typeTable.getRuntimeTypeFactory();
  +    }
  +
  +    RuntimeBindingType getRuntimeType(BindingType type) throws XmlException
  +    {
  +        return typeTable.getRuntimeTypeFactory().createRuntimeType(type,
  +                                                                   typeTable,
  +                                                                   bindingLoader);
  +    }
  +
       private void enrichXmlStream(XMLStreamReader reader)
       {
           assert reader != null;
  @@ -106,15 +118,9 @@
       }
   
       //returns null and updates errors if there was a problem.
  -    private TypeUnmarshaller getTypeUnmarshaller(QName xsi_type)
  +    TypeUnmarshaller getTypeUnmarshaller(BindingType binding_type)
       {
  -        XmlTypeName xname = XmlTypeName.forTypeNamed(xsi_type);
  -        BindingType binding_type =
  -            bindingLoader.getBindingType(bindingLoader.lookupPojoFor(xname));
  -        if (binding_type == null) {
  -            addError("unknown type: " + xsi_type);
  -            return null;
  -        }
  +
           TypeUnmarshaller um =
               typeTable.getTypeUnmarshaller(binding_type);
           if (um == null) {
  @@ -126,6 +132,12 @@
           return um;
       }
   
  +    BindingType lookupBindingType(QName xsi_type)
  +    {
  +        XmlTypeName xname = XmlTypeName.forTypeNamed(xsi_type);
  +        return bindingLoader.getBindingType(bindingLoader.lookupPojoFor(xname));
  +    }
  +
       private void addError(String msg)
       {
           addError(msg, baseReader.getLocation());
  @@ -672,7 +684,8 @@
        * return the QName value found for xsi:type
        * or null if neither one was found
        */
  -    private QName getXsiType() throws XmlException
  +    QName getXsiType()
  +        throws XmlException
       {
           if (!gotXsiAttributes) {
               getXsiAttributes();
  @@ -853,7 +866,7 @@
           return defaultAttributeBits.get(att_idx);
       }
   
  -    private void setNextElementDefault(String lexical_default)
  +    void setNextElementDefault(String lexical_default)
           throws XmlException
       {
           try {
  @@ -864,48 +877,6 @@
           }
       }
   
  -    static void fillElementProp(RuntimeBindingProperty prop,
  -                                UnmarshalResult context,
  -                                Object inter)
  -        throws XmlException
  -    {
  -        final TypeUnmarshaller um = prop.getTypeUnmarshaller(context);
  -        assert um != null;
  -
  -        try {
  -            final String lexical_default = prop.getLexicalDefault();
  -            if (lexical_default != null) {
  -                context.setNextElementDefault(lexical_default);
  -            }
  -            final Object prop_val = um.unmarshal(context);
  -            prop.fill(inter, prop_val);
  -        }
  -        catch (InvalidLexicalValueException ilve) {
  -            //unlike attributes, the error has been added to the context
  -            //already via BaseSimpleTypeConveter...
  -        }
  -    }
  -
  -    static void fillAttributeProp(RuntimeBindingProperty prop,
  -                                  UnmarshalResult context,
  -                                  Object inter)
  -        throws XmlException
  -    {
  -        final TypeUnmarshaller um = prop.getTypeUnmarshaller(context);
  -        assert um != null;
  -
  -        try {
  -            final Object prop_val = um.unmarshalAttribute(context);
  -            prop.fill(inter, prop_val);
  -        }
  -        catch (InvalidLexicalValueException ilve) {
  -            //TODO: review error messages
  -            String msg = "invalid value for " + prop.getName() +
  -                ": " + ilve.getMessage();
  -            context.addError(msg, ilve.getLocation());
  -        }
  -    }
  -
       /**
        * Do the supplied localname, uri pair match the given qname?
        *
  @@ -930,11 +901,16 @@
           final QName xsi_type = getXsiType();
   
           if (xsi_type != null) {
  -            TypeUnmarshaller typed_um = getTypeUnmarshaller(xsi_type);
  -            if (typed_um != null)
  -                return typed_um;
  +            final BindingType binding_type = lookupBindingType(xsi_type);
  +            if (binding_type != null) {
  +                TypeUnmarshaller typed_um = getTypeUnmarshaller(binding_type);
  +                if (typed_um != null)
  +                    return typed_um;
  +            } else {
  +                addError("unknown type: " + xsi_type);
  +            }
               //reaching here means some problem with extracting the
  -            //marshaller for the xsi type, so just use the expected one
  +            //unmarshaller for the xsi type, so just use the expected one
           }
   
           if (hasXsiNil())
  
  
  
  1.4       +24 -21    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/WrappedArrayRuntimeBindingType.java
  
  Index: WrappedArrayRuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/WrappedArrayRuntimeBindingType.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WrappedArrayRuntimeBindingType.java	13 Mar 2004 00:33:22 -0000	1.3
  +++ WrappedArrayRuntimeBindingType.java	25 Mar 2004 03:19:28 -0000	1.4
  @@ -74,7 +74,7 @@
   
       private WAProperty elementProperty;
   
  -    public WrappedArrayRuntimeBindingType(WrappedArrayType binding_type)
  +    WrappedArrayRuntimeBindingType(WrappedArrayType binding_type)
           throws XmlException
       {
           super(binding_type);
  @@ -100,8 +100,8 @@
               rttFactory.createRuntimeType(item_type, typeTable, bindingLoader);
   
           elementProperty =
  -            new WAProperty(wrappedArrayType.getItemName(), item_rtt,
  -                           typeTable, bindingLoader,
  +            new WAProperty(this, wrappedArrayType.getItemName(),
  +                           item_rtt, typeTable, bindingLoader,
                              wrappedArrayType.isItemNillable());
   
   
  @@ -113,21 +113,21 @@
           return elementProperty;
       }
   
  -    Object createIntermediary(Object context)
  +    Object createIntermediary()
       {
           return AccumulatorFactory.createAccumulator(getJavaType(),
                                                       elementProperty.getElementClass());
   
       }
   
  -    Object getFinalObjectFromIntermediary(Object inter, Object context)
  +    static Object getFinalObjectFromIntermediary(Object inter)
       {
           Accumulator acc = (Accumulator)inter;
           return acc.getFinalArray();
       }
   
       private static final class WAProperty
  -        implements RuntimeBindingProperty
  +        extends RuntimeBindingProperty
       {
           private final QName itemName;
           private final RuntimeBindingType itemType;
  @@ -135,13 +135,16 @@
           private final TypeUnmarshaller unmarshaller;
           private final boolean nillable;
   
  -        public WAProperty(QName item_name,
  -                          RuntimeBindingType item_type,
  -                          RuntimeBindingTypeTable type_table,
  -                          BindingLoader loader,
  -                          boolean nillable)
  +        WAProperty(RuntimeBindingType containing_type,
  +                   QName item_name,
  +                   RuntimeBindingType item_type,
  +                   RuntimeBindingTypeTable type_table,
  +                   BindingLoader loader,
  +                   boolean nillable)
               throws XmlException
           {
  +            super(containing_type);
  +
               itemName = item_name;
               itemType = item_type;
   
  @@ -159,13 +162,13 @@
               return itemType.getJavaType();
           }
   
  -        public RuntimeBindingType getRuntimeBindingType()
  +        RuntimeBindingType getRuntimeBindingType()
           {
               return itemType;
           }
   
  -        public RuntimeBindingType getActualRuntimeType(Object property_value,
  -                                                       MarshalResult result)
  +        RuntimeBindingType getActualRuntimeType(Object property_value,
  +                                                MarshalResult result)
               throws XmlException
           {
               return MarshalResult.findActualRuntimeType(property_value,
  @@ -173,7 +176,7 @@
                                                          result);
           }
   
  -        public QName getName()
  +        QName getName()
           {
               return itemName;
           }
  @@ -192,7 +195,7 @@
           }
   
           //non simple type props can throw some runtime exception.
  -        public CharSequence getLexical(Object value, MarshalResult result)
  +        CharSequence getLexical(Object value, MarshalResult result)
               throws XmlException
           {
               assert value != null;
  @@ -202,13 +205,13 @@
               return marshaller.print(value, result);
           }
   
  -        public Object getValue(Object parentObject, MarshalResult result)
  +        Object getValue(Object parentObject, MarshalResult result)
               throws XmlException
           {
               return Array.get(parentObject, result.getCurrIndex());
           }
   
  -        public boolean isSet(Object parentObject, MarshalResult result)
  +        boolean isSet(Object parentObject, MarshalResult result)
               throws XmlException
           {
               if (nillable) return true;
  @@ -219,17 +222,17 @@
               return getValue(parentObject, result) != null;
           }
   
  -        public boolean isMultiple()
  +        boolean isMultiple()
           {
               return true;
           }
   
  -        public boolean isNillable()
  +        boolean isNillable()
           {
               return nillable;
           }
   
  -        public String getLexicalDefault()
  +        String getLexicalDefault()
           {
               return null;
           }
  
  
  
  1.3       +16 -5     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/WrappedArrayUnmarshaller.java
  
  Index: WrappedArrayUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/WrappedArrayUnmarshaller.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WrappedArrayUnmarshaller.java	2 Mar 2004 04:23:24 -0000	1.2
  +++ WrappedArrayUnmarshaller.java	25 Mar 2004 03:19:28 -0000	1.3
  @@ -75,9 +75,15 @@
       public Object unmarshal(UnmarshalResult result)
           throws XmlException
       {
  -        final Object inter = type.createIntermediary(result);
  +        final Object inter = type.createIntermediary();
           deserializeContents(inter, result);
  -        return type.getFinalObjectFromIntermediary(inter, result);
  +        return type.getFinalObjectFromIntermediary(inter);
  +    }
  +
  +    public void unmarshal(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new UnsupportedOperationException("not supported: this=" + this);
       }
   
       //TODO: cleanup this code.  We are doing extra work for assertion checking
  @@ -95,8 +101,7 @@
               assert context.isStartElement();
   
               if (matchesItemElement(context)) {
  -                UnmarshalResult.fillElementProp(type.getElementProperty(),
  -                                                context, inter);
  +                type.getElementProperty().extractAndFillElementProp(context, inter);
               }
           }
   
  @@ -123,7 +128,13 @@
       public Object unmarshalAttribute(UnmarshalResult result)
           throws XmlException
       {
  -        throw new UnsupportedOperationException("not used");
  +        throw new AssertionError("not used");
  +    }
  +
  +    public void unmarshalAttribute(Object object, UnmarshalResult result)
  +        throws XmlException
  +    {
  +        throw new AssertionError("not used");
       }
   
       public void initialize(RuntimeBindingTypeTable typeTable,
  
  
  
  1.4       +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ArrayUtils.java
  
  Index: ArrayUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ArrayUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArrayUtils.java	3 Mar 2004 18:53:28 -0000	1.3
  +++ ArrayUtils.java	25 Mar 2004 03:19:28 -0000	1.4
  @@ -17,7 +17,7 @@
   
   import java.lang.reflect.Array;
   
  -public class ArrayUtils
  +public final class ArrayUtils
   {
   
       public static String arrayToString(Object array)
  
  
  
  1.4       +9 -2      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java
  
  Index: ReflectionUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReflectionUtils.java	13 Mar 2004 03:46:57 -0000	1.3
  +++ ReflectionUtils.java	25 Mar 2004 03:19:28 -0000	1.4
  @@ -33,6 +33,12 @@
                                         Object[] params)
           throws XmlException
       {
  +//        final Class decl = method.getDeclaringClass();
  +//        final Class got = target.getClass();
  +//
  +//        assert decl.isAssignableFrom(got) : "DECL=" + decl + " GOT:" + got;
  +
  +
           try {
               return method.invoke(target, params);
           }
  @@ -105,7 +111,7 @@
           throws XmlException
       {
           if (method_name == null) return null;
  -        
  +
           try {
               return method_name.getMethodOn(clazz);
           }
  @@ -120,7 +126,8 @@
           }
       }
   
  -    public static boolean isMethodStatic(Method m) {
  +    public static boolean isMethodStatic(Method m)
  +    {
           return Modifier.isStatic(m.getModifiers());
       }
   
  
  
  
  1.3       +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ReflectiveArrayIterator.java
  
  Index: ReflectiveArrayIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ReflectiveArrayIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ReflectiveArrayIterator.java	12 Feb 2004 20:06:18 -0000	1.2
  +++ ReflectiveArrayIterator.java	25 Mar 2004 03:19:28 -0000	1.3
  @@ -22,7 +22,7 @@
   /**
    * @author   Copyright (c) 2003 by BEA Systems, Inc. All Rights Reserved.
    */
  -public class ReflectiveArrayIterator
  +public final class ReflectiveArrayIterator
       implements Iterator
   {
       private final Object array;
  
  
  
  1.26      +17 -3     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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- example_config.xml	13 Mar 2004 03:46:57 -0000	1.25
  +++ example_config.xml	25 Mar 2004 03:19:28 -0000	1.26
  @@ -39,18 +39,26 @@
                   <bin:attribute>true</bin:attribute>
                   <bin:default>9.12321</bin:default>
               </bin:qname-property>
  +
               <bin:qname-property>
                   <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
                   <bin:javatype>com.mytest.MyClass</bin:javatype>
                   <bin:getter>
  -                   <bin:method-name>getMyClass</bin:method-name>
  +                    <bin:method-name>getMyClass</bin:method-name>
                   </bin:getter>
                   <bin:setter>
  -                   <bin:method-name>setMyClass</bin:method-name>
  -                   <bin:param-type>com.mytest.MyClass</bin:param-type>
  +                    <bin:method-name>setMyClass</bin:method-name>
  +                    <bin:param-type>com.mytest.MyClass</bin:param-type>
                   </bin:setter>
  +                <bin:factory xsi:type="bin:parent-instance-factory">
  +                    <bin:create-object-method>
  +                        <bin:method-name>createObject</bin:method-name>
  +                        <bin:param-type>java.lang.Class</bin:param-type>
  +                    </bin:create-object-method>
  +                </bin:factory>
                   <bin:qname>java:MyClass</bin:qname>
               </bin:qname-property>
  +
               <bin:qname-property>
                   <bin:xmlcomponent>t=MySubClass@java:com.mytest</bin:xmlcomponent>
                   <bin:javatype>com.mytest.MySubClass</bin:javatype>
  @@ -381,6 +389,12 @@
                      <bin:method-name>setMyelt</bin:method-name>
                      <bin:param-type>com.mytest.YourClass</bin:param-type>
                   </bin:setter>
  +                <bin:factory xsi:type="bin:parent-instance-factory">
  +                    <bin:create-object-method>
  +                        <bin:method-name>createYourClass</bin:method-name>
  +                        <!--                        <bin:param-type>java.lang.Class</bin:param-type>-->
  +                    </bin:create-object-method>
  +                </bin:factory>
                   <bin:qname>java:Myelt</bin:qname>
               </bin:qname-property>
               <bin:qname-property>
  
  
  
  1.7       +10 -2     xml-xmlbeans/v2/test/cases/marshal/com/mytest/MyClass.java
  
  Index: MyClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/com/mytest/MyClass.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MyClass.java	12 Feb 2004 20:06:30 -0000	1.6
  +++ MyClass.java	25 Mar 2004 03:19:28 -0000	1.7
  @@ -18,11 +18,19 @@
   /**
    *  @xsdgen:complexType.rootElement load
    */
  -public class MyClass {
  +public class MyClass
  +{
   
   
       private YourClass myelt;
  -    private String myatt = "DEFAULT:"+YourClass.RND.nextInt();
  +    private String myatt = "DEFAULT:" + YourClass.RND.nextInt();
  +
  +
  +    //generic factory
  +    public Object createYourClass()
  +    {
  +        return new YourClass();
  +    }
   
   
       public YourClass getMyelt()
  
  
  
  1.15      +22 -7     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- YourClass.java	13 Mar 2004 03:46:57 -0000	1.14
  +++ YourClass.java	25 Mar 2004 03:19:28 -0000	1.15
  @@ -38,11 +38,11 @@
       private long[] longArray;// = {RND.nextLong(), RND.nextLong()};
   
       private boolean[] booleanArray;// = {true, false, true};
  -    private String[] stringArray = {"ONE:"+RND.nextInt(), "TWO:"+RND.nextInt()};
  +    private String[] stringArray = {"ONE:" + RND.nextInt(), "TWO:" + RND.nextInt()};
       private MyClass[] myClassArray;//{new MyClass(), new MyClass()};
   
  -    private QName qn = new QName("URI" + RND.nextInt(), "LNAME"+RND.nextInt());
  -    private QName qn2 = new QName("URI" + RND.nextInt(), "LNAME"+RND.nextInt());
  +    private QName qn = new QName("URI" + RND.nextInt(), "LNAME" + RND.nextInt());
  +    private QName qn2 = new QName("URI" + RND.nextInt(), "LNAME" + RND.nextInt());
   
   
       private String[] wrappedArrayOne = {"W1", "W2"};
  @@ -80,6 +80,25 @@
           return l;
       }
   
  +
  +    //generic factory
  +    public Object createObject(Class type)
  +    {
  +        if (type == null) throw new IllegalArgumentException("null type");
  +
  +        if (type.equals(MyClass.class)) {
  +            return new MyClass();
  +        } else if (type.equals(MySubClass.class)) {
  +            return new MySubClass();
  +        } else if (type.equals(MySubSubClass.class)) {
  +            return new MySubSubClass();
  +        } else if (type.equals(YourClass.class)) {
  +            return new YourClass();
  +        } else {
  +            throw new AssertionError("unknown type: " + type);
  +        }
  +    }
  +
       public float getMyFloat()
       {
           return myFloat;
  @@ -294,7 +313,6 @@
           final YourClass yourClass = (YourClass)o;
   
   
  -
           if (attrib != yourClass.attrib) return false;
           if (myFloat != yourClass.myFloat) return false;
           if (someBool != yourClass.someBool) return false;
  @@ -335,8 +353,6 @@
       }
   
   
  -
  -
       public String toString()
       {
           return "com.mytest.YourClass{" +
  @@ -359,7 +375,6 @@
               ", myClassArray=" + ArrayUtils.arrayToString(myClassArray) +
               "}";
       }
  -
   
   
   }
  
  
  

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