java.util.List<MyObject>说,我想对类对象的列表进行管理和解组。我计划使用Castor,我将不得不使用Castor-0.9.5.*.jar版本。
此外,我还有我的封送对象(MyObject)的XML。MyObject类没有默认构造函数,它只有一个参数化构造函数来设置所有字段。而且MyObject类中的任何字段都没有setter方法。我根本不能修改MyObject类。
下面是MyObject类的片段:
public class MyObject
{
private final SomeEnumType type;
private final CutomObject custObjs[];
private final int index;
private final String[] strs;
private final int rows[];
// NOTE: This class also has getter methods for all the fields.
// NOTE: There are NO setters methods and all fields are final
public MyObject(SomeEnumType type, CutomObject custObjs[],
int index, String strs[], int rows[])
{
this.type = type;
this.custObjs = custObjs;
this.index = index;
this.strs = strs;
this.rows = rows;
}
}我的问题是:
MyObject类没有默认构造函数,所以它无法工作?MyObject的XML来生成Castor映射。org.exolab.castor.xml.XMLContext和org.castor.xml.BackwardCompatibilityContext类,它们不是Castor的一部分吗?发布于 2013-06-10 12:22:09
我更喜欢使用jaxB,因为它重量轻,编组和解编组不会占用太多内存,点击这里,例如
https://stackoverflow.com/questions/17023626
复制相似问题