博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
XStream xml to bean
阅读量:6156 次
发布时间:2019-06-21

本文共 5494 字,大约阅读时间需要 18 分钟。

com.thoughtworks.xstream
xstream
${xstream.version}
package demo;import com.thoughtworks.xstream.annotations.XStreamAlias;@XStreamAlias("data")public class XjdbBean {    public Message getMessage() {        return message;    }    public void setMessage(Message message) {        this.message = message;    }    public XjCompares getXjCompares() {        return xjCompares;    }    public void setXjCompares(XjCompares xjCompares) {        this.xjCompares = xjCompares;    }    @XStreamAlias("message")    private Message message;    @XStreamAlias("xjCompares")    private XjCompares xjCompares;    @XStreamAlias("xjCompares")    public static class XjCompares{        public XjCompare getXjCompare() {            return xjCompare;        }        public void setXjCompare(XjCompare xjCompare) {            this.xjCompare = xjCompare;        }        @XStreamAlias("xjCompare")        private XjCompare xjCompare;            }        @XStreamAlias("xjCompare")    public static class XjCompare{        @XStreamAlias("wybs")        private String wybs;        @XStreamAlias("message")        private Message message;        @XStreamAlias("yjbyrq")        private String yjbyrq;        @XStreamAlias("xllbCheckrs")        private String xllbCheckrs;        @XStreamAlias("rxrqCheckrs")        private String rxrqCheckrs;        @XStreamAlias("yxmcCheckrs")        private String yxmcCheckrs;        @XStreamAlias("ccCheckrs")        private String ccCheckrs;        @XStreamAlias("xjCheckrs")        private String xjCheckrs;        public String getXllbCheckrs() {            return xllbCheckrs;        }        public void setXllbCheckrs(String xllbCheckrs) {            this.xllbCheckrs = xllbCheckrs;        }        public String getRxrqCheckrs() {            return rxrqCheckrs;        }        public void setRxrqCheckrs(String rxrqCheckrs) {            this.rxrqCheckrs = rxrqCheckrs;        }        public String getYxmcCheckrs() {            return yxmcCheckrs;        }        public void setYxmcCheckrs(String yxmcCheckrs) {            this.yxmcCheckrs = yxmcCheckrs;        }        public String getCcCheckrs() {            return ccCheckrs;        }        public void setCcCheckrs(String ccCheckrs) {            this.ccCheckrs = ccCheckrs;        }        public String getXjCheckrs() {            return xjCheckrs;        }        public void setXjCheckrs(String xjCheckrs) {            this.xjCheckrs = xjCheckrs;        }        public String getWybs() {            return wybs;        }        public void setWybs(String wybs) {            this.wybs = wybs;        }        public Message getMessage() {            return message;        }        public void setMessage(Message message) {            this.message = message;        }        public String getYjbyrq() {            return yjbyrq;        }        public void setYjbyrq(String yjbyrq) {            this.yjbyrq = yjbyrq;        }    }        @XStreamAlias("message")    public static class Message{        @XStreamAlias("status")        private int status;        @XStreamAlias("value")        private String value;        public int getStatus() {            return status;        }        public void setStatus(int status) {            this.status = status;        }        public String getValue() {            return value;        }        public void setValue(String value) {            this.value = value;        }    }}
public static void main(String[] args) {        // TODO Auto-generated method stub                //toXml//        String xmlStr=new PersonTest().toXml();                //toBean//        XjdbBean per=new PersonTest().toBean();        String xmlStr="
"+""+ "
"+ "
0
"+ "
处理成功
"+ "
"+ "
"+ "
"+ "
40288940560cfc780156262f01a344e3
"+ "
"+ "
1
"+ "
查询成功_无数据
"+ "
"+ "
201507
"+ "
1
"+ "
1
"+ "
1
"+ "
1
"+ "
1
"+ "
"+ "
"+ ""+ ""+ "
"; XjdbBean person=XmlUtil.toBean(xmlStr, XjdbBean.class); System.out.println("person=firstname=="+person.getMessage().getValue()); System.out.println("person=firstname=="+person.getXjCompares().getXjCompare().getMessage().getStatus()); System.out.println("0".equals(person.getXjCompares().getXjCompare().getMessage().getStatus())); if(0==person.getXjCompares().getXjCompare().getMessage().getStatus()){ System.out.println("person=firstname=="+person.getXjCompares().getXjCompare().getYjbyrq()); } /*System.out.println("person==Friends==name1=="+person.getFriend().getName().get(0)); System.out.println("person==Pets==name2=="+person.getPet().getAnimalList().get(1).getName());*/ }

 

转载地址:http://mwsfa.baihongyu.com/

你可能感兴趣的文章
MoSQL
查看>>
Hibernate多对一外键单向关联(Annotation配置)
查看>>
《CLR via C#》读书笔记 之 方法
查看>>
设计模式:组合模式(Composite Pattern)
查看>>
ContentValues 和HashTable区别
查看>>
LogicalDOC 6.6.2 发布,文档管理系统
查看>>
给PowerShell脚本传递参数
查看>>
实战2——Hadoop的日志分析
查看>>
利用FIFO进行文件拷贝一例
查看>>
Ecshop安装过程中的的问题:cls_image::gd_version()和不支持JPEG
查看>>
resmgr:cpu quantum等待事件
查看>>
一个屌丝程序猿的人生(六十六)
查看>>
Java 编码 UTF-8
查看>>
SpringMVC实战(注解)
查看>>
关于静态属性和静态函数
查看>>
进程的基本属性:进程ID、父进程ID、进程组ID、会话和控制终端
查看>>
spring+jotm+ibatis+mysql实现JTA分布式事务
查看>>
MyBatis启动:MapperStatement创建
查看>>
调查问卷相关
查看>>
eclipse启动无响应,老是加载不了revert resources,或停留在Loading workbench状态
查看>>