/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.thoughtworks.xstream.XStream
 */
package com.hst.common.util;

import com.hst.common.util.XmlParse;
import com.hst.taxService.domain.gt3.HXZGDJ00004NsrxxGridDomain;
import com.hst.taxService.domain.gt3.HXZGDJ00004NsrxxGridlbDomain;
import com.hst.taxService.domain.gt3.HXZGDJ00004ResponseDomain;
import com.thoughtworks.xstream.XStream;
import java.util.HashMap;
import java.util.Map;

public class XmlHelper {
    private String rootNode = "";
    private Map<String, Class> aliasMap = null;

    private XmlHelper() {
    }

    public XmlHelper(Map<String, Class> aliasMap) {
        this.aliasMap = aliasMap;
    }

    public XmlHelper(String rootNode, Map<String, Class> aliasMap) {
        this.rootNode = rootNode;
        this.aliasMap = aliasMap;
    }

    public Object xmlStrParser(String xmlStr) throws Exception {
        try {
            XStream xStream = XmlParse.createXStream(this.rootNode, this.aliasMap);
            return xStream.fromXML(xmlStr);
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    public Object xmlStrParser(String xmlStr, String rootNode) throws Exception {
        try {
            XStream xStream = XmlParse.createXStream(rootNode, this.aliasMap);
            return xStream.fromXML(xmlStr);
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    public Object xmlStrParser(String xmlStr, String rootNode, Map<String, Class> aliasMap) throws Exception {
        try {
            XStream xStream = XmlParse.createXStream(rootNode, aliasMap);
            return xStream.fromXML(xmlStr);
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    public String parserTObject(Object obj) throws Exception {
        try {
            XStream xStream = XmlParse.createXStream(this.rootNode, this.aliasMap);
            return xStream.toXML(obj).trim();
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    public String parserTObject(Object obj, String rootNode) throws Exception {
        try {
            XStream xStream = XmlParse.createXStream(rootNode, this.aliasMap);
            return xStream.toXML(obj).trim();
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    public static void main(String[] args) {
        String xml2 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><taxML xsi:type=\"HXZGDJ00004Response\" xmlns=\"http://www.chinatax.gov.cn/dataspec/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><nsrxxGrid><nsrxxGridlb><nsrfyhyGrid/><gdslxDm>1</gdslxDm><nsrsbh>430102694564694</nsrsbh><nsrmc>\u963f\u91cc\u5df4\u5df4(\u4e2d\u56fd)\u6559\u80b2\u79d1\u6280\u6709\u9650\u516c\u53f8</nsrmc><fddbrsfzjlxDm>201</fddbrsfzjlxDm><kqccsztdjbz>N</kqccsztdjbz><zgswjDm>14301020000</zgswjDm><scjydz>\u676d\u5dde\u5e02\u6ee8\u6c5f\u533a\u7f51\u5546\u8def699\u53f76\u53f7\u697c2\u697c</scjydz><gdghlxDm>3</gdghlxDm><nsrztDm>03</nsrztDm><djxh>10114301010000000035</djxh><djrq>2016-05-10 00:00:00.0</djrq><zzjgDm>694564694</zzjgDm><scjydzxzqhszDm>430102</scjydzxzqhszDm><djjgDm>14301020600</djjgDm><fddbrxm>\u9646\u5146\u79a7</fddbrxm><lrrDm>14311111111</lrrDm><swdjblbz>N</swdjblbz><kzztdjlxDm>1110</kzztdjlxDm><djzclxDm>230</djzclxDm><fddbrsfzjhm>440103196912092133</fddbrsfzjhm><sjgsdq>14301021200</sjgsdq><zgswskfjDm>14301021200</zgswskfjDm><fjmqybz>N</fjmqybz><ssdabh>10114301010000000025</ssdabh><lrrq>2016-05-10 00:28:27.0</lrrq><hhrs>0</hhrs><ggrs>0</ggrs><gytzbl>0.0</gytzbl><zczbbzyje>0.0</zczbbzyje><jyfw>\u670d\u52a1\uff1a\u6210\u5e74\u4eba\u7684\u975e\u8bc1\u4e66\u52b3\u52a8\u804c\u4e1a\u6280\u80fd\u57f9\u8bad\uff0c\u6210\u5e74\u4eba\u7684\u975e\u6587\u5316\u6559\u80b2\u57f9\u8bad\uff08\u6d89\u53ca\u524d\u7f6e\u5ba1\u6279\u7684\u9879\u76ee\u9664\u5916\uff09\uff0c\u4f01\u4e1a\u7ba1\u7406\u54a8\u8be2\uff0c\u7ecf\u6d4e\u4fe1\u606f\u54a8\u8be2\uff08\u9664\u5546\u54c1\u4e2d\u4ecb\uff09\uff0c\u7535\u8111\u52a8\u753b\u8bbe\u8ba1\uff1b\u6280\u672f\u7814\u53d1\u3001\u6280\u672f\u670d\u52a1\uff1a\u8ba1\u7b97\u673a\u7f51\u7edc\u5e94\u7528\u8f6f\u4ef6\uff0c\u8ba1\u7b97\u673a\u7cfb\u7edf\uff0c\u7f51\u7edc\u6280\u672f\u4ea7\u54c1\u3002\uff08\u56fd\u5bb6\u7981\u6b62\u548c\u9650\u5236\u7684\u9664\u5916\uff0c\u51e1\u6d89\u53ca\u8bb8\u53ef\u8bc1\u5236\u5ea6\u7684\u51ed\u8bc1\u7ecf\u8425\uff09\u3002\uff08\u4f9d\u6cd5\u987b\u7ecf\u6279\u51c6\u7684\u9879\u76ee\uff0c\u7ecf\u76f8\u5173\u90e8\u95e8\u6279\u51c6\u540e\u65b9\u53ef\u5f00\u5c55\u7ecf\u8425\u6d3b\u52a8\uff09</jyfw><zczbbzsje>0.0</zczbbzsje><zfjglxDm>0</zfjglxDm><wjcyrs>0</wjcyrs><zczbbzeje>0.0</zczbbzeje><tzzebzyje>0.0</tzzebzyje><cyrs>0</cyrs><gdgrs>0</gdgrs><zrrtzbl>0.0</zrrtzbl><zczb>0.0</zczb><tzze>0.0</tzze><wztzbl>0.0</wztzbl><tzzebzeje>0.0</tzzebzeje><tzzebzsje>0.0</tzzebzsje><kyslrq>2016-04-01</kyslrq></nsrxxGridlb></nsrxxGrid></taxML>";
        HashMap<String, Class> map = new HashMap<String, Class>();
        map.put("taxML", HXZGDJ00004ResponseDomain.class);
        map.put("nsrxxGrid", HXZGDJ00004NsrxxGridDomain.class);
        map.put("nsrxxGridlb", HXZGDJ00004NsrxxGridlbDomain.class);
        XmlHelper help = new XmlHelper("taxML", map);
        try {
            HXZGDJ00004ResponseDomain dom = (HXZGDJ00004ResponseDomain)help.xmlStrParser(xml2);
            System.out.println(dom.getNsrxxGrid().getNsrxxGridlb().get(0).getJyfw());
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
