xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases MarshalTests.java
Date Wed, 17 Dec 2003 21:10:53 GMT
zieg        2003/12/17 13:10:53

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        MarshallerImpl.java
               v2/test/src/drt/drtcases MarshalTests.java
  Log:
  fix polymorphism for marshalType
  
  Revision  Changes    Path
  1.11      +12 -17    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MarshallerImpl.java	17 Dec 2003 15:54:27 -0000	1.10
  +++ MarshallerImpl.java	17 Dec 2003 21:10:53 -0000	1.11
  @@ -110,8 +110,7 @@
                                      NamespaceContext nscontext)
           throws XmlException
       {
  -
  -        final JavaTypeName jname = JavaTypeName.forString(obj.getClass().getName());
  +        JavaTypeName jname = determineJavaType(obj);
           BindingTypeName root_elem_btype = loader.lookupElementFor(jname);
           if (root_elem_btype == null) {
               final String msg = "failed to find root " +
  @@ -139,6 +138,11 @@
           return new MarshalResult(prop, obj, this);
       }
   
  +    private static JavaTypeName determineJavaType(Object obj)
  +    {
  +        return JavaTypeName.forString(obj.getClass().getName());
  +    }
  +
       public void marshal(XMLStreamWriter writer, Object obj)
           throws XmlException
       {
  @@ -197,7 +201,7 @@
                                          NamespaceContext namespaceContext)
           throws XmlException
       {
  -        BindingType type = determineBindingType(obj, schemaType, javaType);
  +        BindingType type = lookupBindingType(obj, schemaType, loader);
           RuntimeGlobalProperty prop = new RuntimeGlobalProperty(type, elementName);
           return new MarshalResult(prop, obj, this);
       }
  @@ -220,22 +224,12 @@
           }
       }
   
  -    private BindingType determineBindingType(Object obj,
  -                                             QName schemaType,
  -                                             String javaType)
  -    {
  -        //TODO: consult object when needed for polymorphism
  -        BindingType binding_type = lookupBindingType(javaType, schemaType,
  -                                                     loader);
  -
  -        return binding_type;
  -    }
  -
  -    private static BindingType lookupBindingType(String javaType,
  +    private static BindingType lookupBindingType(Object obj,
                                                    QName schemaType,
                                                    BindingLoader loader)
       {
  -        JavaTypeName jname = JavaTypeName.forString(javaType);
  +        JavaTypeName jname = determineJavaType(obj);
  +
           XmlTypeName xname = XmlTypeName.forTypeNamed(schemaType);
           BindingTypeName btname = BindingTypeName.forPair(jname, xname);
           if (btname == null) {
  @@ -315,7 +309,8 @@
           do {
               prefix = NSPREFIX + (++prefixCnt);
               testuri = namespaceContext.getNamespaceURI(prefix);
  -        } while (testuri != null);
  +        }
  +        while (testuri != null);
           assert prefix != null;
           namespaceContext.bindNamespace(prefix, uri);
           return prefix;
  
  
  
  1.23      +7 -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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- MarshalTests.java	17 Dec 2003 15:54:27 -0000	1.22
  +++ MarshalTests.java	17 Dec 2003 21:10:53 -0000	1.23
  @@ -222,11 +222,18 @@
                               new QName("java:com.mytest", "MyClass"),
                               mc.getClass().getName(), null);
   
  +//
  +//        final XMLStreamReader reader =
  +//            ctx.marshalType(sub, new QName("java:com.mytest", "sub-test"),
  +//                            new QName("java:com.mytest", "MySubClass"),
  +//                            "MyClass", null);
  +
           System.out.println("=======IN-OBJ: " + mc);
   
           dumpReader(reader);
           Assert.assertTrue(errors.isEmpty());
       }
  +
   
   
       public void testByNameMarshalViaWriter()
  
  
  

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