xml-xmlbeans-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases MarshalTests.java
Date Tue, 02 Dec 2003 23:41:32 GMT
zieg        2003/12/02 15:41:32

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        ByNameBean.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        MarshallerImpl.java
               v2/src/xmlpublic/org/apache/xmlbeans Marshaller.java
               v2/test/cases/marshal example_config.xml
               v2/test/cases/marshal/com/mytest MyClass.java YourClass.java
               v2/test/src/drt/drtcases MarshalTests.java
  Log:
  add XMLStreamWriter versions of marshal methods (tests added to MarshalTests)
  update example_config to generated version
  
  Revision  Changes    Path
  1.5       +5 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ByNameBean.java
  
  Index: ByNameBean.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ByNameBean.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ByNameBean.java	13 Nov 2003 01:37:07 -0000	1.4
  +++ ByNameBean.java	2 Dec 2003 23:41:31 -0000	1.5
  @@ -103,6 +103,11 @@
        */ 
       protected org.apache.xml.xmlbeans.bindingConfig.BindingType write(org.apache.xml.xmlbeans.bindingConfig.BindingType
node)
       {
  +        if (!(node instanceof org.apache.xml.xmlbeans.bindingConfig.ByNameBean)) {
  +            throw new AssertionError("node is " + node.getClass() + " wanted org.apache.xml.xmlbeans.bindingConfig.ByNameBean");
  +
  +        }
  +
           org.apache.xml.xmlbeans.bindingConfig.ByNameBean bnNode =
                   (org.apache.xml.xmlbeans.bindingConfig.ByNameBean)super.write(node);
           for (Iterator i = props.iterator(); i.hasNext(); )
  
  
  
  1.4       +32 -0     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MarshallerImpl.java	14 Nov 2003 00:40:29 -0000	1.3
  +++ MarshallerImpl.java	2 Dec 2003 23:41:32 -0000	1.4
  @@ -65,10 +65,13 @@
   import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.bts.JavaName;
   import org.apache.xmlbeans.impl.binding.bts.XmlName;
  +import org.apache.xmlbeans.impl.common.XmlReaderToWriter;
   
   import javax.xml.namespace.NamespaceContext;
   import javax.xml.namespace.QName;
  +import javax.xml.stream.XMLStreamException;
   import javax.xml.stream.XMLStreamReader;
  +import javax.xml.stream.XMLStreamWriter;
   import java.util.ArrayList;
   
   /**
  @@ -120,6 +123,18 @@
           return marshalResult;
       }
   
  +    public void marshall(XMLStreamWriter writer, Object obj)
  +        throws XmlException
  +    {
  +        XMLStreamReader rdr = marshall(obj, writer.getNamespaceContext());
  +        try {
  +            XmlReaderToWriter.writeAll(rdr, writer);
  +        }
  +        catch (XMLStreamException e) {
  +            throw new XmlException(e);
  +        }
  +    }
  +
       public XMLStreamReader marshallType(Object obj,
                                           QName elementName,
                                           QName schemaType,
  @@ -136,6 +151,23 @@
           BindingType type = determineBindingType(obj, schemaType, javaType);
           RuntimeGlobalProperty prop = new RuntimeGlobalProperty(type, elementName);
           return new MarshalResult(prop, obj, our_context);
  +    }
  +
  +    public void marshallType(XMLStreamWriter writer,
  +                             Object obj,
  +                             QName elementName,
  +                             QName schemaType,
  +                             String javaType,
  +                             MarshalContext context)
  +        throws XmlException
  +    {
  +        XMLStreamReader rdr = marshallType(obj, elementName, schemaType, javaType, context);
  +        try {
  +            XmlReaderToWriter.writeAll(rdr, writer);
  +        }
  +        catch (XMLStreamException e) {
  +            throw new XmlException(e);
  +        }
       }
   
       private BindingType determineBindingType(Object obj,
  
  
  
  1.2       +42 -0     xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/Marshaller.java
  
  Index: Marshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/Marshaller.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Marshaller.java	14 Nov 2003 00:40:30 -0000	1.1
  +++ Marshaller.java	2 Dec 2003 23:41:32 -0000	1.2
  @@ -60,6 +60,7 @@
   import javax.xml.namespace.NamespaceContext;
   import javax.xml.namespace.QName;
   import javax.xml.stream.XMLStreamReader;
  +import javax.xml.stream.XMLStreamWriter;
   
   /**
    * A Marshaller object is used to convert Java objects to XML documents.
  @@ -86,6 +87,23 @@
       XMLStreamReader marshall(Object obj, NamespaceContext nscontext)
           throws XmlException;
   
  +    /**
  +     * Write an XML representation of the Java object to the provided writer.
  +     *
  +     * The object is expected to correspond to a global element in a schema.
  +     * The first matching global element will be used as the root element.
  +     *
  +     * As of this writing (11/22/2003), this method will NOT write
  +     * a START_DOCUMENT or END_DOCUMENT element.
  +     * The first event written will be a START_ELEMENT event.
  +     *
  +     * @param obj
  +     * @param writer
  +     * @throws XmlException
  +     */
  +    void marshall(XMLStreamWriter writer, Object obj)
  +        throws XmlException;
  +
   
       /**
        * Get an XMLStreamReader object that represents the given java type.
  @@ -108,4 +126,28 @@
                                    String javaType,
                                    MarshalContext context)
           throws XmlException;
  +
  +
  +    /**
  +     * Write an XML representation of the Java object to the provided writer.
  +     *
  +     * As of this writing (11/22/2003), this method will NOT write
  +     * a START_DOCUMENT or END_DOCUMENT element.
  +     * The first event written will be a START_ELEMENT event.
  +     *
  +     * @param writer
  +     * @param obj
  +     * @param elementName
  +     * @param schemaType
  +     * @param javaType
  +     * @throws XmlException
  +     */
  +    void marshallType(XMLStreamWriter writer,
  +                      Object obj,
  +                      QName elementName,
  +                      QName schemaType,
  +                      String javaType,
  +                      MarshalContext context)
  +        throws XmlException;
  +
   }
  
  
  
  1.9       +119 -150  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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- example_config.xml	19 Nov 2003 20:40:25 -0000	1.8
  +++ example_config.xml	2 Dec 2003 23:41:32 -0000	1.9
  @@ -1,153 +1,122 @@
   <?xml version="1.0" encoding="UTF-8"?>
   <bin:binding-config xmlns:java="java:com.mytest" xmlns:bin="http://xml.apache.org/xmlbeans/binding-config">
  -    <bin:bindings>
  -        <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  -            <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.YourClass</bin:javatype>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=float@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>float</bin:javatype>
  -                <bin:getter>getAttrib</bin:getter>
  -                <bin:setter>setAttrib</bin:setter>
  -                <bin:qname>java:Attrib</bin:qname>
  -                <bin:attribute>true</bin:attribute>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  -                <bin:javatype>com.mytest.MyClass</bin:javatype>
  -                <bin:getter>getMyClass</bin:getter>
  -                <bin:setter>setMyClass</bin:setter>
  -                <bin:qname>java:MyClass</bin:qname>
  -                <bin:nillable>true</bin:nillable>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=float@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>float</bin:javatype>
  -                <bin:getter>getMyFloat</bin:getter>
  -                <bin:setter>setMyFloat</bin:setter>
  -                <bin:qname>java:MyFloat</bin:qname>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=boolean@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>boolean</bin:javatype>
  -                <bin:getter>isSomeBool</bin:getter>
  -                <bin:setter>setSomeBool</bin:setter>
  -                <bin:qname>java:SomeBool</bin:qname>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>java.lang.String</bin:javatype>
  -                <bin:getter>getStrs</bin:getter>
  -                <bin:setter>setStrs</bin:setter>
  -                <bin:collection>java.util.List</bin:collection>
  -                <bin:qname>java:Strs</bin:qname>
  -                <bin:multiple>true</bin:multiple>
  -                <bin:nillable>true</bin:nillable>
  -            </bin:qname-property>
  -
  -<!--            myclassArray-->
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  -                <bin:javatype>com.mytest.MyClass</bin:javatype>
  -                <bin:getter>getMyClassArray</bin:getter>
  -                <bin:setter>setMyClassArray</bin:setter>
  -                <bin:collection>com.mytest.MyClass[]</bin:collection>
  -                <bin:qname>java:MyClassArray</bin:qname>
  -                <bin:multiple>true</bin:multiple>
  -                <bin:nillable>true</bin:nillable>
  -            </bin:qname-property>
  -
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=boolean@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>boolean</bin:javatype>
  -                <bin:getter>getBools</bin:getter>
  -                <bin:setter>setBools</bin:setter>
  -                <bin:collection>java.util.List</bin:collection>
  -                <bin:qname>java:Bools</bin:qname>
  -                <bin:multiple>true</bin:multiple>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=long@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>long</bin:javatype>
  -                <bin:getter>getLongArray</bin:getter>
  -                <bin:setter>setLongArray</bin:setter>
  -                <bin:collection>long[]</bin:collection>
  -                <bin:qname>java:LongArray</bin:qname>
  -                <bin:multiple>true</bin:multiple>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=boolean@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>boolean</bin:javatype>
  -                <bin:getter>getBooleanArray</bin:getter>
  -                <bin:setter>setBooleanArray</bin:setter>
  -                <bin:collection>boolean[]</bin:collection>
  -                <bin:qname>java:BooleanArray</bin:qname>
  -                <bin:multiple>true</bin:multiple>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>java.lang.String</bin:javatype>
  -                <bin:getter>getStringArray</bin:getter>
  -                <bin:setter>setStringArray</bin:setter>
  -                <bin:collection>java.lang.String[]</bin:collection>
  -                <bin:qname>java:StringArray</bin:qname>
  -                <bin:multiple>true</bin:multiple>
  -            </bin:qname-property>
  -        </bin:binding-type>
  -        <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  -            <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.MyClass</bin:javatype>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  -                <bin:javatype>com.mytest.YourClass</bin:javatype>
  -                <bin:getter>getMyelt</bin:getter>
  -                <bin:setter>setMyelt</bin:setter>
  -                <bin:qname>java:Myelt</bin:qname>
  -            </bin:qname-property>
  -            <bin:qname-property>
  -                <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  -                <bin:javatype>java.lang.String</bin:javatype>
  -                <bin:getter>getMyatt</bin:getter>
  -                <bin:setter>setMyatt</bin:setter>
  -                <bin:qname>java:Myatt</bin:qname>
  -                <bin:nillable>true</bin:nillable>
  -            </bin:qname-property>
  -        </bin:binding-type>
  -        <bin:binding-type xsi:type="bin:simple-document-binding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  -            <bin:xmlcomponent>e=load@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.MyClass</bin:javatype>
  -            <bin:type-of-element>t=MyClass@java:com.mytest</bin:type-of-element>
  -        </bin:binding-type>
  -    </bin:bindings>
  -    <bin:xml-to-pojo>
  -        <bin:mapping>
  -            <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.YourClass</bin:javatype>
  -        </bin:mapping>
  -        <bin:mapping>
  -            <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.MyClass</bin:javatype>
  -        </bin:mapping>
  -        <bin:mapping>
  -            <bin:xmlcomponent>e=load@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.MyClass</bin:javatype>
  -        </bin:mapping>
  -    </bin:xml-to-pojo>
  -    <bin:xml-to-xmlobj/>
  -    <bin:java-to-xml>
  -        <bin:mapping>
  -            <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.YourClass</bin:javatype>
  -        </bin:mapping>
  -        <bin:mapping>
  -            <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.MyClass</bin:javatype>
  -        </bin:mapping>
  -    </bin:java-to-xml>
  -    <bin:java-to-element>
  -        <bin:mapping>
  -            <bin:xmlcomponent>e=load@java:com.mytest</bin:xmlcomponent>
  -            <bin:javatype>com.mytest.MyClass</bin:javatype>
  -        </bin:mapping>
  -    </bin:java-to-element>
  +  <bin:bindings>
  +    <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +      <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.YourClass</bin:javatype>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=float@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +        <bin:javatype>float</bin:javatype>
  +        <bin:getter>getAttrib</bin:getter>
  +        <bin:setter>setAttrib</bin:setter>
  +        <bin:qname>java:Attrib</bin:qname>
  +        <bin:attribute>true</bin:attribute>
  +      </bin:qname-property>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  +        <bin:javatype>com.mytest.MyClass</bin:javatype>
  +        <bin:getter>getMyClass</bin:getter>
  +        <bin:setter>setMyClass</bin:setter>
  +        <bin:qname>java:MyClass</bin:qname>
  +      </bin:qname-property>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=float@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +        <bin:javatype>float</bin:javatype>
  +        <bin:getter>getMyFloat</bin:getter>
  +        <bin:setter>setMyFloat</bin:setter>
  +        <bin:qname>java:MyFloat</bin:qname>
  +      </bin:qname-property>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  +        <bin:javatype>com.mytest.MyClass</bin:javatype>
  +        <bin:getter>getMyClassArray</bin:getter>
  +        <bin:setter>setMyClassArray</bin:setter>
  +        <bin:collection>com.mytest.MyClass[]</bin:collection>
  +        <bin:qname>java:MyClassArray</bin:qname>
  +        <bin:multiple>true</bin:multiple>
  +      </bin:qname-property>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=long@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +        <bin:javatype>long</bin:javatype>
  +        <bin:getter>getLongArray</bin:getter>
  +        <bin:setter>setLongArray</bin:setter>
  +        <bin:collection>long[]</bin:collection>
  +        <bin:qname>java:LongArray</bin:qname>
  +        <bin:multiple>true</bin:multiple>
  +      </bin:qname-property>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=boolean@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +        <bin:javatype>boolean</bin:javatype>
  +        <bin:getter>getBooleanArray</bin:getter>
  +        <bin:setter>setBooleanArray</bin:setter>
  +        <bin:collection>boolean[]</bin:collection>
  +        <bin:qname>java:BooleanArray</bin:qname>
  +        <bin:multiple>true</bin:multiple>
  +      </bin:qname-property>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +        <bin:javatype>java.lang.String</bin:javatype>
  +        <bin:getter>getStringArray</bin:getter>
  +        <bin:setter>setStringArray</bin:setter>
  +        <bin:collection>java.lang.String[]</bin:collection>
  +        <bin:qname>java:StringArray</bin:qname>
  +        <bin:multiple>true</bin:multiple>
  +      </bin:qname-property>
  +    </bin:binding-type>
  +    <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +      <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.MyClass</bin:javatype>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  +        <bin:javatype>com.mytest.YourClass</bin:javatype>
  +        <bin:getter>getMyelt</bin:getter>
  +        <bin:setter>setMyelt</bin:setter>
  +        <bin:qname>java:Myelt</bin:qname>
  +      </bin:qname-property>
  +      <bin:qname-property>
  +        <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +        <bin:javatype>java.lang.String</bin:javatype>
  +        <bin:getter>getMyatt</bin:getter>
  +        <bin:setter>setMyatt</bin:setter>
  +        <bin:qname>java:Myatt</bin:qname>
  +        <bin:nillable>true</bin:nillable>
  +      </bin:qname-property>
  +    </bin:binding-type>
  +    <bin:binding-type xsi:type="bin:simple-document-binding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  +      <bin:xmlcomponent>e=load@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.MyClass</bin:javatype>
  +      <bin:type-of-element>t=MyClass@java:com.mytest</bin:type-of-element>
  +    </bin:binding-type>
  +  </bin:bindings>
  +  <bin:xml-to-pojo>
  +    <bin:mapping>
  +      <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.YourClass</bin:javatype>
  +    </bin:mapping>
  +    <bin:mapping>
  +      <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.MyClass</bin:javatype>
  +    </bin:mapping>
  +    <bin:mapping>
  +      <bin:xmlcomponent>e=load@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.MyClass</bin:javatype>
  +    </bin:mapping>
  +  </bin:xml-to-pojo>
  +  <bin:xml-to-xmlobj/>
  +  <bin:java-to-xml>
  +    <bin:mapping>
  +      <bin:xmlcomponent>t=YourClass@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.YourClass</bin:javatype>
  +    </bin:mapping>
  +    <bin:mapping>
  +      <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.MyClass</bin:javatype>
  +    </bin:mapping>
  +  </bin:java-to-xml>
  +  <bin:java-to-element>
  +    <bin:mapping>
  +      <bin:xmlcomponent>e=load@java:com.mytest</bin:xmlcomponent>
  +      <bin:javatype>com.mytest.MyClass</bin:javatype>
  +    </bin:mapping>
  +  </bin:java-to-element>
   </bin:binding-config>
  
  
  
  1.5       +3 -1      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MyClass.java	19 Nov 2003 20:40:25 -0000	1.4
  +++ MyClass.java	2 Dec 2003 23:41:32 -0000	1.5
  @@ -20,7 +20,9 @@
           this.myelt = myelt;
       }
   
  -
  +    /**
  +     *  @xsdgen:element.nillable true
  +     */
       public String getMyatt()
       {
           return myatt;
  
  
  
  1.6       +27 -27    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- YourClass.java	19 Nov 2003 20:40:25 -0000	1.5
  +++ YourClass.java	2 Dec 2003 23:41:32 -0000	1.6
  @@ -69,8 +69,8 @@
       private float myFloat;
       private float attrib;
       private boolean someBool;
  -    private List bools;// = newBoolList();
  -    private List strs;// = newStringList();
  +//    private List bools;// = newBoolList();
  +//    private List strs;// = newStringList();
       private long[] longArray;// = {RND.nextLong(), RND.nextLong()};
       private boolean[] booleanArray;// = {true, false, true};
       private String[] stringArray;//{"ONE:"+RND.nextInt(), "TWO:"+RND.nextInt()};
  @@ -129,16 +129,16 @@
       {
           this.someBool = someBool;
       }
  -
  -    public List getBools()
  -    {
  -        return bools;
  -    }
  -
  -    public void setBools(List bools)
  -    {
  -        this.bools = bools;
  -    }
  +//
  +//    public List getBools()
  +//    {
  +//        return bools;
  +//    }
  +//
  +//    public void setBools(List bools)
  +//    {
  +//        this.bools = bools;
  +//    }
   
   
       /**
  @@ -154,15 +154,15 @@
           this.attrib = attrib;
       }
   
  -    public List getStrs()
  -    {
  -        return strs;
  -    }
  -
  -    public void setStrs(List strs)
  -    {
  -        this.strs = strs;
  -    }
  +//    public List getStrs()
  +//    {
  +//        return strs;
  +//    }
  +//
  +//    public void setStrs(List strs)
  +//    {
  +//        this.strs = strs;
  +//    }
   
       public long[] getLongArray()
       {
  @@ -216,12 +216,12 @@
           if (myFloat != yourClass.myFloat) return false;
           if (someBool != yourClass.someBool) return false;
           if (!Arrays.equals(booleanArray, yourClass.booleanArray)) return false;
  -        if (bools != null ? !bools.equals(yourClass.bools) : yourClass.bools != null) return
false;
  +//        if (bools != null ? !bools.equals(yourClass.bools) : yourClass.bools != null)
return false;
           if (!Arrays.equals(longArray, yourClass.longArray)) return false;
           if (myClass != null ? !myClass.equals(yourClass.myClass) : yourClass.myClass !=
null) return false;
           if (!Arrays.equals(myClassArray, yourClass.myClassArray)) return false;
           if (!Arrays.equals(stringArray, yourClass.stringArray)) return false;
  -        if (strs != null ? !strs.equals(yourClass.strs) : yourClass.strs != null) return
false;
  +//        if (strs != null ? !strs.equals(yourClass.strs) : yourClass.strs != null) return
false;
   
           return true;
       }
  @@ -233,8 +233,8 @@
           result = 29 * result + Float.floatToIntBits(myFloat);
           result = 29 * result + Float.floatToIntBits(attrib);
           result = 29 * result + (someBool ? 1 : 0);
  -        result = 29 * result + (bools != null ? bools.hashCode() : 0);
  -        result = 29 * result + (strs != null ? strs.hashCode() : 0);
  +//        result = 29 * result + (bools != null ? bools.hashCode() : 0);
  +//        result = 29 * result + (strs != null ? strs.hashCode() : 0);
           return result;
       }
   
  @@ -248,8 +248,8 @@
               ", myFloat=" + myFloat +
               ", attrib=" + attrib +
               ", someBool=" + someBool +
  -            ", bools=" + (bools == null ? null : "size:" + bools.size() + bools) +
  -            ", strs=" + (strs == null ? null : "size:" + strs.size() + strs) +
  +//            ", bools=" + (bools == null ? null : "size:" + bools.size() + bools) +
  +//            ", strs=" + (strs == null ? null : "size:" + strs.size() + strs) +
               ", longArray=" + ArrayUtils.arrayToString(longArray) +
               ", booleanArray=" + ArrayUtils.arrayToString(booleanArray) +
               ", stringArray=" + ArrayUtils.arrayToString(stringArray) +
  
  
  
  1.15      +81 -0     xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java
  
  Index: MarshalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MarshalTests.java	19 Nov 2003 20:40:25 -0000	1.14
  +++ MarshalTests.java	2 Dec 2003 23:41:32 -0000	1.15
  @@ -150,6 +150,8 @@
           myelt.setMyClass(null);
           mc.setMyelt(myelt);
   
  +        myelt.setStringArray(new String[]{"one", "two", "three"});
  +
   
           final File bcdoc = getBindingConfigDocument();
   
  @@ -174,6 +176,84 @@
       }
   
   
  +    public void testByNameMarshalViaWriter()
  +        throws Exception
  +    {
  +        com.mytest.MyClass mc = new com.mytest.MyClass();
  +        mc.setMyatt("attval");
  +        com.mytest.YourClass myelt = new com.mytest.YourClass();
  +        myelt.setAttrib(99999.777f);
  +        myelt.setMyFloat(5555.4444f);
  +//        myelt.setMyClass(new com.mytest.MyClass());
  +        myelt.setMyClass(null);
  +        mc.setMyelt(myelt);
  +
  +        myelt.setStringArray(new String[]{"one", "two", "three"});
  +
  +
  +        final File bcdoc = getBindingConfigDocument();
  +
  +        BindingContext bindingContext =
  +            BindingContextFactory.newInstance().createBindingContext(bcdoc);
  +
  +        Marshaller m = bindingContext.createMarshaller();
  +
  +        StringWriter sw = new StringWriter();
  +        XMLStreamWriter w = XMLOutputFactory.newInstance().createXMLStreamWriter(sw);
  +
  +        MarshalContext ctx =
  +            bindingContext.createMarshallContext(w.getNamespaceContext());
  +
  +         m.marshallType(w, mc, new QName("java:com.mytest", "load"),
  +                           new QName("java:com.mytest", "MyClass"),
  +                           mc.getClass().getName(),
  +                           ctx);
  +
  +        System.out.println("=======IN-OBJ: " + mc);
  +        System.out.println("=======OUT-XML: " + PrettyPrinter.indent(sw.getBuffer().toString()));
  +    }
  +
  +    public void testByNameDocMarshalViaWriter()
  +        throws Exception
  +    {
  +        com.mytest.MyClass mc = new com.mytest.MyClass();
  +        mc.setMyatt("attval");
  +        com.mytest.YourClass myelt = new com.mytest.YourClass();
  +        myelt.setAttrib(99999.777f);
  +        myelt.setMyFloat(5555.4444f);
  +//        myelt.setMyClass(new com.mytest.MyClass());
  +        myelt.setMyClass(null);
  +        mc.setMyelt(myelt);
  +
  +        myelt.setStringArray(new String[]{"one", "two", "three"});
  +
  +
  +        final File bcdoc = getBindingConfigDocument();
  +
  +        BindingContext bindingContext =
  +            BindingContextFactory.newInstance().createBindingContext(bcdoc);
  +
  +        Marshaller m = bindingContext.createMarshaller();
  +
  +        StringWriter sw = new StringWriter();
  +        XMLStreamWriter w = XMLOutputFactory.newInstance().createXMLStreamWriter(sw);
  +
  +        MarshalContext ctx =
  +            bindingContext.createMarshallContext(w.getNamespaceContext());
  +
  +        m.marshall(w, mc);
  +
  +
  +        //now unmarshall from String and compare objects...
  +        StringReader sr = new StringReader(sw.getBuffer().toString());
  +        XMLStreamReader rdr =
  +            XMLInputFactory.newInstance().createXMLStreamReader(sr);
  +        Unmarshaller um = bindingContext.createUnmarshaller();
  +        Object out_obj =  um.unmarshal(rdr);
  +        Assert.assertEquals(mc, out_obj);
  +    }
  +
  +
       public void testRoundtripPerf()
           throws Exception
       {
  @@ -281,6 +361,7 @@
           top_obj.setMyelt(myelt);
   //        curr.setMyatt("STR" + rnd.nextInt());
           top_obj.setMyatt(null);
  +//        top_obj.setMyatt("someVALUE");
   
   
           System.out.println("top_obj = " + top_obj);
  
  
  

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


Mime
View raw message