您的位置:首页 > 编程语言 > Java开发

Java XML 序列化和反序列化

2017-10-19 22:15 417 查看
Utils 类:

1 import javax.xml.bind.annotation.XmlAccessType;
2 import javax.xml.bind.annotation.XmlAccessorType;
3 import javax.xml.bind.annotation.XmlAttribute;
4 import javax.xml.bind.annotation.XmlElement;
5 import javax.xml.bind.annotation.XmlRootElement;
6 import javax.xml.bind.annotation.XmlType;
7
8 /**
9  * Created by Leo on 2017/2/10.
10  */
11 @XmlType(name = "Transition", propOrder = { "id", "from", "to", "name", "coordinate" })
12 @XmlAccessorType(XmlAccessType.FIELD)
13 @XmlRootElement()
14 public class Transition {
15
16     @XmlAttribute(name = "Id")
17     private String id;
18
19     @XmlAttribute(name = "From")
20     private String from;
21
22     @XmlAttribute(name = "To")
23     private String to;
24
25     @XmlAttribute(name = "Name")
26     private String name;
27
28     @XmlElement(name = "Coordinates")
29     private Coordinate coordinate;
30
31     public String getId() {
32         return this.id;
33     }
34
35     public void setId(String value) {
36         this.id = value;
37     }
38
39     public String getFrom() {
40         return this.from;
41     }
42
43     public void setFrom(String value) {
44         this.from = value;
45     }
46
47     public String getTo() {
48         return this.to;
49     }
50
51     public void setTo(String value) {
52         this.to = value;
53     }
54
55     public String getName() {
56         return this.name;
57     }
58
59     public void setName(String value) {
60         this.name = value;
61     }
62
63     public Coordinate getCoordinate() {
64         return this.coordinate;
65     }
66
67     public void setCoordinate(Coordinate value) {
68         this.coordinate = value;
69     }
70
71 }


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: