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/src/marshal/org/apache/xmlbeans/impl/marshal AttributeRuntimeBindingType.java CollapseStringTypeConverter.java ListArrayConverter.java ListArrayRuntimeBindingType.java PreserveStringTypeConverter.java ReplaceStringTypeConverter.java RuntimeBindingProperty.java RuntimeBindingType.java RuntimeGlobalProperty.java UnmarshalResult.java WrappedArrayRuntimeBindingType.java
Date Tue, 27 Apr 2004 21:37:27 GMT
zieg        2004/04/27 14:37:27

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        AttributeRuntimeBindingType.java
                        CollapseStringTypeConverter.java
                        ListArrayConverter.java
                        ListArrayRuntimeBindingType.java
                        PreserveStringTypeConverter.java
                        ReplaceStringTypeConverter.java
                        RuntimeBindingProperty.java RuntimeBindingType.java
                        RuntimeGlobalProperty.java UnmarshalResult.java
                        WrappedArrayRuntimeBindingType.java
  Log:
  cleanup xsi:type handling
  fix bug with whitespace facet on attributes
  
  Revision  Changes    Path
  1.5       +0 -8      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AttributeRuntimeBindingType.java	27 Apr 2004 02:36:14 -0000	1.4
  +++ AttributeRuntimeBindingType.java	27 Apr 2004 21:37:26 -0000	1.5
  @@ -198,14 +198,6 @@
               assert prop.isAttribute();
           }
   
  -
  -        public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  -            throws XmlException
  -        {
  -            assert bindingProperty.isAttribute();
  -            //don't need any xsi stuff for attributes.
  -            return runtimeBindingType.getUnmarshaller();
  -        }
       }
   
   
  
  
  
  1.6       +7 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/CollapseStringTypeConverter.java
  
  Index: CollapseStringTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/CollapseStringTypeConverter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CollapseStringTypeConverter.java	27 Apr 2004 02:36:14 -0000	1.5
  +++ CollapseStringTypeConverter.java	27 Apr 2004 21:37:26 -0000	1.6
  @@ -34,6 +34,13 @@
       {
       }
   
  +
  +    public Object unmarshalAttribute(UnmarshalResult context)
  +        throws XmlException
  +    {
  +        return context.getAttributeStringValue(XmlWhitespace.WS_COLLAPSE);
  +    }
  +
       protected Object getObject(UnmarshalResult context)
           throws XmlException
       {
  
  
  
  1.4       +2 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ListArrayConverter.java
  
  Index: ListArrayConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ListArrayConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ListArrayConverter.java	27 Apr 2004 02:36:14 -0000	1.3
  +++ ListArrayConverter.java	27 Apr 2004 21:37:26 -0000	1.4
  @@ -99,7 +99,8 @@
           final Class list_java_type = listType.getJavaType();
           final Class item_java_type = item_prop.getRuntimeBindingType().getJavaType();
   
  -        final TypeUnmarshaller item_um = item_prop.getTypeUnmarshaller(context);
  +        final TypeUnmarshaller item_um =
  +            item_prop.getRuntimeBindingType().getUnmarshaller();
   
           return unmarshalListString(str, list_java_type, item_java_type,
                                      item_um, context);
  
  
  
  1.5       +0 -5      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ListArrayRuntimeBindingType.java
  
  Index: ListArrayRuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ListArrayRuntimeBindingType.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ListArrayRuntimeBindingType.java	27 Apr 2004 02:36:14 -0000	1.4
  +++ ListArrayRuntimeBindingType.java	27 Apr 2004 21:37:26 -0000	1.5
  @@ -105,11 +105,6 @@
               throw new UnsupportedOperationException("no name");
           }
   
  -        public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  -            throws XmlException
  -        {
  -            return itemType.getUnmarshaller();
  -        }
   
           public void fill(Object inter, Object prop_obj)
               throws XmlException
  
  
  
  1.6       +6 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PreserveStringTypeConverter.java
  
  Index: PreserveStringTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PreserveStringTypeConverter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PreserveStringTypeConverter.java	27 Apr 2004 02:36:14 -0000	1.5
  +++ PreserveStringTypeConverter.java	27 Apr 2004 21:37:26 -0000	1.6
  @@ -34,6 +34,12 @@
       {
       }
   
  +    public Object unmarshalAttribute(UnmarshalResult context)
  +        throws XmlException
  +    {
  +        return context.getAttributeStringValue(XmlWhitespace.WS_PRESERVE);
  +    }
  +
       protected Object getObject(UnmarshalResult context) throws XmlException
       {
           return context.getStringValue(XmlWhitespace.WS_PRESERVE);
  
  
  
  1.6       +6 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ReplaceStringTypeConverter.java
  
  Index: ReplaceStringTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ReplaceStringTypeConverter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ReplaceStringTypeConverter.java	27 Apr 2004 02:36:14 -0000	1.5
  +++ ReplaceStringTypeConverter.java	27 Apr 2004 21:37:26 -0000	1.6
  @@ -34,6 +34,12 @@
       {
       }
   
  +    public Object unmarshalAttribute(UnmarshalResult context)
  +        throws XmlException
  +    {
  +        return context.getAttributeStringValue(XmlWhitespace.WS_REPLACE);
  +    }
  +
       protected Object getObject(UnmarshalResult context)
           throws XmlException
       {
  
  
  
  1.20      +14 -39    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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- RuntimeBindingProperty.java	27 Apr 2004 02:36:14 -0000	1.19
  +++ RuntimeBindingProperty.java	27 Apr 2004 21:37:26 -0000	1.20
  @@ -17,7 +17,6 @@
   
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.impl.binding.bts.BindingProperty;
  -import org.apache.xmlbeans.impl.binding.bts.BindingType;
   import org.apache.xmlbeans.impl.binding.bts.JavaInstanceFactory;
   import org.apache.xmlbeans.impl.binding.bts.MethodName;
   import org.apache.xmlbeans.impl.binding.bts.ParentInstanceFactory;
  @@ -113,7 +112,8 @@
                                              Object inter)
           throws XmlException
       {
  -        final TypeUnmarshaller um = this.getTypeUnmarshaller(context);
  +        final RuntimeBindingType rtt = getRuntimeBindingType();
  +        final TypeUnmarshaller um = rtt.getUnmarshaller();
           assert um != null;
   
           try {
  @@ -124,7 +124,7 @@
                   if (parentFactoryMethodTakesClassArg) {
                       this_val =
                           createObjectViaFactory(actual_obj,
  -                                               getRuntimeBindingType().getJavaType());
  +                                               rtt.getJavaType());
                   } else {
                       this_val = createObjectViaFactory(actual_obj);
                   }
  @@ -150,48 +150,27 @@
               if (lexical_default != null) {
                   context.setNextElementDefault(lexical_default);
               }
  +            final RuntimeBindingType actual_rtt =
  +                context.determineActualRuntimeType(getRuntimeBindingType());
               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);
  +                                                      actual_rtt.getJavaType());
                   } 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);
  +                actual_rtt.getUnmarshaller().unmarshal(this_val, context);
               } else {
  -                this_val = this.getTypeUnmarshaller(context).unmarshal(context);
  +                final TypeUnmarshaller um;
  +                if (context.hasXsiNil()) {
  +                    um = NullUnmarshaller.getInstance();
  +                } else {
  +                    um = actual_rtt.getUnmarshaller();
  +                }
  +                this_val = um.unmarshal(context);
               }
               fill(inter, this_val);
           }
  @@ -229,10 +208,6 @@
       //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()
       {
  
  
  
  1.18      +0 -7      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- RuntimeBindingType.java	27 Apr 2004 02:36:14 -0000	1.17
  +++ RuntimeBindingType.java	27 Apr 2004 21:37:26 -0000	1.18
  @@ -337,13 +337,6 @@
               return result.determineRuntimeBindingType(runtimeBindingType, property_value);
           }
   
  -
  -        public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  -            throws XmlException
  -        {
  -            return context.determineTypeUnmarshaller(runtimeBindingType.getUnmarshaller());
  -        }
  -
           final boolean isSet(Object parentObject, MarshalResult result)
               throws XmlException
           {
  
  
  
  1.18      +0 -5      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- RuntimeGlobalProperty.java	27 Apr 2004 02:36:14 -0000	1.17
  +++ RuntimeGlobalProperty.java	27 Apr 2004 21:37:26 -0000	1.18
  @@ -60,11 +60,6 @@
           return rootElement;
       }
   
  -    public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  -    {
  -        throw new UnsupportedOperationException();
  -    }
  -
       public void fill(Object inter, Object prop_obj)
           throws XmlException
       {
  
  
  
  1.21      +18 -33    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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- UnmarshalResult.java	27 Apr 2004 02:36:14 -0000	1.20
  +++ UnmarshalResult.java	27 Apr 2004 21:37:26 -0000	1.21
  @@ -88,7 +88,7 @@
           this.errors = BindingContextImpl.extractErrorHandler(options);
       }
   
  -    RuntimeBindingType getRuntimeType(BindingType type)
  +    private RuntimeBindingType getRuntimeType(BindingType type)
           throws XmlException
       {
           return typeTable.createRuntimeType(type, bindingLoader);
  @@ -112,28 +112,19 @@
           }
       }
   
  -    //returns null and updates errors if there was a problem.
  -    TypeUnmarshaller getTypeUnmarshaller(BindingType binding_type)
  -        throws XmlException
  +    private BindingType lookupBindingType(QName xsi_type)
       {
  -
  -        final RuntimeBindingType rtt =
  -            typeTable.createRuntimeType(binding_type, bindingLoader);
  -        final TypeUnmarshaller um = rtt.getUnmarshaller();
  -
  -        if (um == null) {
  -            String msg = "unable to locate unmarshaller for " +
  -                binding_type.getName();
  -            addError(msg);
  +        XmlTypeName xname = XmlTypeName.forTypeNamed(xsi_type);
  +        final BindingTypeName btname = bindingLoader.lookupPojoFor(xname);
  +        if (btname == null) {
  +            addError("unknown type: " + xsi_type);
               return null;
           }
  -        return um;
  -    }
  -
  -    BindingType lookupBindingType(QName xsi_type)
  -    {
  -        XmlTypeName xname = XmlTypeName.forTypeNamed(xsi_type);
  -        return bindingLoader.getBindingType(bindingLoader.lookupPojoFor(xname));
  +        final BindingType binding_type = bindingLoader.getBindingType(btname);
  +        if (binding_type == null) {
  +            addError("unknown binding type: " + binding_type);
  +        }
  +        return binding_type;
       }
   
       private void addError(String msg)
  @@ -778,7 +769,7 @@
        * return the QName value found for xsi:type
        * or null if neither one was found
        */
  -    QName getXsiType()
  +    private QName getXsiType()
           throws XmlException
       {
           if (!gotXsiAttributes) {
  @@ -788,7 +779,7 @@
           return xsiAttributeHolder.xsiType;
       }
   
  -    private boolean hasXsiNil() throws XmlException
  +    boolean hasXsiNil() throws XmlException
       {
           if (!gotXsiAttributes) {
               getXsiAttributes();
  @@ -989,29 +980,23 @@
           return false;
       }
   
  -    TypeUnmarshaller determineTypeUnmarshaller(TypeUnmarshaller base)
  +    RuntimeBindingType determineActualRuntimeType(RuntimeBindingType expected)
           throws XmlException
       {
  -        if (hasXsiNil())
  -            return NullUnmarshaller.getInstance();
  -
           final QName xsi_type = getXsiType();
   
           if (xsi_type != null) {
               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);
  +                return typeTable.createRuntimeType(binding_type, bindingLoader);
               }
               //reaching here means some problem with extracting the
  -            //unmarshaller for the xsi type, so just use the expected one
  +            //BindingType for the xsi type, so just use the expected one
           }
   
  -        return base;
  +        return expected;
       }
  +
   
       NamespaceContext getNamespaceContext()
       {
  
  
  
  1.7       +0 -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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WrappedArrayRuntimeBindingType.java	27 Apr 2004 02:36:14 -0000	1.6
  +++ WrappedArrayRuntimeBindingType.java	27 Apr 2004 21:37:26 -0000	1.7
  @@ -127,12 +127,6 @@
               return itemName;
           }
   
  -        public TypeUnmarshaller getTypeUnmarshaller(UnmarshalResult context)
  -            throws XmlException
  -        {
  -            return context.determineTypeUnmarshaller(itemType.getUnmarshaller());
  -        }
  -
           public void fill(Object inter, Object prop_obj)
               throws XmlException
           {
  
  
  

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