"{"
+ "\"imHandleAttr1\":{\"address\":\"handle\",\"protocol\":\"xmpp\"}"
+ ",\"imHandleAttr2\":{\"address\":\"network\",\"protocol\":\"http://aim.com\"}"
+ "}");
JSONObject h = j.getJSONObject("imHandleAttr1");
IMHandle i = null;
IMHandle.Scheme s = null;
URL u = null;
try {
s = IMHandle.Scheme.valueOf(h.getString("protocol"));
} catch (IllegalArgumentException e) {
try {
u = new URL(h.getString("protocol"));
} catch (MalformedURLException ex) {
}
}
if (s != null) {
i = new IMHandle(s, h.getString("address"));
} else if (u != null) {
i = new IMHandle(u, h.getString("address"));
}
Assert.assertEquals("handle", i.getAddress());
Assert.assertEquals(IMHandle.Scheme.xmpp.name(), i.getProtocol());
}