2 package net.sf.openrocket.preset.xml;
4 import net.sf.openrocket.preset.ComponentPreset;
5 import net.sf.openrocket.preset.ComponentPresetFactory;
6 import net.sf.openrocket.preset.InvalidComponentPresetException;
7 import net.sf.openrocket.preset.TypedPropertyMap;
9 import javax.xml.bind.annotation.XmlAccessType;
10 import javax.xml.bind.annotation.XmlAccessorType;
11 import javax.xml.bind.annotation.XmlElement;
12 import javax.xml.bind.annotation.XmlRootElement;
13 import java.util.List;
16 * Bulkhead preset XML handler.
18 @XmlRootElement(name = "BulkHead")
19 @XmlAccessorType(XmlAccessType.FIELD)
20 public class BulkHeadDTO extends BaseComponentDTO {
22 @XmlElement(name = "OutsideDiameter")
23 private double outsideDiameter;
24 @XmlElement(name = "Length")
25 private double length;
27 public BulkHeadDTO() {
31 * Most-useful constructor that maps a BulkHead preset to a BulkHeadDTO.
33 * @param thePreset the preset
35 * @throws net.sf.openrocket.util.BugException thrown if the expected bulk head keys are not in the preset
37 public BulkHeadDTO(final ComponentPreset thePreset) {
39 setOutsideDiameter(thePreset.get(ComponentPreset.OUTER_DIAMETER));
40 setLength(thePreset.get(ComponentPreset.LENGTH));
43 public double getOutsideDiameter() {
44 return outsideDiameter;
47 public void setOutsideDiameter(final double theOutsideDiameter) {
48 outsideDiameter = theOutsideDiameter;
51 public double getLength() {
55 public void setLength(final double theLength) {
59 public ComponentPreset asComponentPreset(List<MaterialDTO> materials) throws InvalidComponentPresetException {
60 TypedPropertyMap props = new TypedPropertyMap();
61 addProps(props, materials);
62 props.put(ComponentPreset.OUTER_DIAMETER, this.getOutsideDiameter());
63 props.put(ComponentPreset.LENGTH, this.getLength());
64 props.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
66 return ComponentPresetFactory.create(props);