/** * 解析响应体 * * @param params */ private void parserResoponse(List<ProtocolData> params) { ResponseData response = new ResponseData(); LoginUtil.mLoginStatus.mResponseData = response; bankRecordDatas.clear(); for (ProtocolData data : params) { if (data.mKey.equals(ProtocolUtil.msgheader)) { ProtocolUtil.parserResponse(response, data); } else if (data.mKey.equals(ProtocolUtil.msgbody)) { List<ProtocolData> result1 = data.find("/result"); if (result1 != null) { LoginUtil.mLoginStatus.result = result1.get(0).mValue; } List<ProtocolData> message = data.find("/message"); if (message != null) { LoginUtil.mLoginStatus.message = message.get(0).mValue; } List<ProtocolData> aupic = data.find("/msgchild"); if (aupic != null) for (ProtocolData child : aupic) { BankRecordData picData = new BankRecordData(); if (child.mChildren != null && child.mChildren.size() > 0) { Set<String> keys = child.mChildren.keySet(); for (String key : keys) { List<ProtocolData> rs = child.mChildren.get(key); for (ProtocolData item : rs) { if (item.mKey.equals("shoucardid")) { picData.shoucardid = item.mValue; } else if (item.mKey.equals("shoucardno")) { picData.shoucardno = item.mValue; } else if (item.mKey.equals("shoucardbank")) { picData.shoucardbank = item.mValue; } else if (item.mKey.equals("shoucardman")) { picData.shoucardman = item.mValue; } else if (item.mKey.equals("shoucardmobile")) { picData.shoucardmobile = item.mValue; } else if (item.mKey.equals("paytype")) { picData.paytype = item.mValue; } else if (item.mKey.equals("bankid")) { picData.bankid = item.mValue; } } } } bankRecordDatas.add(picData); } } } }
private void parserResponse(List<ProtocolData> mDatas) { ResponseData response = new ResponseData(); LoginUtil.mLoginStatus.mResponseData = response; for (ProtocolData data : mDatas) { if (data.mKey.equals(ProtocolUtil.msgheader)) { ProtocolUtil.parserResponse(response, data); } else if (data.mKey.equals(ProtocolUtil.msgbody)) { List<ProtocolData> result = data.find("/result"); if (result != null) { LoginUtil.mLoginStatus.result = result.get(0).getmValue(); } List<ProtocolData> message = data.find("/message"); if (result != null) { LoginUtil.mLoginStatus.message = message.get(0).getmValue(); } List<ProtocolData> authorid = data.find("/authorid"); if (authorid != null) { LoginUtil.mLoginStatus.authorid = authorid.get(0).mValue; } List<ProtocolData> aupic = data.find("/msgchild"); if (aupic != null) for (ProtocolData child : aupic) { PwdSafetyValidateUserData picData = new PwdSafetyValidateUserData(); if (child.mChildren != null && child.mChildren.size() > 0) { Set<String> keys = child.mChildren.keySet(); for (String key : keys) { List<ProtocolData> rs = child.mChildren.get(key); for (ProtocolData item : rs) { if (item.mKey.equals("que")) { picData.que = item.mValue; } else if (item.mKey.equals("answer")) { picData.answer = item.mValue; } } } } mList.add(picData); } } } }
@Override public ProtocolData parserBody(XmlPullParser parser) throws XmlPullParserException, IOException { // TODO Auto-generated method stub ProtocolData res = new ProtocolData("msgbody", null); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_TAG: { // 姓名 if (parser.getName().compareTo("result") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("result", temp); res.addChild(r); } // 身份证 } else if (parser.getName().compareTo("message") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("message", temp); res.addChild(r); } } } break; case XmlPullParser.END_TAG: { if (parser.getName().compareTo("msgbody") == 0) { return res; } } break; case XmlPullParser.TEXT: { } break; } eventType = parser.next(); } return res; }
/** * 解析图片 * * @param parser * @return * @throws XmlPullParserException * @throws IOException */ public ProtocolData parserPic(XmlPullParser parser, ProtocolData res) throws XmlPullParserException, IOException { // TODO Auto-generated method stub int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_TAG: { // 自增长ID if (parser.getName().compareTo("picid") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("picid", temp); res.addChild(r); } } // 图片类型 else if (parser.getName().compareTo("pictype") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("pictype", temp); res.addChild(r); } } // 图片地址 else if (parser.getName().compareTo("picpath") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("picpath", temp); res.addChild(r); } } // 管理图片类型 else if (parser.getName().compareTo("uploadpictype") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("uploadpictype", temp); res.addChild(r); } } // 存放地址 else if (parser.getName().compareTo("uploadurl") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("uploadurl", temp); res.addChild(r); } } // 上传方式 else if (parser.getName().compareTo("uploadmethod") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData r = new ProtocolData("uploadmethod", temp); res.addChild(r); } } } break; case XmlPullParser.END_TAG: { if (parser.getName().compareTo("aupic") == 0) { return res; } } break; case XmlPullParser.TEXT: { } break; } eventType = parser.next(); } return res; }
private void parserHelpItem(XmlPullParser parser, ProtocolData parent) throws XmlPullParserException, IOException { // TODO Auto-generated method stub // HashMap<String, List<ProtocolData>> res = new HashMap<String, // List<ProtocolData>>(); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_TAG: { if (parser.getName().compareTo("rechaMoneyid") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData data = new ProtocolData("rechaMoneyid", temp); parent.addChild(data); } } else if (parser.getName().compareTo("rechamoney") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData data = new ProtocolData("rechamoney", temp); parent.addChild(data); } } else if (parser.getName().compareTo("rechapaymoney") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData data = new ProtocolData("rechapaymoney", temp); parent.addChild(data); } } else if (parser.getName().compareTo("rechamemo") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData data = new ProtocolData("rechamemo", temp); parent.addChild(data); } } else if (parser.getName().compareTo("rechaisdefault") == 0) { String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData data = new ProtocolData("rechaisdefault", temp); parent.addChild(data); } } /** * else if (parser.getName().compareTo("feemoney") == 0) { String temp = * parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData data = new * ProtocolData("feemoney", temp); parent.addChild(data); } } else if * (parser.getName().compareTo("allmoney") == 0) { String temp = parser.nextText(); if * (temp != null && temp.length() > 0) { ProtocolData data = new ProtocolData("allmoney", * temp); parent.addChild(data); } }else if (parser.getName().compareTo("state") == 0) { * String temp = parser.nextText(); if (temp != null && temp.length() > 0) { ProtocolData * data = new ProtocolData("state", temp); parent.addChild(data); } }else if * (parser.getName().compareTo("huancardbank") == 0) { String temp = parser.nextText(); if * (temp != null && temp.length() > 0) { ProtocolData data = new * ProtocolData("huancardbank", temp); parent.addChild(data); } }else if * (parser.getName().compareTo("fucardbank") == 0) { String temp = parser.nextText(); if * (temp != null && temp.length() > 0) { ProtocolData data = new * ProtocolData("fucardbank", temp); parent.addChild(data); } } */ } break; case XmlPullParser.END_TAG: { if (parser.getName().compareTo("msgchild") == 0) { return; } } break; case XmlPullParser.TEXT: { } break; } eventType = parser.next(); } return; }