1 package net.sf.openrocket.android.thrustcurve;
\r
3 import java.io.IOException;
\r
4 import java.io.StringReader;
\r
5 import java.util.List;
\r
7 import net.sf.openrocket.file.motor.RASPMotorLoader;
\r
8 import net.sf.openrocket.file.motor.RockSimMotorLoader;
\r
9 import net.sf.openrocket.motor.Motor;
\r
10 import net.sf.openrocket.motor.ThrustCurveMotor;
\r
12 public class MotorBurnFile {
\r
14 private Integer motorId;
\r
15 private String filetype;
\r
16 private ThrustCurveMotor thrustCurveMotor;
\r
18 public void init() {
\r
19 this.motorId = null;
\r
20 this.filetype = null;
\r
21 this.thrustCurveMotor = null;
\r
25 public MotorBurnFile clone() {
\r
26 MotorBurnFile clone = new MotorBurnFile();
\r
27 clone.motorId = this.motorId;
\r
28 clone.filetype = this.filetype;
\r
29 clone.thrustCurveMotor = this.thrustCurveMotor;
\r
33 public void decodeFile(String data) {
\r
35 if (SupportedFileTypes.RASP_FORMAT.equals(filetype)) {
\r
36 RASPMotorLoader loader = new RASPMotorLoader();
\r
37 List<Motor> motors = loader.load( new StringReader(data), "download");
\r
38 this.thrustCurveMotor = (ThrustCurveMotor) motors.get(0);
\r
39 } else if (SupportedFileTypes.ROCKSIM_FORMAT.equals(filetype) ){
\r
40 RockSimMotorLoader loader = new RockSimMotorLoader();
\r
41 List<Motor> motors = loader.load( new StringReader(data), "download");
\r
42 this.thrustCurveMotor = (ThrustCurveMotor) motors.get(0);
\r
44 } catch ( IOException ex ) {
\r
45 this.thrustCurveMotor = null;
\r
50 * @return the motor_id
\r
52 public Integer getMotorId() {
\r
57 * @param motor_id the motor_id to set
\r
59 public void setMotorId(Integer motorId) {
\r
60 this.motorId = motorId;
\r
64 * @return the filetype
\r
66 public String getFiletype() {
\r
71 * @param filetype the filetype to set
\r
73 public void setFiletype(String filetype) {
\r
74 this.filetype = filetype;
\r
78 * @return the thrustCurveMotor
\r
80 public ThrustCurveMotor getThrustCurveMotor() {
\r
81 return thrustCurveMotor;
\r