jaxb从上层排除字段

时间:2016-09-27 15:17:26

标签: xml jaxb jna

我有一个静态类,它扩展了Struture(JNA)。我有一些字段(只有整数)。我可以使用jaxb处理该类,但是当我序列化该类的对象时,我在xml文件中有字段autoRead / autoWrite。如何从xml中排除这些字段?

我已将XmlAccessorType设置为None / property但在任何地方都相同。

我的代码:

@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "Data", propOrder = { "field1", "field2", "field3", "field4", "field5" })
public static class Data extends Structure {
    public transient int type;
    @XmlElement(name = "field1")
    public int field1;
    @XmlElement(name = "field2")
    public int field2;
    @XmlElement(name = "field3")
    public int field3;
    @XmlElement(name = "field4")
    public int field4;
    @XmlElement(name = "field5")
    public int field5;

    @Override
    protected List<String> getFieldOrder() {
        // TODO Auto-generated method stub
        return Arrays.asList(new String[] { "type", "field1", "field2", "field3", "field4", "field5" });
    }

迎接

本杰明

0 个答案:

没有答案