snichol 2003/02/07 11:38:57
Modified: java/src/org/apache/soap/util/xml
XMLJavaMappingRegistry.java
java/src/org/apache/soap/encoding SOAPMappingRegistry.java
Log:
Restore changes of version 1.9 in XJMR. Add methods to map just types.
Add code to SMR to map Object so that null objects still can be serialized.
Revision Changes Path
1.15 +48 -10
xml-soap/java/src/org/apache/soap/util/xml/XMLJavaMappingRegistry.java
Index: XMLJavaMappingRegistry.java
===================================================================
RCS file:
/home/cvs/xml-soap/java/src/org/apache/soap/util/xml/XMLJavaMappingRegistry.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XMLJavaMappingRegistry.java 7 Feb 2003 04:15:58 -0000 1.14
+++ XMLJavaMappingRegistry.java 7 Feb 2003 19:38:57 -0000 1.15
@@ -155,25 +155,63 @@
{
Maps maps = getMapsForEncoding(encodingStyleURI);
Object java2XMLKey = "";
- if (javaType != null)
- java2XMLKey = javaType;
Object xml2JavaKey = "";
- if (elementType != null)
- xml2JavaKey = elementType;
- if (s != null)
+ if (s != null) {
+ if (javaType != null)
+ java2XMLKey = javaType;
maps.sReg.put(java2XMLKey, s);
+ }
- if (ds != null)
+ if (ds != null) {
+ if (elementType != null)
+ xml2JavaKey = elementType;
maps.dsReg.put(xml2JavaKey, ds);
+ }
// Only map types if both types are provided.
- // Map regardless of specification of serializer and deserializer,
- // since the mapping can be used for null values, too.
if (elementType != null && javaType != null) {
- maps.java2XMLReg.put(java2XMLKey, elementType);
- maps.xml2JavaReg.put(xml2JavaKey, javaType);
+ if (s != null)
+ maps.java2XMLReg.put(java2XMLKey, elementType);
+ if (ds != null)
+ maps.xml2JavaReg.put(xml2JavaKey, javaType);
}
+ }
+
+ /**
+ * Adds a Java-to-XML type mapping. This is usually called to
+ * provide a mapping to allow serialization of a null value
+ * for a type for which there is no serializer.
+ *
+ * @param encodingStyleURI The encoding style for the map. The
+ * encoding style qualifies the types.
+ * @param elementType The XML type.
+ * @param javaType The Java type.
+ */
+ public void addJavaToXMLMap(String encodingStyleURI, QName elementType, Class
javaType) {
+ Maps maps = getMapsForEncoding(encodingStyleURI);
+ Object java2XMLKey = "";
+ if (javaType != null)
+ java2XMLKey = javaType;
+ maps.java2XMLReg.put(java2XMLKey, elementType);
+ }
+
+ /**
+ * Adds an XML-to-Java type mapping. This is usually called to
+ * provide a mapping to allow de-serialization of a null value
+ * for a type for which there is no de-serializer.
+ *
+ * @param encodingStyleURI The encoding style for the map. The
+ * encoding style qualifies the types.
+ * @param elementType The XML type.
+ * @param javaType The Java type.
+ */
+ public void addXMLToJavaMap(String encodingStyleURI, QName elementType, Class
javaType) {
+ Maps maps = getMapsForEncoding(encodingStyleURI);
+ Object xml2JavaKey = "";
+ if (elementType != null)
+ xml2JavaKey = elementType;
+ maps.xml2JavaReg.put(xml2JavaKey, javaType);
}
/**
1.39 +7 -0
xml-soap/java/src/org/apache/soap/encoding/SOAPMappingRegistry.java
Index: SOAPMappingRegistry.java
===================================================================
RCS file:
/home/cvs/xml-soap/java/src/org/apache/soap/encoding/SOAPMappingRegistry.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- SOAPMappingRegistry.java 7 Feb 2003 04:15:58 -0000 1.38
+++ SOAPMappingRegistry.java 7 Feb 2003 19:38:57 -0000 1.39
@@ -414,14 +414,17 @@
private void initializeRegistry(String schemaURI)
{
QName schemaQNames[] = null;
+ QName objectQName = null;
if (schemaURI.equals(Constants.NS_URI_1999_SCHEMA_XSD)) {
schemaQNames = schema1999QNames;
+ objectQName = Constants.object1999QName;
mapSchemaTypes(schema2000QNames, false);
mapSchemaTypes(schema2001QNames, false);
} else if (schemaURI.equals(Constants.NS_URI_2000_SCHEMA_XSD)) {
mapSchemaTypes(schema1999QNames, false);
schemaQNames = schema2000QNames;
+ objectQName = Constants.object2000QName;
mapSchemaTypes(schema2001QNames, false);
} else {
if (!schemaURI.equals(Constants.NS_URI_2001_SCHEMA_XSD)) {
@@ -432,10 +435,14 @@
mapSchemaTypes(schema1999QNames, false);
mapSchemaTypes(schema2000QNames, false);
schemaQNames = schema2001QNames;
+ objectQName = Constants.object2001QName;
}
// map the ones that I want to do read-write with
mapSchemaTypes(schemaQNames, true);
+
+ // add a mapping for serialization of null Objects
+ addJavaToXMLMap(soapEncURI, objectQName, Object.class);
// Register parameter serializer for SOAP-ENC encoding style.
mapTypes(soapEncURI, RPCConstants.Q_ELEM_PARAMETER, Parameter.class,