From xmlbeansthorntonjeremy@example.com Wed Jun 02 02:17:50 2004 Return-Path: <xmlbeansthorntonjeremy@example.com> Delivered-To: thorntonjeremy@example.com Received: (qmail 56955 invoked from network); 2 Jun 2004 02:17:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur-2.apache.org with SMTP; 2 Jun 2004 02:17:50 -0000 Received: (qmail 66291 invoked by uid 500); 2 Jun 2004 02:18:11 -0000 Delivered-To: thorntonjeremy@example.com Received: (qmail 66256 invoked by uid 500); 2 Jun 2004 02:18:10 -0000 Mailing-List: contact thorntonjeremy@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:thorntonjeremy@example.com> List-Help: <mailto:thorntonjeremy@example.com> List-Unsubscribe: <mailto:thorntonjeremy@example.com> List-Subscribe: <mailto:thorntonjeremy@example.com> Reply-To: thorntonjeremy@example.com Delivered-To: mailing list thorntonjeremy@example.com Received: (qmail 66240 invoked by uid 99); 2 Jun 2004 02:18:09 -0000 Received: from [83.161.120.155] (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.27.1) with SMTP; Tue, 01 Jun 2004 19:18:09 -0700 Received: (qmail 56915 invoked by uid 1742); 2 Jun 2004 02:17:45 -0000 Date: 2 Jun 2004 02:17:45 -0000 Message-ID: <thorntonjeremy@example.com> From: thorntonjeremy@example.com To: thorntonjeremy@example.com Subject: cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases MarshalTests.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N zieg 2004/06/01 19:17:45 Modified: v2/src/marshal/org/apache/xmlbeans/impl/marshal AttributeRuntimeBindingType.java AttributeUnmarshaller.java BaseSimpleTypeConverter.java BindingContextFactoryImpl.java BindingContextImpl.java ByNameRuntimeBindingType.java JaxrpcEnumRuntimeBindingType.java JaxrpcEnumUnmarshaller.java ListArrayRuntimeBindingType.java LiteralPushMarshalResult.java LiteralUnmarshalResult.java MarshalResult.java NullUnmarshaller.java ObjectAnyTypeConverter.java ObjectRefTable.java PullSoapMarshalResult.java PushSoap11MarshalResult.java RefObjectTable.java RuntimeBindingProperty.java RuntimeBindingType.java Soap11Constants.java Soap11UnmarshalResult.java SoapArrayRuntimeBindingType.java SoapArrayUnmarshaller.java SoapUnmarshallerImpl.java SoapUnmarshalResult.java TylarSchemaTypeLoaderProvider.java TypeUnmarshaller.java UnmarshalResult.java WrappedArrayRuntimeBindingType.java WrappedArrayUnmarshaller.java v2/src/marshal/org/apache/xmlbeans/impl/marshal/util AttrCache.java ReflectionUtils.java v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections Accumulator.java ArrayListBasedObjectAccumulator.java BooleanList.java ByteList.java CharList.java DoubleList.java FloatList.java GenericCollectionObjectAccumulator.java HashSetBasedObjectAccumulator.java IntList.java LinkedListBasedObjectAccumulator.java LongList.java ObjectAccumulator.java ShortList.java StackBasedObjectAccumulator.java StringList.java TreeSetBasedObjectAccumulator.java VectorBasedObjectAccumulator.java v2/src/xmlpublic/org/apache/xmlbeans BindingContext.java SoapUnmarshaller.java v2/test/src/drt/drtcases MarshalTests.java Added: v2/src/marshal/org/apache/xmlbeans/impl/marshal StreamRefNavigator.java Log: soap unmarshalling phase two Revision Changes Path 1.8 +0 -12 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AttributeRuntimeBindingType.java 20 May 2004 21:09:53 -0000 1.7 +++ AttributeRuntimeBindingType.java 2 Jun 2004 02:17:42 -0000 1.8 @@ -19,7 +19,6 @@ import org.apache.xmlbeans.impl.binding.bts.BindingLoader; import org.apache.xmlbeans.impl.binding.bts.BindingType; import org.apache.xmlbeans.impl.binding.bts.QNameProperty; -import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils; import javax.xml.namespace.QName; import java.util.Collection; @@ -107,17 +106,6 @@ } protected abstract Collection getQNameProperties(); - - //some subclass will certainly need to override this - protected Object createIntermediary(UnmarshalResult context, - Object actual_object) - { - return actual_object; - } - - protected abstract Object getFinalObjectFromIntermediary(Object retval, - UnmarshalResult context) - throws XmlException; final RuntimeBindingProperty getAttributeProperty(int index) 1.7 +2 -12 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeUnmarshaller.java Index: AttributeUnmarshaller.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/AttributeUnmarshaller.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- AttributeUnmarshaller.java 20 May 2004 21:09:53 -0000 1.6 +++ AttributeUnmarshaller.java 2 Jun 2004 02:17:42 -0000 1.7 @@ -39,22 +39,12 @@ return type.getFinalObjectFromIntermediary(inter, context); } - public void unmarshal(Object object, UnmarshalResult context) - throws XmlException - { - final Object inter = type.createIntermediary(context, object); - deserializeAttributes(inter, context); - deserializeContents(inter, context); - - //this is needed to fill in all the array props - type.getFinalObjectFromIntermediary(inter, context); - } - public void unmarshalIntoIntermediary(Object intermediary, UnmarshalResult result) throws XmlException { - throw new AssertionError("UNIMP!!!"); + deserializeAttributes(intermediary, result); + deserializeContents(intermediary, result); } public Object unmarshalAttribute(UnmarshalResult context) 1.12 +0 -6 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BaseSimpleTypeConverter.java Index: BaseSimpleTypeConverter.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BaseSimpleTypeConverter.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- BaseSimpleTypeConverter.java 20 May 2004 21:09:53 -0000 1.11 +++ BaseSimpleTypeConverter.java 2 Jun 2004 02:17:42 -0000 1.12 @@ -51,12 +51,6 @@ } } - public void unmarshal(Object object, UnmarshalResult result) - throws XmlException - { - throw new UnsupportedOperationException("not supported: this=" + this); - } - public void unmarshalIntoIntermediary(Object intermediary, UnmarshalResult result) { 1.18 +46 -45 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextFactoryImpl.java Index: BindingContextFactoryImpl.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextFactoryImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- BindingContextFactoryImpl.java 28 May 2004 17:02:53 -0000 1.17 +++ BindingContextFactoryImpl.java 2 Jun 2004 02:17:42 -0000 1.18 @@ -39,15 +39,16 @@ public final class BindingContextFactoryImpl extends BindingContextFactory { - public BindingContext createBindingContext(ClassLoader cl) throws IOException, XmlException { - if (cl == null) throw new IllegalArgumentException("null uris"); - //FIXME loader class needs to be pluggable - TylarLoader loader = DefaultTylarLoader.getInstance(); - if (loader == null) throw new IllegalStateException("null loader"); - return createBindingContext(loader.load(cl)); - } + public BindingContext createBindingContext(ClassLoader cl) throws IOException, XmlException + { + if (cl == null) throw new IllegalArgumentException("null uris"); + //FIXME loader class needs to be pluggable + TylarLoader loader = DefaultTylarLoader.getInstance(); + if (loader == null) throw new IllegalStateException("null loader"); + return createBindingContext(loader.load(cl)); + } - public BindingContext createBindingContext(URL[] tylarUrls) + public BindingContext createBindingContext(URL[] tylarUrls) throws IOException, XmlException { if (tylarUrls == null) throw new IllegalArgumentException("null uris"); @@ -63,7 +64,7 @@ // Of course, exposing it means we expose Tylar to the public as well, // and this should be done with caution. public BindingContext createBindingContext(Tylar tylar) - throws IOException, XmlException + throws IOException, XmlException { // build the loader chain - this is the binding files plus // the builtin loader @@ -116,42 +117,42 @@ } - // ======================================================================== - // Deprecated methods + // ======================================================================== + // Deprecated methods - /** - * @deprecated - */ - public BindingContext createBindingContext(URI tylarUri) - throws IOException, XmlException - { - return createBindingContext(new URI[]{tylarUri}); - } - - /** - * @deprecated - */ - public BindingContext createBindingContext(URI[] tylarUris) - throws IOException, XmlException - { - if (tylarUris == null) throw new IllegalArgumentException("null uris"); - //FIXME loader class needs to be pluggable - TylarLoader loader = DefaultTylarLoader.getInstance(); - if (loader == null) throw new IllegalStateException("null loader"); - return createBindingContext(((DefaultTylarLoader)loader).load(tylarUris)); - } - - /** - * @deprecated - */ - public BindingContext createBindingContext(JarInputStream jar) - throws IOException, XmlException - { - if (jar == null) throw new IllegalArgumentException("null InputStream"); - //FIXME loader class needs to be pluggable - TylarLoader loader = DefaultTylarLoader.getInstance(); - if (loader == null) throw new IllegalStateException("null TylarLoader"); - return createBindingContext(((DefaultTylarLoader)loader).load(jar)); - } + /** + * @deprecated + */ + public BindingContext createBindingContext(URI tylarUri) + throws IOException, XmlException + { + return createBindingContext(new URI[]{tylarUri}); + } + + /** + * @deprecated + */ + public BindingContext createBindingContext(URI[] tylarUris) + throws IOException, XmlException + { + if (tylarUris == null) throw new IllegalArgumentException("null uris"); + //FIXME loader class needs to be pluggable + TylarLoader loader = DefaultTylarLoader.getInstance(); + if (loader == null) throw new IllegalStateException("null loader"); + return createBindingContext(((DefaultTylarLoader)loader).load(tylarUris)); + } + + /** + * @deprecated + */ + public BindingContext createBindingContext(JarInputStream jar) + throws IOException, XmlException + { + if (jar == null) throw new IllegalArgumentException("null InputStream"); + //FIXME loader class needs to be pluggable + TylarLoader loader = DefaultTylarLoader.getInstance(); + if (loader == null) throw new IllegalStateException("null TylarLoader"); + return createBindingContext(((DefaultTylarLoader)loader).load(jar)); + } } 1.15 +11 -3 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextImpl.java Index: BindingContextImpl.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextImpl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- BindingContextImpl.java 20 May 2004 21:09:53 -0000 1.14 +++ BindingContextImpl.java 2 Jun 2004 02:17:42 -0000 1.15 @@ -19,11 +19,12 @@ import org.apache.xmlbeans.EncodingStyle; import org.apache.xmlbeans.Marshaller; import org.apache.xmlbeans.SoapMarshaller; +import org.apache.xmlbeans.SoapUnmarshaller; import org.apache.xmlbeans.Unmarshaller; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.SoapUnmarshaller; import org.apache.xmlbeans.impl.binding.bts.BindingLoader; +import org.w3c.dom.Node; import java.util.Collection; @@ -95,16 +96,23 @@ encodingStyle); } - public SoapUnmarshaller createSoapUnmarshaller(EncodingStyle encodingStyle) + public SoapUnmarshaller createSoapUnmarshaller(EncodingStyle encodingStyle, + Node referenceRoot) throws XmlException { if (encodingStyle == null) { throw new IllegalArgumentException("null encodingStyle"); } + if (referenceRoot == null) { + throw new IllegalArgumentException("null referenceRoot"); + } + + return new SoapUnmarshallerImpl(bindingLoader, typeTable, - encodingStyle); + encodingStyle, + referenceRoot); } static Collection extractErrorHandler(XmlOptions options) 1.41 +0 -2 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.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- ByNameRuntimeBindingType.java 10 May 2004 06:06:33 -0000 1.40 +++ ByNameRuntimeBindingType.java 2 Jun 2004 02:17:42 -0000 1.41 @@ -19,7 +19,6 @@ import org.apache.xmlbeans.impl.binding.bts.BindingLoader; import org.apache.xmlbeans.impl.binding.bts.ByNameBean; import org.apache.xmlbeans.impl.binding.bts.QNameProperty; -import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils; import org.apache.xmlbeans.impl.marshal.util.collections.Accumulator; import org.apache.xmlbeans.impl.marshal.util.collections.AccumulatorFactory; @@ -113,7 +112,6 @@ } } - //some subclass will certainly need to override this protected Object createIntermediary(UnmarshalResult context, Object actual_object) { 1.7 +1 -1 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumRuntimeBindingType.java Index: JaxrpcEnumRuntimeBindingType.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumRuntimeBindingType.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JaxrpcEnumRuntimeBindingType.java 4 May 2004 21:33:22 -0000 1.6 +++ JaxrpcEnumRuntimeBindingType.java 2 Jun 2004 02:17:42 -0000 1.7 @@ -20,8 +20,8 @@ import org.apache.xmlbeans.impl.binding.bts.BindingType; import org.apache.xmlbeans.impl.binding.bts.BindingTypeName; import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType; -import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils; import org.apache.xmlbeans.impl.common.InvalidLexicalValueException; +import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils; import java.lang.reflect.Method; 1.7 +0 -6 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumUnmarshaller.java Index: JaxrpcEnumUnmarshaller.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumUnmarshaller.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JaxrpcEnumUnmarshaller.java 20 May 2004 21:09:53 -0000 1.6 +++ JaxrpcEnumUnmarshaller.java 2 Jun 2004 02:17:42 -0000 1.7 @@ -43,12 +43,6 @@ } } - public void unmarshal(Object object, UnmarshalResult result) - throws XmlException - { - throw new UnsupportedOperationException("not supported: this=" + this); - } - public void unmarshalIntoIntermediary(Object intermediary, UnmarshalResult result) throws XmlException 1.9 +0 -1 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ListArrayRuntimeBindingType.java 5 May 2004 00:46:56 -0000 1.8 +++ ListArrayRuntimeBindingType.java 2 Jun 2004 02:17:42 -0000 1.9 @@ -23,7 +23,6 @@ import org.apache.xmlbeans.impl.marshal.util.collections.Accumulator; import javax.xml.namespace.QName; -import java.lang.reflect.Array; final class ListArrayRuntimeBindingType extends RuntimeBindingType 1.2 +0 -5 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/LiteralPushMarshalResult.java Index: LiteralPushMarshalResult.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/LiteralPushMarshalResult.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LiteralPushMarshalResult.java 9 May 2004 23:52:16 -0000 1.1 +++ LiteralPushMarshalResult.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -18,13 +18,8 @@ import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.impl.binding.bts.BindingLoader; -import org.apache.xmlbeans.impl.marshal.util.ArrayUtils; -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; -import java.util.Iterator; final class LiteralPushMarshalResult extends PushMarshalResult 1.2 +5 -4 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/LiteralUnmarshalResult.java Index: LiteralUnmarshalResult.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/LiteralUnmarshalResult.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LiteralUnmarshalResult.java 20 May 2004 21:09:53 -0000 1.1 +++ LiteralUnmarshalResult.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -20,9 +20,8 @@ import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.impl.binding.bts.BindingLoader; -import org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader; -import org.apache.xmlbeans.impl.richParser.XMLStreamReaderExt; import org.apache.xmlbeans.impl.common.InvalidLexicalValueException; +import org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamReader; @@ -118,8 +117,10 @@ final Object this_val; if (prop.hasFactory()) { - this_val = prop.createObjectViaFactory(inter, actual_rtt); - actual_rtt.getUnmarshaller().unmarshal(this_val, this); + final Object prop_inter = + prop.createIntermediary(inter, actual_rtt, this); + actual_rtt.getUnmarshaller().unmarshalIntoIntermediary(prop_inter, this); + this_val = actual_rtt.getFinalObjectFromIntermediary(prop_inter, this); } else { TypeUnmarshaller um = getUnmarshaller(actual_rtt); this_val = um.unmarshal(this); 1.34 +2 -1 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.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- MarshalResult.java 20 May 2004 21:09:53 -0000 1.33 +++ MarshalResult.java 2 Jun 2004 02:17:42 -0000 1.34 @@ -88,7 +88,8 @@ do { prefix = NSPREFIX + (++prefixCnt); testuri = getNamespaceContext().getNamespaceURI(prefix); - } while (testuri != null); + } + while (testuri != null); assert prefix != null; return prefix; } 1.11 +0 -6 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/NullUnmarshaller.java Index: NullUnmarshaller.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/NullUnmarshaller.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- NullUnmarshaller.java 20 May 2004 21:09:53 -0000 1.10 +++ NullUnmarshaller.java 2 Jun 2004 02:17:42 -0000 1.11 @@ -38,12 +38,6 @@ return null; } - public void unmarshal(Object object, UnmarshalResult result) - throws XmlException - { - throw new UnsupportedOperationException("not supported: this=" + this); - } - public void unmarshalIntoIntermediary(Object intermediary, UnmarshalResult result) throws XmlException 1.6 +0 -6 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ObjectAnyTypeConverter.java Index: ObjectAnyTypeConverter.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ObjectAnyTypeConverter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ObjectAnyTypeConverter.java 20 May 2004 21:09:53 -0000 1.5 +++ ObjectAnyTypeConverter.java 2 Jun 2004 02:17:42 -0000 1.6 @@ -32,12 +32,6 @@ throw new AssertionError("GENERIC XML UNIMPLEMENTED"); } - public void unmarshal(Object object, UnmarshalResult result) - throws XmlException - { - throw new UnsupportedOperationException("not supported: this=" + this); - } - public void unmarshalIntoIntermediary(Object intermediary, UnmarshalResult result) { 1.3 +0 -2 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ObjectRefTable.java Index: ObjectRefTable.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ObjectRefTable.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ObjectRefTable.java 20 May 2004 21:09:53 -0000 1.2 +++ ObjectRefTable.java 2 Jun 2004 02:17:42 -0000 1.3 @@ -15,8 +15,6 @@ package org.apache.xmlbeans.impl.marshal; -import org.apache.xmlbeans.impl.marshal.RuntimeBindingProperty; - import java.util.IdentityHashMap; import java.util.Iterator; import java.util.Map; 1.3 +1 -1 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PullSoapMarshalResult.java Index: PullSoapMarshalResult.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PullSoapMarshalResult.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PullSoapMarshalResult.java 20 May 2004 21:09:53 -0000 1.2 +++ PullSoapMarshalResult.java 2 Jun 2004 02:17:42 -0000 1.3 @@ -65,7 +65,7 @@ int id = objectRefTable.getId(top_lvl_obj); if (id >= 0) { fillAndAddAttribute(getIdAttributeName(), - Soap11Constants.constructRefValueFromId(id)); + Soap11Constants.constructIdValueFromId(id)); } } 1.3 +3 -3 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PushSoap11MarshalResult.java Index: PushSoap11MarshalResult.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PushSoap11MarshalResult.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PushSoap11MarshalResult.java 20 May 2004 21:09:53 -0000 1.2 +++ PushSoap11MarshalResult.java 2 Jun 2004 02:17:42 -0000 1.3 @@ -15,9 +15,9 @@ package org.apache.xmlbeans.impl.marshal; -import org.apache.xmlbeans.impl.binding.bts.BindingLoader; -import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlOptions; +import org.apache.xmlbeans.impl.binding.bts.BindingLoader; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamWriter; @@ -52,6 +52,6 @@ protected String getIdValue(int id) { - return Soap11Constants.constructRefValueFromId(id); + return Soap11Constants.constructIdValueFromId(id); } } 1.2 +47 -3 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RefObjectTable.java Index: RefObjectTable.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RefObjectTable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RefObjectTable.java 20 May 2004 21:09:53 -0000 1.1 +++ RefObjectTable.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -15,8 +15,8 @@ package org.apache.xmlbeans.impl.marshal; -import java.util.Map; import java.util.HashMap; +import java.util.Map; final class RefObjectTable { @@ -24,11 +24,55 @@ Object getObjectForRef(String ref) { - return refTable.get(ref); + RefEntry e = getEntryForRef(ref); + if (e == null) return null; + return e.final_obj; + } + + Object getInterForRef(String ref) + { + RefEntry e = getEntryForRef(ref); + if (e == null) return null; + return e.inter; + } + + RefEntry getEntryForRef(String ref) + { + return (RefEntry)refTable.get(ref); + } + + void putForRef(String ref, Object inter, Object actual_obj) + { + refTable.put(ref, new RefEntry(inter, actual_obj)); } void putObjectForRef(String ref, Object val) { - refTable.put(ref, val); + RefEntry e = (RefEntry)refTable.get(ref); + assert e != null; + assert e.inter != null; + e.final_obj = val; + } + + void putIntermediateForRef(String ref, Object inter) + { + refTable.put(ref, new RefEntry(inter)); + } + + final static class RefEntry + { + RefEntry(Object inter, Object final_obj) + { + this.inter = inter; + this.final_obj = final_obj; + } + + RefEntry(Object inter) + { + this.inter = inter; + } + + Object inter; + Object final_obj; } } 1.23 +26 -4 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- RuntimeBindingProperty.java 20 May 2004 21:09:53 -0000 1.22 +++ RuntimeBindingProperty.java 2 Jun 2004 02:17:42 -0000 1.23 @@ -88,6 +88,20 @@ abstract QName getName(); + protected final Object createIntermediary(Object parent_inter, + RuntimeBindingType actual_rtt, + UnmarshalResult context) + throws XmlException + { + if (hasFactory()) { + final Object obj = createObjectViaFactory(parent_inter, actual_rtt); + return actual_rtt.createIntermediary(context, obj); + } else { + return actual_rtt.createIntermediary(context); + } + } + + //non simple type props can throw an exception final CharSequence getLexical(Object value, MarshalResult result) @@ -151,17 +165,16 @@ } - //these methods should be used only by this type and subclasses protected abstract void fill(Object inter, Object prop_obj) throws XmlException; - protected boolean hasFactory() + protected final boolean hasFactory() { return parentFactoryMethod != null; } - Object createObjectViaFactory(Object inter, - final RuntimeBindingType actual_rtt) + private Object createObjectViaFactory(Object inter, + final RuntimeBindingType actual_rtt) throws XmlException { final Object actual_obj = @@ -183,5 +196,14 @@ params); } + + public String toString() + { + return "RuntimeBindingProperty{" + + "bindingType=" + this.getRuntimeBindingType().getBindingType() + + "containingType=" + containingType + + "}"; + } + } 1.23 +25 -0 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- RuntimeBindingType.java 20 May 2004 21:09:53 -0000 1.22 +++ RuntimeBindingType.java 2 Jun 2004 02:17:42 -0000 1.23 @@ -88,14 +88,36 @@ protected Object createIntermediary(UnmarshalResult context) { + //TODO: make this abstract throw new UnsupportedOperationException("this=" + this); } + + //some subclass will certainly need to override this + protected Object createIntermediary(UnmarshalResult context, + Object actual_object) + { + return actual_object; + } + + Object getObjectFromIntermediate(Object inter) { return inter; } + protected Object getFinalObjectFromIntermediary(Object inter, + UnmarshalResult context) + throws XmlException + { + return inter; + } + + boolean isObjectFromIntermediateIdempotent() + { + return true; + } + final BindingType getBindingType() { return bindingType; @@ -324,6 +346,9 @@ protected void setValue(final Object target, final Object prop_obj) throws XmlException { + assert prop_obj == null || propertyClass.isPrimitive() || propertyClass.isInstance(prop_obj) : + " wrong property type: " + prop_obj.getClass() + " expected " + propertyClass; + if (field == null) { ReflectionUtils.invokeMethod(target, setMethod, new Object[]{prop_obj}); 1.2 +5 -2 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/Soap11Constants.java Index: Soap11Constants.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/Soap11Constants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Soap11Constants.java 20 May 2004 21:09:53 -0000 1.1 +++ Soap11Constants.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -15,8 +15,6 @@ package org.apache.xmlbeans.impl.marshal; -import org.apache.xmlbeans.impl.common.InvalidLexicalValueException; - import javax.xml.namespace.QName; final class Soap11Constants @@ -35,6 +33,11 @@ static String constructRefValueFromId(int id) { return REF_PREFIX + Integer.toString(id); + } + + static String constructIdValueFromId(int id) + { + return ID_PREFIX + Integer.toString(id); } 1.2 +3 -2 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/Soap11UnmarshalResult.java Index: Soap11UnmarshalResult.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/Soap11UnmarshalResult.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Soap11UnmarshalResult.java 20 May 2004 21:09:53 -0000 1.1 +++ Soap11UnmarshalResult.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -28,9 +28,10 @@ Soap11UnmarshalResult(BindingLoader loader, RuntimeBindingTypeTable typeTable, RefObjectTable refObjectTable, - XmlOptions options) + StreamRefNavigator refNavigator, + XmlOptions opts) { - super(loader, typeTable, refObjectTable, options); + super(loader, typeTable, refObjectTable, refNavigator, opts); } protected String getReferencedIdFromAttributeValue(String attval) 1.2 +5 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapArrayRuntimeBindingType.java Index: SoapArrayRuntimeBindingType.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapArrayRuntimeBindingType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SoapArrayRuntimeBindingType.java 21 May 2004 01:20:09 -0000 1.1 +++ SoapArrayRuntimeBindingType.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -95,6 +95,11 @@ return acc.getFinalArray(); } + boolean isObjectFromIntermediateIdempotent() + { + return false; + } + static final class ItemProperty extends RuntimeBindingProperty { 1.2 +0 -10 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapArrayUnmarshaller.java Index: SoapArrayUnmarshaller.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapArrayUnmarshaller.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SoapArrayUnmarshaller.java 21 May 2004 01:20:09 -0000 1.1 +++ SoapArrayUnmarshaller.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -18,8 +18,6 @@ import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.impl.binding.bts.BindingLoader; -import javax.xml.namespace.QName; - public class SoapArrayUnmarshaller implements TypeUnmarshaller { @@ -39,12 +37,6 @@ return type.getFinalObjectFromIntermediary(inter); } - public void unmarshal(Object object, UnmarshalResult result) - throws XmlException - { - throw new UnsupportedOperationException("not supported: this=" + this); - } - public void unmarshalIntoIntermediary(Object intermediary, UnmarshalResult result) throws XmlException @@ -52,8 +44,6 @@ throw new AssertionError("UNIMP!!"); } - //TODO: cleanup this code. We are doing extra work for assertion checking - //also might consider consolidating the common code with the ByNameUnmarshaller private void deserializeContents(Object inter, UnmarshalResult context) throws XmlException 1.2 +54 -5 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapUnmarshallerImpl.java Index: SoapUnmarshallerImpl.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapUnmarshallerImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SoapUnmarshallerImpl.java 20 May 2004 21:09:53 -0000 1.1 +++ SoapUnmarshallerImpl.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -20,30 +20,39 @@ import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.impl.binding.bts.BindingLoader; +import org.apache.xmlbeans.impl.marshal.util.AttrCache; +import org.apache.xmlbeans.impl.newstore2.Public2; +import org.w3c.dom.Node; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamReader; final class SoapUnmarshallerImpl - implements SoapUnmarshaller + implements SoapUnmarshaller, StreamRefNavigator + { private final BindingLoader bindingLoader; private final RuntimeBindingTypeTable typeTable; private final EncodingStyle encodingStyle; private final RefObjectTable refObjectTable = new RefObjectTable(); + private final Node referenceRoot; + private AttrCache attrCache; SoapUnmarshallerImpl(BindingLoader loader, RuntimeBindingTypeTable typeTable, - EncodingStyle encodingStyle) + EncodingStyle encodingStyle, + Node reference_root) { assert loader != null; assert typeTable != null; assert encodingStyle != null; + assert reference_root != null; this.bindingLoader = loader; this.typeTable = typeTable; this.encodingStyle = encodingStyle; + this.referenceRoot = reference_root; } public Object unmarshalType(XMLStreamReader reader, @@ -60,16 +69,56 @@ throw new IllegalStateException("reader must be positioned on a start element"); } - final SoapUnmarshalResult result; + final SoapUnmarshalResult result = createMarshalResult(options); + return result.unmarshalType(reader, schemaType, javaType); + } + + private SoapUnmarshalResult createMarshalResult(XmlOptions options) + { + SoapUnmarshalResult result; if (EncodingStyle.SOAP11 == encodingStyle) { - result = new Soap11UnmarshalResult(bindingLoader, typeTable, refObjectTable, options); + result = new Soap11UnmarshalResult(bindingLoader, typeTable, + refObjectTable, this, + options); } else if (EncodingStyle.SOAP12 == encodingStyle) { throw new AssertionError("soap 12 UNIMP: " + encodingStyle); } else { throw new AssertionError("unknown encoding style: " + encodingStyle); } + return result; + } + private QName getIdQName() + { - return result.unmarshalType(reader, schemaType, javaType); + if (EncodingStyle.SOAP11 == encodingStyle) { + return Soap11Constants.ID_NAME; + } else if (EncodingStyle.SOAP12 == encodingStyle) { + throw new AssertionError("soap 12 is unimplemented"); + } else { + throw new AssertionError("unknown encoding style: " + encodingStyle); + } + + } + + public XMLStreamReader lookupRef(String ref) + throws XmlException + { + if (attrCache == null) { + attrCache = new AttrCache(referenceRoot, getIdQName()); + } + final Node target_node = attrCache.lookup(ref); + if (target_node == null) { + return null; + } + + assert target_node.getNodeType() == Node.ELEMENT_NODE; + + final XMLStreamReader target_stream = Public2.getStream(target_node); + assert target_stream.isStartElement(); + + return target_stream; } + + } 1.2 +91 -36 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapUnmarshalResult.java Index: SoapUnmarshalResult.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapUnmarshalResult.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SoapUnmarshalResult.java 20 May 2004 21:09:53 -0000 1.1 +++ SoapUnmarshalResult.java 2 Jun 2004 02:17:42 -0000 1.2 @@ -19,8 +19,10 @@ import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.impl.binding.bts.BindingLoader; import org.apache.xmlbeans.impl.common.InvalidLexicalValueException; +import org.apache.xmlbeans.impl.common.XmlStreamUtils; import org.apache.xmlbeans.impl.common.XmlWhitespace; import org.apache.xmlbeans.impl.richParser.XMLStreamReaderExt; +import org.apache.xmlbeans.impl.richParser.XMLStreamReaderExtImpl; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; @@ -32,14 +34,18 @@ private final SoapAttributeHolder soapAttributeHolder = new SoapAttributeHolder(); private final RefObjectTable refObjectTable; + private final StreamRefNavigator streamRefNavigator; SoapUnmarshalResult(BindingLoader loader, RuntimeBindingTypeTable typeTable, RefObjectTable refObjectTable, + StreamRefNavigator refNavigator, XmlOptions options) { super(loader, typeTable, options); this.refObjectTable = refObjectTable; + assert refNavigator != null; + this.streamRefNavigator = refNavigator; } protected XMLStreamReader getValidatingStream(XMLStreamReader reader) @@ -65,42 +71,75 @@ updateSoapAttributes(); final String ref = soapAttributeHolder.ref; + Object tmpval = null; if (ref != null) { - baseReader = relocateStreamToRef(ref); - updateSoapAttributes(); - updateAttributeState(); + tmpval = getObjectForRefFromTable(ref); + if (tmpval == null) { + Object tmp_inter = getInterForRefFromTable(ref); + if (tmp_inter == null) { + baseReader = relocateStreamToRef(ref); + updateSoapAttributes(); + updateAttributeState(); + } else { + throw new AssertionError("FIXME"); + } + } else { + prop.fill(inter, tmpval); + skipElement(); + } } - try { - final RuntimeBindingType actual_rtt = - this.determineActualRuntimeType(prop.getRuntimeBindingType()); + if (tmpval == null) { + try { + final RuntimeBindingType actual_rtt = + this.determineActualRuntimeType(prop.getRuntimeBindingType()); - final Object this_val = - unmarshalElementProperty(prop, inter, actual_rtt); + final Object this_val = + unmarshalElementProperty(prop, inter, actual_rtt); - prop.fill(inter, this_val); - } - catch (InvalidLexicalValueException ilve) { - //unlike attributes, the error has been added to the this - //already via BaseSimpleTypeConveter... + prop.fill(inter, this_val); + } + catch (InvalidLexicalValueException ilve) { + //unlike attributes, the error has been added to the this + //already via BaseSimpleTypeConveter... + } } if (baseReader != curr_reader) { baseReader = curr_reader; - updateAttributeState(); //TODO: do we really need this here? + skipElement(); } } + private Object getObjectForRefFromTable(String ref) + { + //TODO: mask null values + + final Object obj = refObjectTable.getObjectForRef(ref); + return obj; + } + + private Object getInterForRefFromTable(String ref) + { + //TODO: mask null values + + final Object obj = refObjectTable.getInterForRef(ref); + return obj; + } + private XMLStreamReaderExt relocateStreamToRef(String ref) + throws XmlException { - throw new AssertionError("UNIMP"); + assert streamRefNavigator != null; -// XMLStreamReaderExtImpl impl = (XMLStreamReaderExtImpl)baseReader; -// final XMLStreamReader underlyingXmlStream = impl.getUnderlyingXmlStream(); -// final Node node = Public2.getNode(underlyingXmlStream); -// final XmlCursor cursor = Public2.getCursor(node); -// final XMLStreamReader reader = cursor.newXMLStreamReader(); -// return new XMLStreamReaderExtImpl(reader); + final XMLStreamReader reader = streamRefNavigator.lookupRef(ref); + + if (reader == null) { + //TODO: better error handling in this case!! + throw new XmlException("failed to deref " + ref); + } + + return new XMLStreamReaderExtImpl(reader); } private void updateSoapAttributes() @@ -120,7 +159,8 @@ final XMLStreamReaderExt reader = baseReader; - assert reader.isStartElement(); + assert reader.isStartElement() : + " illegal state: " + XmlStreamUtils.printEvent(reader); soapAttributeHolder.clear(); @@ -191,15 +231,19 @@ } final Object this_val; - if (prop.hasFactory()) { - this_val = prop.createObjectViaFactory(inter, actual_rtt); - addIdToTable(this_val); - actual_rtt.getUnmarshaller().unmarshal(this_val, this); - } else if (actual_rtt.hasElementChildren()) { - final Object intermediary = actual_rtt.createIntermediary(this); - this_val = actual_rtt.getObjectFromIntermediate(intermediary); - addIdToTable(this_val); - actual_rtt.getUnmarshaller().unmarshalIntoIntermediary(intermediary, this); + + + if (actual_rtt.hasElementChildren()) { + final Object prop_inter = prop.createIntermediary(inter, actual_rtt, this); + + final String id = soapAttributeHolder.id; + final boolean update_again = updateRefTable(actual_rtt, prop_inter, id); + + actual_rtt.getUnmarshaller().unmarshalIntoIntermediary(prop_inter, this); + this_val = actual_rtt.getFinalObjectFromIntermediary(prop_inter, this); + if (update_again) { + refObjectTable.putObjectForRef(id, this_val); + } } else { TypeUnmarshaller um = getUnmarshaller(actual_rtt); this_val = um.unmarshal(this); @@ -207,11 +251,22 @@ return this_val; } - private void addIdToTable(final Object this_val) - { - final String id = soapAttributeHolder.id; - if (id != null) - refObjectTable.putObjectForRef(id, this_val); + private boolean updateRefTable(RuntimeBindingType actual_rtt, + Object prop_inter, + String id) + { + boolean update_again = false; + if (id != null) { + if (actual_rtt.isObjectFromIntermediateIdempotent()) { + refObjectTable.putForRef(id, + prop_inter, + actual_rtt.getObjectFromIntermediate(prop_inter)); + } else { + refObjectTable.putIntermediateForRef(id, prop_inter); + update_again = true; + } + } + return update_again; } 1.5 +9 -7 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TylarSchemaTypeLoaderProvider.java Index: TylarSchemaTypeLoaderProvider.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TylarSchemaTypeLoaderProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TylarSchemaTypeLoaderProvider.java 25 May 2004 20:44:46 -0000 1.4 +++ TylarSchemaTypeLoaderProvider.java 2 Jun 2004 02:17:42 -0000 1.5 @@ -36,13 +36,15 @@ { if (schemaTypeLoader == null) { try { - schemaTypeLoader = tylar.getSchemaTypeLoader(); - //REVIEW - Scott: this method throws now, not sure how you - //want to handle it. - } catch(IOException ioe) { - ioe.printStackTrace(); - } catch(XmlException xe) { - xe.printStackTrace(); + schemaTypeLoader = tylar.getSchemaTypeLoader(); + //REVIEW - Scott: this method throws now, not sure how you + //want to handle it. + } + catch (IOException ioe) { + ioe.printStackTrace(); + } + catch (XmlException xe) { + xe.printStackTrace(); } } assert schemaTypeLoader != null; 1.13 +0 -15 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TypeUnmarshaller.java Index: TypeUnmarshaller.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TypeUnmarshaller.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- TypeUnmarshaller.java 20 May 2004 21:09:53 -0000 1.12 +++ TypeUnmarshaller.java 2 Jun 2004 02:17:42 -0000 1.13 @@ -41,21 +41,6 @@ /** - * Unmarshal into an existing object (i.e. fill the object's properties). - * - * This method is optional and TypeUnmarshaller's for immutable - * types (e.g. java.lang.String) will throw UnsupportedOperationException - * - * @param object Object who's properties will be filled. - * @param result - * @throws UnsupportedOperationException if not appropriate for this type - * @throws XmlException - */ - void unmarshal(Object object, UnmarshalResult result) - throws XmlException; - - - /** * unmarshal into an intermediate value. required only for types that * have element children. used for soap unmarshalling * 1.27 +23 -22 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.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- UnmarshalResult.java 20 May 2004 21:09:53 -0000 1.26 +++ UnmarshalResult.java 2 Jun 2004 02:17:42 -0000 1.27 @@ -128,7 +128,7 @@ return baseReader.getNamespaceContext(); } - void addError(String msg) + private void addError(String msg) { addError(msg, baseReader.getLocation()); } @@ -143,7 +143,7 @@ } - void addError(String msg, Location location) + final void addError(String msg, Location location) { assert location != null; MarshalStreamUtils.addError(errors, msg, location); @@ -154,7 +154,7 @@ return errors; } - Object unmarshalDocument(XMLStreamReader reader) + final Object unmarshalDocument(XMLStreamReader reader) throws XmlException { enrichXmlStream(getValidatingStream(reader)); @@ -164,7 +164,7 @@ } - protected Object unmarshalBindingType(BindingType bindingType) + private Object unmarshalBindingType(BindingType bindingType) throws XmlException { updateAttributeState(); @@ -183,8 +183,9 @@ } else { final Object initial_obj = of.createObject(rtt.getJavaType()); um = rtt.getUnmarshaller(); - um.unmarshal(initial_obj, this); - return initial_obj; + final Object inter = rtt.createIntermediary(this, initial_obj); + um.unmarshalIntoIntermediary(inter, this); + return rtt.getFinalObjectFromIntermediary(inter, this); } } catch (InvalidLexicalValueException ilve) { @@ -194,7 +195,7 @@ } } - protected ObjectFactory extractObjectFactory() + private ObjectFactory extractObjectFactory() { if (options == null) return null; @@ -202,9 +203,9 @@ (ObjectFactory)options.get(XmlOptions.UNMARSHAL_INITIAL_OBJECT_FACTORY); } - Object unmarshalType(XMLStreamReader reader, - QName schemaType, - String javaType) + final Object unmarshalType(XMLStreamReader reader, + QName schemaType, + String javaType) throws XmlException { doctorStream(schemaType, reader); @@ -245,9 +246,9 @@ throws XmlException; - Object unmarshalElement(XMLStreamReader reader, - QName globalElement, - String javaType) + final Object unmarshalElement(XMLStreamReader reader, + QName globalElement, + String javaType) throws XmlException { final BindingType binding_type = @@ -768,7 +769,7 @@ return xsiAttributeHolder.xsiType; } - boolean hasXsiNil() throws XmlException + private boolean hasXsiNil() throws XmlException { if (!gotXsiAttributes) { getXsiAttributes(); @@ -793,11 +794,11 @@ * * @return false if we hit an end element (any end element at all) */ - boolean advanceToNextStartElement() + final boolean advanceToNextStartElement() throws XmlException { - final boolean ret; - ret = MarshalStreamUtils.advanceToNextStartElement(baseReader); + final boolean ret = + MarshalStreamUtils.advanceToNextStartElement(baseReader); updateAttributeState(); return ret; } @@ -835,7 +836,7 @@ } - protected void updateAttributeState() + protected final void updateAttributeState() { xsiAttributeHolder.reset(); gotXsiAttributes = false; @@ -879,7 +880,7 @@ return baseReader.getNamespaceURI(); } - void skipElement() + final void skipElement() throws XmlException { MarshalStreamUtils.skipElement(baseReader); @@ -887,7 +888,7 @@ } - void advanceAttribute() + final void advanceAttribute() { assert hasMoreAttributes(); assert currentAttributeCount != INVALID; @@ -924,7 +925,7 @@ return baseReader.getAttributeLocalName(currentAttributeIndex); } - void attributePresent(int att_idx) + final void attributePresent(int att_idx) { if (defaultAttributeBits == null) { int bits_size = getAttributeCount(); @@ -971,7 +972,7 @@ return false; } - RuntimeBindingType determineActualRuntimeType(RuntimeBindingType expected) + final RuntimeBindingType determineActualRuntimeType(RuntimeBindingType expected) throws XmlException { final QName xsi_type = getXsiType(); 1.11 +17 -2 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WrappedArrayRuntimeBindingType.java 5 May 2004 16:49:600.956.9433.10 +++ WrappedArrayRuntimeBindingType.java 2 Jun 2004 02:17:42 -0000 1.11 @@ -82,17 +82,32 @@ return elementProperty; } - Object createIntermediary() + protected Object createIntermediary(UnmarshalResult context) { return AccumulatorFactory.createAccumulator(getJavaType(), elementProperty.getElementClass()); + } + protected Object createIntermediary(UnmarshalResult context, + Object actual_object) + { + //cannot modify the length of an array once it is created... + final String e = "factories not supported for array types: " + + getBindingType(); + throw new UnsupportedOperationException(e); } - static Object getFinalObjectFromIntermediary(Object inter) + protected Object getFinalObjectFromIntermediary(Object inter, + UnmarshalResult context) + throws XmlException { Accumulator acc = (Accumulator)inter; return acc.getFinalArray(); + } + + boolean isObjectFromIntermediateIdempotent() + { + return false; } static final class ItemProperty 1.8 +9 -11 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WrappedArrayUnmarshaller.java 20 May 2004 21:09:53 -0000 1.7 +++ WrappedArrayUnmarshaller.java 2 Jun 2004 02:17:42 -0000 1.8 @@ -34,24 +34,19 @@ public Object unmarshal(UnmarshalResult result) throws XmlException { - final Object inter = type.createIntermediary(); - deserializeContents(inter, result); - return type.getFinalObjectFromIntermediary(inter); - } - - public void unmarshal(Object object, UnmarshalResult result) - throws XmlException - { - throw new UnsupportedOperationException("not supported: this=" + this); + final Object inter = type.createIntermediary(result); + unmarshalIntoIntermediary(inter, result); + return type.getFinalObjectFromIntermediary(inter, result); } public void unmarshalIntoIntermediary(Object intermediary, UnmarshalResult result) throws XmlException { - throw new AssertionError("UNIMP!!"); + deserializeContents(intermediary, result); } + //TODO: cleanup this code. We are doing extra work for assertion checking //also might consider consolidating the common code with the ByNameUnmarshaller private void deserializeContents(Object inter, @@ -63,11 +58,14 @@ final String ourStartLocalName = context.getLocalName(); context.next(); + final WrappedArrayRuntimeBindingType.ItemProperty elem_prop = + type.getElementProperty(); + while (context.advanceToNextStartElement()) { assert context.isStartElement(); if (matchesItemElement(context)) { - context.extractAndFillElementProp(type.getElementProperty(), inter); + context.extractAndFillElementProp(elem_prop, inter); } } 1.1 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/StreamRefNavigator.java Index: StreamRefNavigator.java =================================================================== /* Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.xmlbeans.impl.marshal; import org.apache.xmlbeans.XmlException; import javax.xml.stream.XMLStreamReader; public interface StreamRefNavigator { /** * * @param ref * @return null if unable to locate reference, else reader at target node * @throws XmlException */ XMLStreamReader lookupRef(String ref) throws XmlException; } 1.2 +43 -38 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/AttrCache.java Index: AttrCache.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/AttrCache.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AttrCache.java 21 May 2004 19:21:600.956.9433.1 +++ AttrCache.java 2 Jun 2004 02:17:44 -0000 1.2 @@ -15,95 +15,100 @@ package org.apache.xmlbeans.impl.marshal.util; -import javax.xml.namespace.QName; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor.ChangeStamp; import org.apache.xmlbeans.impl.newstore2.Public2; import org.w3c.dom.Node; + +import javax.xml.namespace.QName; import java.util.HashMap; public class AttrCache { - public AttrCache ( Node n, QName attrName ) + public AttrCache(Node n, QName attrName) { - QName[] names = new QName[ 1 ]; - names[ 0 ] = attrName; + QName[] names = new QName[1]; + names[0] = attrName; - init( n, names ); + init(n, names); } - public AttrCache ( Node n, QName[] attrNames ) + public AttrCache(Node n, QName[] attrNames) { - init( n, attrNames ); + init(n, attrNames); } - public Node lookup ( String key ) + public Node lookup(String key) { ensureCache(); - return (Node) _map.get( key ); + return (Node)_map.get(key); } - private void init ( Node n, QName[] attrNames ) + private void init(Node n, QName[] attrNames) { _node = n; _map = new HashMap(); StringBuffer sb = new StringBuffer(); - for ( int i = 0 ; i < attrNames.length ; i++ ) - { - if (attrNames[ i ].getNamespaceURI().length() > 0) - { - sb.append( "declare namespace ns" ); - sb.append( i ); - sb.append( "='" ); - sb.append( attrNames[ i ].getNamespaceURI() ); - sb.append( "' " ); + for (int i = 0; i < attrNames.length; i++) { + if (attrNames[i].getNamespaceURI().length() > 0) { + sb.append("declare namespace ns"); + sb.append(i); + sb.append("='"); + sb.append(attrNames[i].getNamespaceURI()); + sb.append("' "); } } - for ( int i = 0 ; i < attrNames.length ; i++ ) - { + for (int i = 0; i < attrNames.length; i++) { if (i > 0) - sb.append( "|" ); + sb.append("|"); - sb.append( ".//@" ); + sb.append(".//@"); - if (attrNames[ i ].getNamespaceURI().length() > 0) - { - sb.append( "ns" ); - sb.append( i ); - sb.append( ":" ); + if (attrNames[i].getNamespaceURI().length() > 0) { + sb.append("ns"); + sb.append(i); + sb.append(":"); } - sb.append( attrNames[ i ].getLocalPart() ); + sb.append(attrNames[i].getLocalPart()); } - _path = Public2.compilePath( sb.toString(), null ); + _path = Public2.compilePath(sb.toString(), null); } - private void ensureCache ( ) + private void ensureCache() { if (_stamp != null && !_stamp.hasChanged()) return; - XmlCursor c = Public2.getCursor( _node ); + XmlCursor c = Public2.getCursor(_node); _stamp = c.getDocChangeStamp(); _map.clear(); - c.selectPath( _path ); + c.selectPath(_path); - while ( c.toNextSelection() ) - _map.put( c.getTextValue(), c.getDomNode() ); + while (c.toNextSelection()) { + final String attr_val = c.getTextValue(); + + if (c.toParent()) { + _map.put(attr_val, c.getDomNode()); + } else { + //not sure why this will ever happen. + assert false : " failed to move to parent: " + c; + } + } c.dispose(); } - private Node _node; - private String _path; + private Node _node; + private String _path; private ChangeStamp _stamp; - private HashMap _map; + private HashMap _map; } 1.8 +5 -3 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java Index: ReflectionUtils.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ReflectionUtils.java 10 May 2004 06:06:33 -0000 1.7 +++ ReflectionUtils.java 2 Jun 2004 02:17:44 -0000 1.8 @@ -19,10 +19,10 @@ import org.apache.xmlbeans.impl.binding.bts.BindingProperty; import org.apache.xmlbeans.impl.binding.bts.MethodName; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.Field; public final class ReflectionUtils { @@ -34,10 +34,12 @@ Object[] params) throws XmlException { -// final Class decl = method.getDeclaringClass(); + assert method != null : "null method"; + + final Class decl = method.getDeclaringClass(); // final Class got = target.getClass(); // -// assert decl.isAssignableFrom(got) : "DECL=" + decl + " GOT:" + got; + assert target == null || decl.isInstance(target) : "DECL=" + decl + " GOT:" + target.getClass(); assert (checkParams(method, params)); 1.3 +14 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/Accumulator.java Index: Accumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/Accumulator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Accumulator.java 12 Feb 2004 20:06:18 -0000 1.2 +++ Accumulator.java 2 Jun 2004 02:17:44 -0000 1.3 @@ -23,6 +23,20 @@ void append(Object elem); + /** + * append default value for this type + * (null of Objects, normal java defaults for primtive types) + */ + void appendDefault(); + + void set(int index, Object value); + + + /** + * This method must be idempotent between calls to add or set. + * + * @return + */ Object getFinalArray(); } 1.5 +7 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ArrayListBasedObjectAccumulator.java Index: ArrayListBasedObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ArrayListBasedObjectAccumulator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ArrayListBasedObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.4 +++ ArrayListBasedObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -48,5 +48,12 @@ return (ArrayList)store; } + public void set(int index, Object value) + { + ArrayList l = (ArrayList)store; + l.set(index, value); + lastArray = null; + } + } 1.5 +24 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/BooleanList.java Index: BooleanList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/BooleanList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- BooleanList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ BooleanList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -45,8 +45,13 @@ */ public boolean[] getMinSizedArray() { + if (size == store.length) { + return store; + } + boolean[] new_a = new boolean[size]; System.arraycopy(store, 0, new_a, 0, size); + store = new_a; return new_a; } @@ -69,6 +74,25 @@ { assert (o instanceof Boolean); add(((Boolean)o).booleanValue()); + } + + public void appendDefault() + { + add(false); + } + + public void set(int index, Object value) + { + set(index, ((Boolean)value).booleanValue()); + } + + public void set(int index, boolean value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; } /** 1.5 +24 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ByteList.java Index: ByteList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ByteList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ByteList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ ByteList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -45,8 +45,13 @@ */ public byte[] getMinSizedArray() { + if (size == store.length) { + return store; + } + byte[] new_a = new byte[size]; System.arraycopy(store, 0, new_a, 0, size); + store = new_a; return new_a; } @@ -71,6 +76,16 @@ add(((Number)o).byteValue()); } + public void appendDefault() + { + add((byte)0); + } + + public void set(int index, Object value) + { + set(index, ((Number)value).byteValue()); + } + /** * Appends the specified element to the end of this list. * @@ -86,6 +101,15 @@ { //let array do range checking. return store[idx]; + } + + public void set(int index, byte value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; } 1.5 +25 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/CharList.java Index: CharList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/CharList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CharList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ CharList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -50,8 +50,13 @@ */ public char[] getMinSizedArray() { + if (size == store.length) { + return store; + } + char[] new_a = new char[size]; System.arraycopy(store, 0, new_a, 0, size); + store = new_a; return new_a; } @@ -69,6 +74,26 @@ { assert (o instanceof Character); add(((Character)o).charValue()); + } + + public void appendDefault() + { + add((char)0); + } + + public void set(int index, Object value) + { + set(index, ((Character)value).charValue()); + } + + + public void set(int index, char value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; } /** 1.5 +26 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/DoubleList.java Index: DoubleList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/DoubleList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DoubleList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ DoubleList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -48,8 +48,13 @@ */ public double[] getMinSizedArray() { + if (size == store.length) { + return store; + } + double[] new_a = new double[size]; System.arraycopy(store, 0, new_a, 0, size); + store = new_a; return new_a; } @@ -69,6 +74,27 @@ assert (o instanceof Number); add(((Number)o).doubleValue()); } + + public void appendDefault() + { + add(0); + } + + public void set(int index, Object value) + { + set(index, ((Number)value).doubleValue()); + } + + + public void set(int index, double value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; + } + /** * Appends the specified element to the end of this list. 1.5 +26 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/FloatList.java Index: FloatList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/FloatList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FloatList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ FloatList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -50,8 +50,13 @@ */ public float[] getMinSizedArray() { + if (size == store.length) { + return store; + } + float[] new_a = new float[size]; System.arraycopy(store, 0, new_a, 0, size); + store = new_a; return new_a; } @@ -70,6 +75,27 @@ { assert (o instanceof Number); add(((Number)o).floatValue()); + } + + public void appendDefault() + { + add(0f); + } + + + public void set(int index, Object value) + { + set(index, ((Number)value).floatValue()); + } + + + public void set(int index, float value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; } /** 1.4 +10 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/GenericCollectionObjectAccumulator.java Index: GenericCollectionObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/GenericCollectionObjectAccumulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- GenericCollectionObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.3 +++ GenericCollectionObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.4 @@ -47,6 +47,16 @@ container.add(elem); } + public void appendDefault() + { + append(null); + } + + public void set(int index, Object value) + { + throw new UnsupportedOperationException("no indexed access"); + } + public Object getFinalArray() { return container; 1.4 +5 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/HashSetBasedObjectAccumulator.java Index: HashSetBasedObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/HashSetBasedObjectAccumulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- HashSetBasedObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.3 +++ HashSetBasedObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.4 @@ -41,5 +41,10 @@ return (HashSet)store; } + public void set(int index, Object value) + { + throw new UnsupportedOperationException("no indexed access"); + } + } 1.5 +24 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/IntList.java Index: IntList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/IntList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- IntList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ IntList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -48,8 +48,13 @@ */ public int[] getMinSizedArray() { + if (size == store.length) { + return store; + } + int[] new_a = new int[size]; System.arraycopy(store, 0, new_a, 0, size); + store = new_a; return new_a; } @@ -67,6 +72,25 @@ { assert (o instanceof Number); add(((Number)o).intValue()); + } + + public void appendDefault() + { + add(0); + } + + public void set(int index, Object value) + { + set(index, ((Number)value).intValue()); + } + + public void set(int index, int value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; } /** 1.4 +7 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/LinkedListBasedObjectAccumulator.java Index: LinkedListBasedObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/LinkedListBasedObjectAccumulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LinkedListBasedObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.3 +++ LinkedListBasedObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.4 @@ -40,5 +40,12 @@ return (LinkedList)store; } + public void set(int index, Object value) + { + LinkedList l = (LinkedList)store; + l.set(index, value); + lastArray = null; + } + } 1.5 +26 -3 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/LongList.java Index: LongList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/LongList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- LongList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ LongList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -40,13 +40,15 @@ store = new long[initial_capacity]; } - /** - get a new array just large enough to hold the items - */ public long[] getMinSizedArray() { + if (size == store.length) { + return store; + } + long[] new_a = new long[size]; System.arraycopy(store, 0, new_a, 0, size); + store = new_a; return new_a; } @@ -70,6 +72,27 @@ assert (o instanceof Number); add(((Number)o).longValue()); } + + public void appendDefault() + { + add(0L); + } + + public void set(int index, Object value) + { + set(index, ((Number)value).longValue()); + } + + + public void set(int index, long value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; + } + /** * Appends the specified element to the end of this list. 1.7 +14 -1 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ObjectAccumulator.java Index: ObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ObjectAccumulator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.6 +++ ObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.7 @@ -26,6 +26,7 @@ private final Class componentType; private final boolean returnCollectionForArray; protected final Collection store; + protected Object[] lastArray; public ObjectAccumulator(Class component_type, @@ -56,9 +57,15 @@ { assert checkInstance(o); + lastArray = null; store.add(o); } + public final void appendDefault() + { + append(null); + } + private boolean checkInstance(Object o) { if (o == null) return true; @@ -76,8 +83,14 @@ if (returnCollectionForArray) { return store; } else { + if (lastArray != null) { + return lastArray; + } + Object[] out = (Object[])Array.newInstance(componentType, store.size()); - return store.toArray(out); + final Object[] retval = store.toArray(out); + lastArray = retval; + return retval; } } 1.5 +21 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ShortList.java Index: ShortList.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/ShortList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ShortList.java 21 Apr 2004 22:08:03 -0000 1.4 +++ ShortList.java 2 Jun 2004 02:17:44 -0000 1.5 @@ -71,6 +71,27 @@ add(((Number)o).shortValue()); } + public void appendDefault() + { + add((short)0); + } + + + public void set(int index, Object value) + { + set(index, ((Number)value).shortValue()); + } + + + public void set(int index, short value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; + } + /** * Appends the specified element to the end of this list. * 1.4 +7 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/StackBasedObjectAccumulator.java Index: StackBasedObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/StackBasedObjectAccumulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- StackBasedObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.3 +++ StackBasedObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.4 @@ -40,5 +40,12 @@ return (Stack)store; } + public void set(int index, Object value) + { + Stack s = (Stack)store; + s.set(index, value); + lastArray = null; + } + } 1.8 +19 -0 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- StringList.java 21 Apr 2004 22:08:03 -0000 1.7 +++ StringList.java 2 Jun 2004 02:17:44 -0000 1.8 @@ -72,6 +72,25 @@ add((String)o); } + public void appendDefault() + { + append(null); + } + + public void set(int index, Object value) + { + set(index, (String)value); + } + + public void set(final int index, String value) + { + ensureCapacity(index + 1); + if (index >= size) { + size = index + 1; + } + store[index] = value; + } + public void clear() { Arrays.fill(store, null); 1.4 +5 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/TreeSetBasedObjectAccumulator.java Index: TreeSetBasedObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/TreeSetBasedObjectAccumulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TreeSetBasedObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.3 +++ TreeSetBasedObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.4 @@ -41,5 +41,10 @@ return (TreeSet)store; } + public void set(int index, Object value) + { + throw new UnsupportedOperationException("no indexed access"); + } + } 1.4 +7 -0 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/VectorBasedObjectAccumulator.java Index: VectorBasedObjectAccumulator.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/collections/VectorBasedObjectAccumulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- VectorBasedObjectAccumulator.java 21 Apr 2004 22:08:03 -0000 1.3 +++ VectorBasedObjectAccumulator.java 2 Jun 2004 02:17:44 -0000 1.4 @@ -39,5 +39,12 @@ return (Vector)store; } + public void set(int index, Object value) + { + Vector v = (Vector)store; + v.set(index, value); + lastArray = null; + } + } 1.9 +6 -1 xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/BindingContext.java Index: BindingContext.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/BindingContext.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- BindingContext.java 20 May 2004 21:09:54 -0000 1.8 +++ BindingContext.java 2 Jun 2004 02:17:44 -0000 1.9 @@ -16,6 +16,10 @@ package org.apache.xmlbeans; +import org.w3c.dom.Node; + + + /** * A BindingContext contains the runtime information necessary to marshal * or unmarshal a set of types. @@ -85,7 +89,8 @@ * @return Marshaller object * @throws XmlException */ - SoapUnmarshaller createSoapUnmarshaller(EncodingStyle encodingStyle) + SoapUnmarshaller createSoapUnmarshaller(EncodingStyle encodingStyle, + Node referenceRoot) throws XmlException; } 1.2 +5 -0 xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SoapUnmarshaller.java Index: SoapUnmarshaller.java =================================================================== RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SoapUnmarshaller.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SoapUnmarshaller.java 20 May 2004 21:09:54 -0000 1.1 +++ SoapUnmarshaller.java 2 Jun 2004 02:17:44 -0000 1.2 @@ -63,4 +63,9 @@ XmlOptions options) throws XmlException; + + public interface StreamDeferer { + XMLStreamReader lookupRef(String ref); + } + } 1.67 +25 -13 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.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- MarshalTests.java 25 May 2004 20:44:46 -0000 1.66 +++ MarshalTests.java 2 Jun 2004 02:17:45 -0000 1.67 @@ -43,15 +43,15 @@ import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.impl.binding.compile.Schema2Java; import org.apache.xmlbeans.impl.common.XmlReaderToWriter; import org.apache.xmlbeans.impl.common.XmlStreamUtils; import org.apache.xmlbeans.impl.marshal.BindingContextFactoryImpl; import org.apache.xmlbeans.impl.marshal.util.ArrayUtils; +import org.apache.xmlbeans.impl.newstore2.Public2; import org.apache.xmlbeans.impl.tool.PrettyPrinter; -import org.apache.xmlbeans.impl.newstore2.Jsr173; import org.w3.x2001.xmlSchema.SchemaDocument; +import org.w3c.dom.Document; import javax.xml.namespace.QName; import javax.xml.stream.XMLInputFactory; @@ -585,9 +585,11 @@ } - public void DISABLED_testByNameSoapUnmarshal() + public void testByNameSoapUnmarshal() throws Exception { + final boolean verbose = false; + final Collection errors = new LinkedList(); final String xmldoc = createSoapExampleXmlString(errors); reportErrors(errors, "byname-marshal-soap-writer"); @@ -596,11 +598,21 @@ BindingContext bindingContext = getBindingContext(getBindingConfigDocument()); + + XmlOptions opts = new XmlOptions(); + opts.setLoadLineNumbers(); + final Document document = Public2.parse(xmldoc, opts); + + if (verbose) { + final XMLStreamReader tmp_stream = Public2.getStream(document); + dumpReader(tmp_stream, true); + tmp_stream.close(); + } + final SoapUnmarshaller um = - bindingContext.createSoapUnmarshaller(EncodingStyle.SOAP11); + bindingContext.createSoapUnmarshaller(EncodingStyle.SOAP11, document); - final XmlObject xmlObject = XmlObject.Factory.parse(xmldoc); - final XMLStreamReader xrdr = xmlObject.newXMLStreamReader(); + final XMLStreamReader xrdr = Public2.getStream(document); while (!xrdr.isStartElement()) { xrdr.next(); @@ -615,10 +627,10 @@ DFLT_ELEM_NAME.getNamespaceURI(), DFLT_ELEM_NAME.getLocalPart()); - final Object obj = - um.unmarshalType(xrdr, MYCLASS_NAME, MyClass.class.getName(), null); - inform("GOT OBJ" + obj, true); + final Object obj = um.unmarshalType(xrdr, MYCLASS_NAME, MyClass.class.getName(), null); + + inform("GOT OBJ" + obj.getClass(), verbose); xrdr.close(); } @@ -636,7 +648,7 @@ myelt.setQn(qn); myelt.setQn2(qn); - myelt.setWrappedArrayOne(new String[]{"a", "a", "b"}); + myelt.setWrappedArrayOne(new String[]{"a", "a", "b4", "b4", "a"}); MySubClass sub = new MySubClass(); sub.setBigInt(new BigInteger("23522352235223522352")); @@ -656,7 +668,7 @@ mc.setMyelt(myelt); - myelt.setStringArray(new String[]{"a", "b", "c"}); + myelt.setStringArray(new String[]{"a", "b", "c", "a", "a", "b"}); myelt.setMyClassArray(new MyClass[]{sub, new MyClass(), sub}); @@ -764,8 +776,8 @@ final long before_millis = System.currentTimeMillis(); for (int i = 0; i < trials; i++) { - bindingContext = ((BindingContextFactoryImpl)context_factory). - createBindingContextFromConfig(conf); + bindingContext = + ((BindingContextFactoryImpl)context_factory).createBindingContextFromConfig(conf); if (bindingContext == null) { throw new Exception("bad news"); --------------------------------------------------------------------- To unsubscribe, e-mail: thorntonjeremy@example.com For additional commands, e-mail: thorntonjeremy@example.com From xmlbeansthorntonjeremy@example.com Thu Jun 03 21:28:38 2004
{'source': 'Apache Software Foundation Public Mail Archives'}