I was wondering if anyone saw any problems with using a Dictionary instead
of a Hastable in XmlRpc.java for the function writeObject(Object obj)
My problem is, that when using a Hashtable, the order of the objects put
in are not kept the same (it uses a hash!) so I had created a class that
implements Dictionary (which Hashtable does also) and use that instead.
The result is what I want, and it's works with existing code also.
The diff like this for java/org/apache/xmlrpc/XmlRpc.java
785c785
< else if (obj instanceof Hashtable)
---
> else if (obj instanceof java.util.Dictionary)
788c788
< Hashtable struct = (Hashtable) obj;
---
> java.util.Dictionary struct = (java.util.Dictionary)
obj;
795c795
< write(nextkey);
---
> chardata(nextkey);
and here's the code if it's easier to read for ya:
else if (obj instanceof java.util.Dictionary)
{
startElement("struct");
java.util.Dictionary struct = (java.util.Dictionary) obj;
for (Enumeration e = struct.keys(); e.hasMoreElements(); )
{
String nextkey = (String) e.nextElement();
Object nextval = struct.get(nextkey);
startElement("member");
startElement("name");
chardata(nextkey);
endElement("name");
writeObject(nextval);
endElement("member");
}
endElement("struct");
}
Does anyone see any problems with this code? Should it be applied to the
original XmlRpc.java so other folks could possibly benifit?
thanks,
-gus
--
"Christmas means carnage!" -- Ferdinand, the duck