rubys 2002/06/27 23:17:55
Modified: java/src/org/apache/axis/encoding
DefaultTypeMappingImpl.java
java/src/org/apache/axis/utils JavaUtils.java
java/test/encoding TestDeser.java
java/test/utils TestJavaUtils.java
Log:
Add support for Hashtables
Revision Changes Path
1.34 +5 -0
xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
Index: DefaultTypeMappingImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- DefaultTypeMappingImpl.java 21 Jun 2002 13:00:30 -0000 1.33
+++ DefaultTypeMappingImpl.java 28 Jun 2002 06:17:54 -0000 1.34
@@ -301,6 +301,11 @@
new MapDeserializerFactory(java.util.HashMap.class,
Constants.SOAP_MAP),
false);
+ myRegister(Constants.SOAP_MAP, java.util.Hashtable.class,
+ new MapSerializerFactory(java.util.Hashtable.class,
+ Constants.SOAP_MAP),
+ null, // Make sure not to override the deser mapping
+ false);
myRegister(Constants.SOAP_MAP, java.util.Map.class,
new MapSerializerFactory(java.util.Map.class,
Constants.SOAP_MAP),
1.52 +10 -0 xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
Index: JavaUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- JavaUtils.java 26 Jun 2002 19:05:10 -0000 1.51
+++ JavaUtils.java 28 Jun 2002 06:17:54 -0000 1.52
@@ -71,7 +71,9 @@
import java.util.ResourceBundle;
import java.util.Collection;
import java.util.Iterator;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.Set;
import java.util.ArrayList;
import java.util.List;
@@ -226,6 +228,11 @@
return ((Calendar) arg).getTime();
}
+ // Convert between HashMap and Hashtable
+ if (arg instanceof HashMap && destClass == Hashtable.class) {
+ return new Hashtable((HashMap)arg);
+ }
+
// Return if no conversion is available
if (!(arg instanceof Collection ||
@@ -405,6 +412,9 @@
(src == byte[].class && dest == Hex.class))
return true;
+ // Allow mapping of HashMaps to Hasttables
+ if (src == HashMap.class && dest == Hashtable.class)
+ return true;
}
Class destHeld = JavaUtils.getHolderValueType(dest);
1.39 +18 -0 xml-axis/java/test/encoding/TestDeser.java
Index: TestDeser.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/TestDeser.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- TestDeser.java 27 Jun 2002 23:10:36 -0000 1.38
+++ TestDeser.java 28 Jun 2002 06:17:55 -0000 1.39
@@ -20,6 +20,7 @@
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -300,6 +301,23 @@
"</item>" +
"</result>",
m);
+ }
+
+ public void testHashtable() throws Exception {
+ Hashtable ht = new Hashtable();
+ ht.put("abcKey", "abcVal");
+ ht.put("defKey", "defVal");
+ deserialize("<result xsi:type=\"xmlsoap:Map\" " +
+ "xmlns:xmlsoap=\"http://xml.apache.org/xml-soap\"> " +
+ "<item>" +
+ "<key xsi:type=\"xsd:string\">abcKey</key>" +
+ "<value xsi:type=\"xsd:string\">abcVal</value>" +
+ "</item><item>" +
+ "<key xsi:type=\"xsd:string\">defKey</key>" +
+ "<value xsi:type=\"xsd:string\">defVal</value>" +
+ "</item>" +
+ "</result>",
+ ht, true);
}
public void testUntyped() throws Exception {
1.8 +7 -0 xml-axis/java/test/utils/TestJavaUtils.java
Index: TestJavaUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/utils/TestJavaUtils.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestJavaUtils.java 26 Jun 2002 19:05:09 -0000 1.7
+++ TestJavaUtils.java 28 Jun 2002 06:17:55 -0000 1.8
@@ -5,6 +5,8 @@
import junit.framework.TestSuite;
import org.apache.axis.utils.JavaUtils;
+import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
@@ -92,5 +94,10 @@
ret = JavaUtils.convert(array, Vector.class);
assertTrue("Converted array not a Vector", (ret instanceof Vector));
+ HashMap m = new HashMap();
+ m.put("abcKey", "abcVal");
+ m.put("defKey", "defVal");
+ ret = JavaUtils.convert(m, Hashtable.class);
+ assertTrue("Converted HashMap not a Hashtable", (ret instanceof Hashtable));
}
}