Add a branch in processXmlRpcResponse() to convert a Map to a Hashtable.
Use ...else if... rather then separate if statements for mutually exclusive conditions in processXmlRpcResponse().
This commit is contained in:
parent
4245d6d08f
commit
37d086d5f3
1 changed files with 7 additions and 6 deletions
|
@ -504,6 +504,7 @@ public final class RhinoCore {
|
||||||
* convert a JavaScript Object object to a generic Java object stucture.
|
* convert a JavaScript Object object to a generic Java object stucture.
|
||||||
*/
|
*/
|
||||||
public Object processXmlRpcResponse (Object what) throws Exception {
|
public Object processXmlRpcResponse (Object what) throws Exception {
|
||||||
|
// unwrap if argument is a Wrapper
|
||||||
if (what instanceof Wrapper) {
|
if (what instanceof Wrapper) {
|
||||||
what = ((Wrapper) what).unwrap();
|
what = ((Wrapper) what).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -521,8 +522,7 @@ public final class RhinoCore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
what = ht;
|
what = ht;
|
||||||
}
|
} else if (what instanceof NativeArray) {
|
||||||
if (what instanceof NativeArray) {
|
|
||||||
NativeArray na = (NativeArray) what;
|
NativeArray na = (NativeArray) what;
|
||||||
Number n = (Number) na.get("length", na);
|
Number n = (Number) na.get("length", na);
|
||||||
int l = n.intValue();
|
int l = n.intValue();
|
||||||
|
@ -531,16 +531,17 @@ public final class RhinoCore {
|
||||||
retval.add(i, processXmlRpcResponse(na.get(i, na)));
|
retval.add(i, processXmlRpcResponse(na.get(i, na)));
|
||||||
}
|
}
|
||||||
what = retval;
|
what = retval;
|
||||||
}
|
} else if (what instanceof Map) {
|
||||||
if (what instanceof Number) {
|
Map map = (Map) what;
|
||||||
|
what = new Hashtable(map);
|
||||||
|
} else if (what instanceof Number) {
|
||||||
Number n = (Number) what;
|
Number n = (Number) what;
|
||||||
if (what instanceof Float || what instanceof Long) {
|
if (what instanceof Float || what instanceof Long) {
|
||||||
what = new Double(n.doubleValue());
|
what = new Double(n.doubleValue());
|
||||||
} else if (!(what instanceof Double)) {
|
} else if (!(what instanceof Double)) {
|
||||||
what = new Integer(n.intValue());
|
what = new Integer(n.intValue());
|
||||||
}
|
}
|
||||||
}
|
} else if (what instanceof Scriptable) {
|
||||||
if (what instanceof Scriptable) {
|
|
||||||
Scriptable s = (Scriptable) what;
|
Scriptable s = (Scriptable) what;
|
||||||
if ("Date".equals(s.getClassName())) {
|
if ("Date".equals(s.getClassName())) {
|
||||||
what = new Date((long) ScriptRuntime.toNumber(s));
|
what = new Date((long) ScriptRuntime.toNumber(s));
|
||||||
|
|
Loading…
Add table
Reference in a new issue