Initial XML generating code for .orc format.
[debian/openrocket] / core / src / net / sf / openrocket / preset / xml / MaterialDTO.java
1
2 package net.sf.openrocket.preset.xml;
3
4 import net.sf.openrocket.material.Material;
5
6 import javax.xml.bind.annotation.XmlAccessType;
7 import javax.xml.bind.annotation.XmlAccessorType;
8 import javax.xml.bind.annotation.XmlAttribute;
9 import javax.xml.bind.annotation.XmlElement;
10 import javax.xml.bind.annotation.XmlRootElement;
11
12 /**
13  * XML handler for materials.
14  */
15 @XmlRootElement(name = "Material")
16 @XmlAccessorType(XmlAccessType.FIELD)
17 public class MaterialDTO {
18
19     @XmlElement(name = "Name")
20     private String name;
21     @XmlElement(name = "Density")
22     private double density;
23     @XmlElement(name = "Type")
24     private MaterialTypeDTO type;
25     @XmlAttribute(name = "UnitsOfMeasure")
26     private String uom;
27
28     /**
29      * Default constructor.
30      */
31     public MaterialDTO() {
32     }
33
34     public MaterialDTO(final Material theMaterial) {
35         this(theMaterial.getName(), theMaterial.getDensity(), MaterialTypeDTO.asDTO(theMaterial.getType()),
36                 theMaterial.getType().getUnitGroup().getDefaultUnit().toString());
37     }
38
39     public MaterialDTO(final String theName, final double theDensity, final MaterialTypeDTO theType, final String theUom) {
40         name = theName;
41         density = theDensity;
42         type = theType;
43         uom = theUom;
44     }
45
46     public String getName() {
47         return name;
48     }
49
50     public void setName(final String theName) {
51         name = theName;
52     }
53
54     public double getDensity() {
55         return density;
56     }
57
58     public void setDensity(final double theDensity) {
59         density = theDensity;
60     }
61
62     public MaterialTypeDTO getType() {
63         return type;
64     }
65
66     public void setType(final MaterialTypeDTO theType) {
67         type = theType;
68     }
69
70     public String getUom() {
71         return uom;
72     }
73
74     public void setUom(final String theUom) {
75         uom = theUom;
76     }
77 }