2
package jaxb.classes;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
public class Task {
    @XmlElement(name="input")
    private String input;   // String representing the input file
    @XmlElement(name="output")
    private String output; // String representing the output file
    @XmlElement(name="format")
    private Format format; // a jaxb.classes.Format representing the format of conversion
    @XmlElement(name="taskID")
    private long taskID; // a unique ID for each task.
    @XmlElement(name="isReady")
    public boolean isReady; // boolean value representing whether the task is ready for conversion


    public boolean isChanging; // boolean representing if the user is changing the task DO NOT MARSHALL
    public boolean isExecuting; // boolean representing whether the task is being executed  DO NOT MARSHALL

    public long getTaskID(){
        return taskID;
    }

    public String getInput(){
        return input;
    }

    public String getOutput(){
        return output;
    }

    public Format getFormat(){
        return format;
    }

    public void setOutput(String out){
        output = out;
    }

    public void setFormat(Format f){
        format = f;
    }

}  

したがって、ここに、変換のための保留中のタスクを表すクラスがあります。これは、保存されたデータを含む XML に変換されます。しかし、私はを XML にしたく
ありません。読み返したときに そうであってほしい。isChangingisExecutingfalse

どうやってやるの ?

4

1 に答える 1

2

この使用例をサポートするには、いくつかの方法があります。

オプション1 -@XmlTransient

注釈を使用して@XmlTransient、フィールド/プロパティがマーシャリングまたはアンマーシャリングされるのを防ぐことができます。

オプション #2 -@XmlAccessorType(XmlAccessType.NONE)

@XmlAccessorType(XmlAccessType.NONE)注釈付きのフィールド/プロパティのみがマーシャリング/マーシャリング解除されるように、クラスに注釈を付けることができます。

詳細については

于 2013-05-22T17:52:35.993 に答える