//////////////////////////////////////////////////
@SuppressWarnings("unchecked")
private static <T> T msgEntityFactory(
Class<? extends WxBaseMsgEntity> clazz, Element ele) {
WxBaseMsgEntity result;
try {
result = clazz.newInstance();
result.setToUserName(strVal(ele, "ToUserName"));
result.setFromUserName(strVal(ele, "FromUserName"));
result.setCreateTime(longVal(ele, "CreateTime"));
result.setCreatedDate(new Date());
result.setMsgType(strVal(ele, "MsgType"));
if (ele.element("MsgId") != null) {
result.setMsgId(longVal(ele, "MsgId"));
}
return (T) result;
} catch (Exception e) {
// never occurs
return null;