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 2003/12/17 01:17:53 UTC
cvs commit: xml-xmlbeans/v2/test/cases/marshal example_config.xml
zieg 2003/12/16 16:17:53
Modified: v2/src/marshal/org/apache/xmlbeans/impl/marshal
ByNameRuntimeBindingType.java
v2/test/cases/marshal example_config.xml
Log:
fix bug in marshalling -- needs reworking in a larger context
modify test case to test fix
Revision Changes Path
1.14 +33 -9 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ByNameRuntimeBindingType.java 16 Dec 2003 09:55:06 -0000 1.13
+++ ByNameRuntimeBindingType.java 17 Dec 2003 00:17:53 -0000 1.14
@@ -57,7 +57,15 @@
package org.apache.xmlbeans.impl.marshal;
import org.apache.xmlbeans.XmlRuntimeException;
-import org.apache.xmlbeans.impl.binding.bts.*;
+import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
+import org.apache.xmlbeans.impl.binding.bts.BindingProperty;
+import org.apache.xmlbeans.impl.binding.bts.BindingType;
+import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
+import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
+import org.apache.xmlbeans.impl.binding.bts.JavaTypeName;
+import org.apache.xmlbeans.impl.binding.bts.MethodName;
+import org.apache.xmlbeans.impl.binding.bts.QNameProperty;
+import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
import org.apache.xmlbeans.impl.marshal.util.collections.Accumulator;
import org.apache.xmlbeans.impl.marshal.util.collections.AccumulatorFactory;
@@ -230,7 +238,6 @@
private final boolean javaPrimitive;
private static final Object[] EMPTY_OBJECT_ARRAY = new Object[]{};
- private static final Class[] EMPTY_CLASS_ARRAY = new Class[]{};
Property(int property_index,
Class beanClass,
@@ -249,7 +256,7 @@
propertyClass = getPropertyClass(prop, bindingType);
collectionElementClass = getCollectionElementClass(prop, bindingType);
getMethod = getGetterMethod(prop, beanClass);
- setMethod = getSetterMethod(prop, beanClass, propertyClass);
+ setMethod = getSetterMethod(prop, beanClass);
javaPrimitive = propertyClass.isPrimitive();
}
@@ -335,11 +342,29 @@
private TypeMarshaller lookupMarshaller(BindingProperty prop,
RuntimeBindingTypeTable typeTable,
- BindingLoader bindingLoader)
+ BindingLoader loader)
{
final BindingType bindingType =
- bindingLoader.getBindingType(prop.getTypeName());
+ loader.getBindingType(prop.getTypeName());
TypeMarshaller m = typeTable.getTypeMarshaller(bindingType);
+
+ if (m == null) {
+ 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);
+
+ assert m != null : "asif type marshaller not found for " + stype;
+ }
+ }
+
return m;
}
@@ -415,7 +440,7 @@
public CharSequence getLexical(Object value, MarshallerImpl context)
{
assert value != null;
- assert marshaller != null : "no marhsaller for " + bindingProperty;
+ assert marshaller != null : "no marhsaller for " + bindingProperty.getTypeName();
return marshaller.print(value, context);
}
@@ -459,8 +484,7 @@
}
private static Method getSetterMethod(QNameProperty binding_prop,
- Class beanClass,
- Class propClass)
+ Class beanClass)
{
MethodName setterName = binding_prop.getSetterName();
try {
@@ -513,7 +537,7 @@
}
- static final class UResultHolder
+ private static final class UResultHolder
{
private final ByNameRuntimeBindingType runtimeBindingType;
private final Object value;
1.14 +2 -1 xml-xmlbeans/v2/test/cases/marshal/example_config.xml
Index: example_config.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/example_config.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- example_config.xml 16 Dec 2003 09:55:06 -0000 1.13
+++ example_config.xml 17 Dec 2003 00:17:53 -0000 1.14
@@ -132,7 +132,8 @@
<bin:qname>java:Myelt</bin:qname>
</bin:qname-property>
<bin:qname-property>
- <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
+<!-- <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>-->
+ <bin:xmlcomponent>t=custom-string@java:com.mytest</bin:xmlcomponent>
<bin:javatype>java.lang.String</bin:javatype>
<bin:getter>
<bin:method-name>getMyatt</bin:method-name>
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org