create changelog entry
[debian/openrocket] / android / src / net / sf / openrocket / android / thrustcurve / MotorBurnFile.java
1 package net.sf.openrocket.android.thrustcurve;\r
2 \r
3 import java.io.IOException;\r
4 import java.io.StringReader;\r
5 import java.util.List;\r
6 \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
11 \r
12 public class MotorBurnFile {\r
13 \r
14         private Integer motorId;\r
15         private String filetype;\r
16         private ThrustCurveMotor thrustCurveMotor;\r
17 \r
18         public void init() {\r
19                 this.motorId = null;\r
20                 this.filetype = null;\r
21                 this.thrustCurveMotor = null;\r
22         }\r
23 \r
24         @Override\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
30                 return clone;\r
31         }\r
32 \r
33         public void decodeFile(String data) {\r
34                 try {\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
43                         }\r
44                 } catch ( IOException ex ) {\r
45                         this.thrustCurveMotor = null;\r
46                 }\r
47         }\r
48 \r
49         /**\r
50          * @return the motor_id\r
51          */\r
52         public Integer getMotorId() {\r
53                 return motorId;\r
54         }\r
55 \r
56         /**\r
57          * @param motor_id the motor_id to set\r
58          */\r
59         public void setMotorId(Integer motorId) {\r
60                 this.motorId = motorId;\r
61         }\r
62 \r
63         /**\r
64          * @return the filetype\r
65          */\r
66         public String getFiletype() {\r
67                 return filetype;\r
68         }\r
69 \r
70         /**\r
71          * @param filetype the filetype to set\r
72          */\r
73         public void setFiletype(String filetype) {\r
74                 this.filetype = filetype;\r
75         }\r
76 \r
77         /**\r
78          * @return the thrustCurveMotor\r
79          */\r
80         public ThrustCurveMotor getThrustCurveMotor() {\r
81                 return thrustCurveMotor;\r
82         }\r
83 \r
84 }\r