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 Tue, 02 Mar 2004 04:23:25 GMT
zieg        2004/03/01 20:23:25

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        ByNameRuntimeBindingType.java UnmarshalResult.java
                        WrappedArrayRuntimeBindingType.java
                        WrappedArrayUnmarshaller.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections
                        StringList.java
               v2/test/cases/marshal example_config.xml
               v2/test/cases/marshal/com/mytest YourClass.java
               v2/test/src/drt/drtcases MarshalTests.java
  Log:
  check for xsi values in wrapped array elements
  
  Revision  Changes    Path
  1.34      +1 -14     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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ByNameRuntimeBindingType.java	2 Mar 2004 02:54:07 -0000	1.33
  +++ ByNameRuntimeBindingType.java	2 Mar 2004 04:23:24 -0000	1.34
  @@ -381,20 +381,7 @@
               //don't need any xsi stuff for attributes.
               if (bindingProperty.isAttribute()) return unmarshaller;
   
  -            final QName xsi_type = context.getXsiType();
  -
  -            if (xsi_type != null) {
  -                TypeUnmarshaller typed_um = context.getTypeUnmarshaller(xsi_type);
  -                if (typed_um != null)
  -                    return typed_um;
  -                //reaching here means some problem with extracting the
  -                //marshaller for the xsi type, so just use the expected one
  -            }
  -
  -            if (context.hasXsiNil())
  -                return NullUnmarshaller.getInstance();
  -
  -            return unmarshaller;
  +            return context.determineTypeUnmarshaller(unmarshaller);
           }
   
           public void fill(final Object inter, final Object prop_obj)
  
  
  
  1.9       +20 -1     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- UnmarshalResult.java	2 Mar 2004 02:54:07 -0000	1.8
  +++ UnmarshalResult.java	2 Mar 2004 04:23:24 -0000	1.9
  @@ -26,9 +26,9 @@
   import org.apache.xmlbeans.impl.binding.bts.JavaTypeName;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.bts.XmlTypeName;
  +import org.apache.xmlbeans.impl.common.InvalidLexicalValueException;
   import org.apache.xmlbeans.impl.richParser.XMLStreamReaderExt;
   import org.apache.xmlbeans.impl.richParser.XMLStreamReaderExtImpl;
  -import org.apache.xmlbeans.impl.common.InvalidLexicalValueException;
   
   import javax.xml.namespace.QName;
   import javax.xml.stream.Location;
  @@ -885,6 +885,25 @@
               return qn.getNamespaceURI().equals(uri == null ? "" : uri);
           }
           return false;
  +    }
  +
  +    TypeUnmarshaller determineTypeUnmarshaller(TypeUnmarshaller base)
  +        throws XmlException
  +    {
  +        final QName xsi_type = getXsiType();
  +
  +        if (xsi_type != null) {
  +            TypeUnmarshaller typed_um = getTypeUnmarshaller(xsi_type);
  +            if (typed_um != null)
  +                return typed_um;
  +            //reaching here means some problem with extracting the
  +            //marshaller for the xsi type, so just use the expected one
  +        }
  +
  +        if (hasXsiNil())
  +            return NullUnmarshaller.getInstance();
  +
  +        return base;
       }
   
   }
  
  
  
  1.2       +14 -6     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WrappedArrayRuntimeBindingType.java	2 Mar 2004 02:54:07 -0000	1.1
  +++ WrappedArrayRuntimeBindingType.java	2 Mar 2004 04:23:24 -0000	1.2
  @@ -101,7 +101,10 @@
   
           elementProperty =
               new WAProperty(wrappedArrayType.getItemName(), item_rtt,
  -                           typeTable, bindingLoader);
  +                           typeTable, bindingLoader,
  +                           wrappedArrayType.isNillable());
  +
  +
       }
   
       RuntimeBindingProperty getElementProperty()
  @@ -130,11 +133,13 @@
           private final RuntimeBindingType itemType;
           private final TypeMarshaller marshaller; // used only for simple types
           private final TypeUnmarshaller unmarshaller;
  +        private final boolean nillable;
   
           public WAProperty(QName item_name,
                             RuntimeBindingType item_type,
                             RuntimeBindingTypeTable type_table,
  -                          BindingLoader loader)
  +                          BindingLoader loader,
  +                          boolean nillable)
               throws XmlException
           {
               itemName = item_name;
  @@ -145,6 +150,7 @@
                   type_table.lookupMarshaller(binding_type, loader);
               unmarshaller =
                   type_table.lookupUnmarshaller(binding_type, loader);
  +            this.nillable = nillable;
   
           }
   
  @@ -175,7 +181,7 @@
           public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
               throws XmlException
           {
  -            return unmarshaller;
  +            return context.determineTypeUnmarshaller(unmarshaller);
           }
   
           public void fill(Object inter, Object prop_obj)
  @@ -205,20 +211,22 @@
           public boolean isSet(Object parentObject, MarshalResult result)
               throws XmlException
           {
  +            if (nillable) return true;
               if (itemType.isJavaPrimitive()) return true;
   
  -            //TODO: call isSet?  check nillable??
  +            //TODO: consider isSet for array elements?
  +
               return getValue(parentObject, result) != null;
           }
   
           public boolean isMultiple()
           {
  -            throw new UnsupportedOperationException();
  +            return true;
           }
   
           public boolean isNillable()
           {
  -            throw new UnsupportedOperationException();
  +            return nillable;
           }
   
           public String getLexicalDefault()
  
  
  
  1.2       +3 -2      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WrappedArrayUnmarshaller.java	2 Mar 2004 02:54:07 -0000	1.1
  +++ WrappedArrayUnmarshaller.java	2 Mar 2004 04:23:24 -0000	1.2
  @@ -95,7 +95,8 @@
               assert context.isStartElement();
   
               if (matchesItemElement(context)) {
  -                UnmarshalResult.fillElementProp(type.getElementProperty(), context, inter);
  +                UnmarshalResult.fillElementProp(type.getElementProperty(),
  +                                                context, inter);
               }
           }
   
  @@ -122,7 +123,7 @@
       public Object unmarshalAttribute(UnmarshalResult result)
           throws XmlException
       {
  -        throw new AssertionError("UNIMP");
  +        throw new UnsupportedOperationException("not used");
       }
   
       public void initialize(RuntimeBindingTypeTable typeTable,
  
  
  
  1.4       +0 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/StringList.java
  
  Index: StringList.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/StringList.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringList.java	12 Feb 2004 20:06:18 -0000	1.3
  +++ StringList.java	2 Mar 2004 04:23:25 -0000	1.4
  @@ -77,7 +77,6 @@
   
       public void append(Object o)
       {
  -        assert (o instanceof String);
           add((String)o);
       }
   
  
  
  
  1.22      +1 -0      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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- example_config.xml	2 Mar 2004 02:54:07 -0000	1.21
  +++ example_config.xml	2 Mar 2004 04:23:25 -0000	1.22
  @@ -210,6 +210,7 @@
                   <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
                   <bin:javatype>java.lang.String</bin:javatype>
               </bin:item-type>
  +            <bin:nillable>true</bin:nillable>
           </bin:binding-type>
   
           <bin:binding-type xsi:type="bin:wrapped-array" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  
  
  
  1.12      +1 -0      xml-xmlbeans/v2/test/cases/marshal/com/mytest/YourClass.java
  
  Index: YourClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/com/mytest/YourClass.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- YourClass.java	2 Mar 2004 02:54:07 -0000	1.11
  +++ YourClass.java	2 Mar 2004 04:23:25 -0000	1.12
  @@ -294,6 +294,7 @@
               ", longArray=" + ArrayUtils.arrayToString(longArray) +
               ", booleanArray=" + ArrayUtils.arrayToString(booleanArray) +
               ", stringArray=" + ArrayUtils.arrayToString(stringArray) +
  +            ", wrappedArrayOne=" + ArrayUtils.arrayToString(wrappedArrayOne) +
               ", myClassArray=" + ArrayUtils.arrayToString(myClassArray) +
               "}";
       }
  
  
  
  1.38      +2 -1      xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java
  
  Index: MarshalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- MarshalTests.java	2 Mar 2004 02:54:07 -0000	1.37
  +++ MarshalTests.java	2 Mar 2004 04:23:25 -0000	1.38
  @@ -306,6 +306,7 @@
           myelt.setMyFloat(5555.4444f);
   //        myelt.setMyClass(new com.mytest.MyClass());
   
  +        myelt.setWrappedArrayOne(new String[]{"a", null, "b"});
   
           MySubClass sub = new MySubClass();
           sub.setBigInt(new BigInteger("23522352235223522352"));
  @@ -500,7 +501,7 @@
               myelt.setAttrib(rnd.nextFloat());
               myelt.setMyFloat(rnd.nextFloat());
               myelt.setBooleanArray(bools);
  -            myelt.setWrappedArrayOne(new String[]{"W1"+rnd.nextInt(), "W2" + rnd.nextInt()});
  +            myelt.setWrappedArrayOne(new String[]{"W1"+rnd.nextInt(), null, "W2" + rnd.nextInt()});
               myelt.setWrappedArrayTwo(null);
               final com.mytest.MyClass my_c = new com.mytest.MyClass();
               myelt.setMyClass(my_c);
  
  
  

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