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 MarshalResult.java MarshallerImpl.java NamedXmlTypeVisitor.java RuntimeBindingTypeTable.java XmlTypeVisitor.java
Date Thu, 08 Apr 2004 19:03:44 GMT
zieg        2004/04/08 12:03:44

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        MarshalResult.java MarshallerImpl.java
                        NamedXmlTypeVisitor.java
                        RuntimeBindingTypeTable.java XmlTypeVisitor.java
  Log:
  isolate creation of QNames into one place to facilitate later
  refactoring/optimization
  
  Revision  Changes    Path
  1.23      +33 -13    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java
  
  Index: MarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- MarshalResult.java	6 Apr 2004 00:53:09 -0000	1.22
  +++ MarshalResult.java	8 Apr 2004 19:03:44 -0000	1.23
  @@ -24,17 +24,14 @@
   import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingType;
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
  +import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType;
   import org.apache.xmlbeans.impl.binding.bts.ListArrayType;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
   import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
  -import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType;
   import org.apache.xmlbeans.impl.common.XmlStreamUtils;
   import org.apache.xmlbeans.impl.common.XmlWhitespace;
  -import org.apache.xmlbeans.impl.marshal.util.collections.ArrayIterator;
  -import org.apache.xmlbeans.impl.marshal.util.collections.EmptyIterator;
  -import org.apache.xmlbeans.impl.marshal.util.collections.ReflectiveArrayIterator;
   
   import javax.xml.namespace.NamespaceContext;
   import javax.xml.namespace.QName;
  @@ -42,7 +39,6 @@
   import javax.xml.stream.XMLStreamException;
   import javax.xml.stream.XMLStreamReader;
   import java.util.Collection;
  -import java.util.Iterator;
   import java.util.Stack;
   
   
  @@ -50,7 +46,6 @@
   {
   
       //per binding context constants
  -    private final RuntimeTypeFactory runtimeTypeFactory;
       private final BindingLoader bindingLoader;
       private final RuntimeBindingTypeTable typeTable;
   
  @@ -73,8 +68,7 @@
   
   
       //TODO: REVIEW: consider ways to reduce the number of parameters here
  -    MarshalResult(RuntimeTypeFactory runtimeTypeFactory,
  -                  BindingLoader loader,
  +    MarshalResult(BindingLoader loader,
                     RuntimeBindingTypeTable tbl,
                     NamespaceContext root_nsctx,
                     RuntimeBindingProperty property,
  @@ -82,7 +76,6 @@
                     XmlOptions options)
           throws XmlException
       {
  -        this.runtimeTypeFactory = runtimeTypeFactory;
           bindingLoader = loader;
           typeTable = tbl;
           namespaceContext = new ScopedNamespaceContext(root_nsctx);
  @@ -131,6 +124,20 @@
           }
       }
   
  +    QName fillPrefix(final QName pname)
  +    {
  +        final String uri = pname.getNamespaceURI();
  +
  +        assert uri != null;  //QName's should use "" for no namespace
  +
  +        if (uri.length() == 0) {
  +            return createQName(pname.getLocalPart());
  +        } else {
  +            String prefix = ensurePrefix(uri);
  +            return createQName(uri, pname.getLocalPart(), prefix);
  +        }
  +    }
  +
   
       String ensurePrefix(String uri)
       {
  @@ -151,8 +158,7 @@
           do {
               prefix = NSPREFIX + (++prefixCnt);
               testuri = namespaceContext.getNamespaceURI(prefix);
  -        }
  -        while (testuri != null);
  +        } while (testuri != null);
           assert prefix != null;
           namespaceContext.bindNamespace(prefix, uri);
           return prefix;
  @@ -176,14 +182,15 @@
               }
               //else go with original type and hope for the best...
           }
  -        return runtimeTypeFactory.createRuntimeType(type, typeTable, bindingLoader);
  +        return getRuntimeTypeFactory().createRuntimeType(type, typeTable, bindingLoader);
       }
   
   
       RuntimeBindingType createRuntimeBindingType(BindingType type)
           throws XmlException
       {
  -        return runtimeTypeFactory.createRuntimeType(type, typeTable, bindingLoader);
  +        return getRuntimeTypeFactory().createRuntimeType(type, typeTable,
  +                                                         bindingLoader);
       }
   
   
  @@ -614,6 +621,19 @@
       {
           XmlError e = XmlError.forMessage(msg, XmlError.SEVERITY_WARNING);
           getErrorCollection().add(e);
  +    }
  +
  +    private RuntimeTypeFactory getRuntimeTypeFactory()
  +    {
  +        return typeTable.getRuntimeTypeFactory();
  +    }
  +
  +    QName createQName(String uri, String localpart, String prefix) {
  +        return new QName(uri, localpart, prefix);
  +    }
  +
  +    QName createQName(String localpart) {
  +        return new QName(localpart);
       }
   
       private static final class BindingTypeVisitor
  
  
  
  1.24      +1 -1      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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- MarshallerImpl.java	25 Mar 2004 03:19:28 -0000	1.23
  +++ MarshallerImpl.java	8 Apr 2004 19:03:44 -0000	1.24
  @@ -101,7 +101,7 @@
           RuntimeGlobalProperty prop =
               new RuntimeGlobalProperty(elem_qn, runtime_type);
   
  -        return new MarshalResult(runtimeTypeFactory, loader, typeTable,
  +        return new MarshalResult(loader, typeTable,
                                    nscontext, prop, obj, null);
       }
   
  
  
  
  1.9       +1 -15     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/NamedXmlTypeVisitor.java
  
  Index: NamedXmlTypeVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/NamedXmlTypeVisitor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- NamedXmlTypeVisitor.java	2 Mar 2004 02:54:07 -0000	1.8
  +++ NamedXmlTypeVisitor.java	8 Apr 2004 19:03:44 -0000	1.9
  @@ -41,7 +41,7 @@
               property.getActualRuntimeType(parentObject, result);
   
           //TODO: optimize to avoid object creation
  -        name = addPrefixToName(getBindingProperty().getName());
  +        name = fillPrefix(getBindingProperty().getName());
       }
   
       protected QName getName()
  @@ -52,20 +52,6 @@
       protected final RuntimeBindingType getActualRuntimeBindingType()
       {
           return actualRuntimeBindingType;
  -    }
  -
  -    private QName addPrefixToName(final QName pname)
  -    {
  -        final String uri = pname.getNamespaceURI();
  -
  -        assert uri != null;  //QName's should use "" for no namespace
  -
  -        if (uri.length() == 0) {
  -            return new QName(pname.getLocalPart());
  -        } else {
  -            String prefix = marshalResult.ensurePrefix(uri);
  -            return new QName(uri, pname.getLocalPart(), prefix);
  -        }
       }
   
       protected final boolean needsXsiType()
  
  
  
  1.26      +2 -0      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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- RuntimeBindingTypeTable.java	7 Apr 2004 23:30:56 -0000	1.25
  +++ RuntimeBindingTypeTable.java	8 Apr 2004 19:03:44 -0000	1.26
  @@ -65,6 +65,8 @@
   
       static RuntimeBindingTypeTable createTable(RuntimeTypeFactory factory)
       {
  +        assert factory != null;
  +
           final RuntimeBindingTypeTable tbl =
               new RuntimeBindingTypeTable((Map)BUILTIN_UNMARSHALLER_MAP.clone(),
                                           (Map)BUILTIN_MARSHALLER_MAP.clone(),
  
  
  
  1.11      +1 -10     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/XmlTypeVisitor.java
  
  Index: XmlTypeVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/XmlTypeVisitor.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XmlTypeVisitor.java	2 Mar 2004 02:54:07 -0000	1.10
  +++ XmlTypeVisitor.java	8 Apr 2004 19:03:44 -0000	1.11
  @@ -91,16 +91,7 @@
   
       protected QName fillPrefix(final QName pname)
       {
  -        final String uri = pname.getNamespaceURI();
  -
  -        assert uri != null;  //QName's should use "" for no namespace
  -
  -        if (uri.length() == 0) {
  -            return new QName(pname.getLocalPart());
  -        } else {
  -            String prefix = marshalResult.ensurePrefix(uri);
  -            return new QName(uri, pname.getLocalPart(), prefix);
  -        }
  +        return marshalResult.fillPrefix(pname);
       }
   
   
  
  
  

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