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/02/12 02:24:32 UTC

cvs commit: xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal ByNameRuntimeBindingType.java MarshalStreamUtils.java RuntimeBindingTypeTable.java

zieg        2004/02/11 17:24:32

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        ByNameRuntimeBindingType.java
                        MarshalStreamUtils.java
                        RuntimeBindingTypeTable.java
  Log:
  fix for nested asif types, remove dead methods
  
  Revision  Changes    Path
  1.26      +20 -28    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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ByNameRuntimeBindingType.java	12 Feb 2004 00:30:11 -0000	1.25
  +++ ByNameRuntimeBindingType.java	12 Feb 2004 01:24:32 -0000	1.26
  @@ -336,7 +336,7 @@
               this.beanHasMulti = bean_has_multis;
               this.bindingProperty = prop;
               this.unmarshaller = lookupUnmarshaller(prop, typeTable, loader);
  -            this.marshaller = lookupMarshaller(prop, typeTable, loader);
  +            this.marshaller = lookupMarshaller(prop.getTypeName(), typeTable, loader);
               this.bindingType = loader.getBindingType(prop.getTypeName());
               propertyClass = getPropertyClass(prop, bindingType);
               collectionElementClass = getCollectionElementClass(prop, bindingType);
  @@ -464,38 +464,30 @@
               return um;
           }
   
  -        private TypeMarshaller lookupMarshaller(BindingProperty prop,
  +        private TypeMarshaller lookupMarshaller(BindingTypeName type_name,
                                                   RuntimeBindingTypeTable typeTable,
                                                   BindingLoader loader)
  +            throws XmlException
           {
  -            final BindingType bindingType =
  -                loader.getBindingType(prop.getTypeName());
  -            TypeMarshaller m = typeTable.getTypeMarshaller(bindingType);
  -
  -            if (m == null) {
  -                //TODO: FIXME for nested as-if types
  -                if (bindingType instanceof SimpleBindingType) {
  -                    SimpleBindingType stype = (SimpleBindingType)bindingType;
  -
  -                    //let's try using the as if type
  -                    final BindingTypeName asif_name = stype.getAsIfBindingTypeName();
  -                    assert asif_name != null : "no asif for " + stype;
  -                    BindingType asif = loader.getBindingType(asif_name);
  -                    if (asif == null) {
  -                        throw new AssertionError("unable to get asif type" +
  -                                                 " for " + asif_name);
  -                    }
  -                    m = typeTable.getTypeMarshaller(asif);
  -
  -                    if (m == null) {
  -                        final String msg = "asif type marshaller not found" +
  -                            " for" + stype + " asif=" + asif;
  -                        throw new AssertionError(msg);
  -                    }
  -                }
  +            final BindingType binding_type = loader.getBindingType(type_name);
  +            if (binding_type == null) {
  +                final String msg = "unable to load type for " + type_name;
  +                throw new XmlException(msg);
  +            }
  +            TypeMarshaller m = typeTable.getTypeMarshaller(binding_type);
  +            if (m != null) return m;
  +
  +            if (binding_type instanceof SimpleBindingType) {
  +                SimpleBindingType stype = (SimpleBindingType)binding_type;
  +
  +                final BindingTypeName asif_name = stype.getAsIfBindingTypeName();
  +                if (asif_name == null)
  +                    throw new XmlException("no asif for " + stype);
  +
  +                return lookupMarshaller(asif_name, typeTable, loader);
               }
   
  -            return m;
  +            return null;
           }
   
   
  
  
  
  1.16      +6 -35     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalStreamUtils.java
  
  Index: MarshalStreamUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalStreamUtils.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MarshalStreamUtils.java	12 Feb 2004 00:30:11 -0000	1.15
  +++ MarshalStreamUtils.java	12 Feb 2004 01:24:32 -0000	1.16
  @@ -59,6 +59,7 @@
   import org.apache.xmlbeans.XmlError;
   import org.apache.xmlbeans.XmlRuntimeException;
   import org.apache.xmlbeans.impl.common.InvalidLexicalValueException;
  +import org.apache.xmlbeans.impl.common.XmlWhitespace;
   import org.apache.xmlbeans.impl.richParser.XMLStreamReaderExt;
   import org.apache.xmlbeans.impl.util.XsTypeConverter;
   
  @@ -105,24 +106,20 @@
                   } else if (XSI_NIL_ATTR.equals(lname)) {
                       holder.hasXsiNil = reader.getAttributeBooleanValue(att_idx);
                   } else if (XSI_SCHEMA_LOCATION_ATTR.equals(lname)) {
  -                    //TODO: apply collapse whitespace facet somehow
                       holder.schemaLocation =
  -                        reader.getAttributeStringValue(att_idx);
  +                        reader.getAttributeStringValue(att_idx,
  +                                                       XmlWhitespace.WS_COLLAPSE);
                   } else if (XSI_NO_NS_SCHEMA_LOCATION_ATTR.equals(lname)) {
  -                    //TODO: apply collapse whitespace facet somehow
                       holder.noNamespaceSchemaLocation =
  -                        reader.getAttributeStringValue(att_idx);
  +                        reader.getAttributeStringValue(att_idx,
  +                                                       XmlWhitespace.WS_COLLAPSE);
                   }
               }
                   //nothing should have been assigned, so keep going
                   //TODO: use real location (maybe just pass context to this method).
               catch (InvalidLexicalValueException ilve) {
                   addError(errors, ilve.getMessage(),
  -                         reader.getLocation(), "<unknown>");
  -            }
  -            catch (IllegalArgumentException iax) {   //thrown by lexBoolean
  -                addError(errors, iax.getMessage(),
  -                         reader.getLocation(), "<unknown>");
  +                         ilve.getLocation(), "<unknown>");
               }
           }
       }
  @@ -171,7 +168,6 @@
   
                   case XMLStreamReader.PROCESSING_INSTRUCTION:
                   case XMLStreamReader.CHARACTERS:
  -                    //TODO: what about mixed content models
                   case XMLStreamReader.COMMENT:
                   case XMLStreamReader.SPACE:
                   case XMLStreamReader.ENTITY_REFERENCE:
  @@ -236,31 +232,6 @@
           throw new XmlRuntimeException("unexpected end of xml stream");
       }
   
  -
  -    private static boolean isXsiNilTrue(XMLStreamReader reader,
  -                                        int att_idx,
  -                                        Collection errors)
  -    {
  -        final String lname = reader.getAttributeLocalName(att_idx);
  -        if (!XSI_NIL_ATTR.equals(lname))
  -            return false;
  -
  -        if (!XSI_NS.equals(reader.getAttributeNamespace(att_idx)))
  -            return false;
  -
  -        final String att_val = reader.getAttributeValue(att_idx);
  -        return XsTypeConverter.lexBoolean(att_val, errors);
  -    }
  -
  -    public static boolean isXsiNilTrue(XMLStreamReader reader,
  -                                       Collection errors)
  -    {
  -        assert reader.isStartElement();
  -        for (int i = 0, len = reader.getAttributeCount(); i < len; i++) {
  -            if (isXsiNilTrue(reader, i, errors)) return true;
  -        }
  -        return false;
  -    }
   
       static void advanceToFirstItemOfInterest(XMLStreamReader rdr)
           throws XMLStreamException
  
  
  
  1.12      +0 -1      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RuntimeBindingTypeTable.java	12 Feb 2004 00:30:11 -0000	1.11
  +++ RuntimeBindingTypeTable.java	12 Feb 2004 01:24:32 -0000	1.12
  @@ -295,7 +295,6 @@
           TypeUnmarshaller um = table.getTypeUnmarshaller(stype);
           if (um != null) return um;
   
  -
           int curr_ws = XmlWhitespace.WS_UNSPECIFIED;
           SimpleBindingType curr = stype;
           BuiltinBindingType resolved;
  
  
  

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