// 日期转换期
xstream.registerConverter(new DateConverter("yyyy-MM-dd'T'hh:mm:ss",null));
格式:"yyyy-MM-dd'T'hh:mm:ss"
结果:2012-05-24T14:01:09
未转换前:2012-05-24 02:12:23.089 UTC
转换后:2012-05-24T02:12:23
//属性重命名
xstream.aliasField("邮件", Student.class, "mails");
未加别名前:<mails>
加了别名后:<邮件>
//包重命名
xstream.aliasPackage("oo","com.model");
未加别名前:<com.model.Student>
加了别名后:<oo.Student>
//类重命名
xstream.alias("Student",Student.class);
未加别名前:<com.model.Student>
加了别名后:<Student>
//添加隐式集合
xstream.addImplicitCollection(Student.class, "mails");
未添加前:
<mails>
<com.model.Mail>
<name>163</name>
<email>test@163.com</email>
</com.model.Mail>
<com.model.Mail>
<name>263</name>
<email>test@263.net</email>
</com.model.Mail>
</mails>
添加后:
<com.model.Mail>
<name>163</name>
<email>test@163.com</email>
</com.model.Mail>
<com.model.Mail>
<name>263</name>
<email>test@263.net</email>
</com.model.Mail>
//设置节点的属性
xstream.useAttributeFor(Student.class, "name");
效果:<com.model.Student name="名字">