*/
public class DatabaseMotorFinder implements MotorFinder {
+ /**
+ * Do something when a missing motor is found.
+ *
+ * This implementation adds a Warning.MissingMotor to the warning set and returns null.
+ *
+ * Override this function to change the behavior.
+ *
+ * @return The Motor which will be put in the Rocket.
+ */
+ protected Motor handleMissingMotor(Type type, String manufacturer, String designation, double diameter, double length, String digest, WarningSet warnings) {
+ Warning.MissingMotor mmw = new Warning.MissingMotor();
+ mmw.setDesignation(designation);
+ mmw.setDigest(digest);
+ mmw.setDiameter(diameter);
+ mmw.setLength(length);
+ mmw.setManufacturer(manufacturer);
+ mmw.setType(type);
+ warnings.add(mmw);
+ return null;
+ }
+
@Override
public Motor findMotor(Type type, String manufacturer, String designation, double diameter, double length, String digest, WarningSet warnings) {
// No motors
if (motors.size() == 0) {
- Warning.MissingMotor mmw = new Warning.MissingMotor();
- mmw.setDesignation(designation);
- mmw.setDigest(digest);
- mmw.setDiameter(diameter);
- mmw.setLength(length);
- mmw.setManufacturer(manufacturer);
- mmw.setType(type);
- warnings.add(mmw);
- return null;
- }
+ return handleMissingMotor(type, manufacturer, designation, diameter, length, digest, warnings);
+ }
// One motor
if (motors.size() == 1) {
--- /dev/null
+package net.sf.openrocket.file;\r
+\r
+import net.sf.openrocket.aerodynamics.WarningSet;\r
+import net.sf.openrocket.motor.Motor;\r
+import net.sf.openrocket.motor.Motor.Type;\r
+import net.sf.openrocket.motor.ThrustCurveMotorPlaceholder;\r
+\r
+public class DatabaseMotorFinderWithMissingMotors extends DatabaseMotorFinder\r
+implements MotorFinder {\r
+\r
+ /**\r
+ * This implementation returns a ThrustCurveMotorPlaceholder.\r
+ */\r
+ @Override\r
+ protected Motor handleMissingMotor(Type type, String manufacturer, String designation, double diameter, double length, String digest, WarningSet warnings) {\r
+ Motor motor = new ThrustCurveMotorPlaceholder(type,\r
+ manufacturer,\r
+ designation,\r
+ diameter,\r
+ length,\r
+ digest,\r
+ /* delay */ Double.NaN,\r
+ /*launchMass*/ Double.NaN,\r
+ /*emptyMass*/ Double.NaN);\r
+ return motor;\r
+ }\r
+}\r