DGP - added isCompatible checks for all Rocksim components
[debian/openrocket] / src / net / sf / openrocket / file / rocksim / StreamerHandler.java
index 9db287d2731c0d6e5c975e615c809fc9df7caa08..73a8c2e8b6c83df26a828747290f0ddd794e62a9 100644 (file)
@@ -6,7 +6,6 @@ package net.sf.openrocket.file.rocksim;
 import net.sf.openrocket.aerodynamics.WarningSet;
 import net.sf.openrocket.file.simplesax.ElementHandler;
 import net.sf.openrocket.file.simplesax.PlainTextHandler;
-import net.sf.openrocket.material.Material;
 import net.sf.openrocket.rocketcomponent.RocketComponent;
 import net.sf.openrocket.rocketcomponent.Streamer;
 import org.xml.sax.SAXException;
@@ -16,7 +15,7 @@ import java.util.HashMap;
 /**
  * A SAX handler for Streamer components.
  */
-class StreamerHandler extends PositionDependentHandler<Streamer> {
+class StreamerHandler extends RecoveryDeviceHandler<Streamer> {
 
     /**
      * The OpenRocket Streamer.
@@ -27,21 +26,31 @@ class StreamerHandler extends PositionDependentHandler<Streamer> {
      * Constructor.
      *
      * @param c the parent component
+     * @param warnings  the warning set
+     * 
      * @throws IllegalArgumentException thrown if <code>c</code> is null
      */
-    public StreamerHandler(RocketComponent c) throws IllegalArgumentException {
+    public StreamerHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException {
         if (c == null) {
             throw new IllegalArgumentException("The parent of a streamer may not be null.");
         }
         streamer = new Streamer();
-        c.addChild(streamer);
+        if (isCompatible(c, Streamer.class, warnings)) {
+            c.addChild(streamer);
+        }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public ElementHandler openElement(String element, HashMap<String, String> attributes, WarningSet warnings) {
         return PlainTextHandler.INSTANCE;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void closeElement(String element, HashMap<String, String> attributes, String content, WarningSet warnings)
             throws SAXException {
@@ -66,30 +75,13 @@ class StreamerHandler extends PositionDependentHandler<Streamer> {
         }
     }
 
-    @Override
-    public Streamer getComponent() {
-        return streamer;
-    }
-
     /**
-     * Set the relative position onto the component.  This cannot be done directly because setRelativePosition is not
-     * public in all components.
-     *
-     * @param position the OpenRocket position
+     * {@inheritDoc}
      */
     @Override
-    public void setRelativePosition(RocketComponent.Position position) {
-        streamer.setRelativePosition(position);
+    public Streamer getComponent() {
+        return streamer;
     }
 
-    /**
-     * Get the required type of material for this component.
-     *
-     * @return BULK
-     */
-    @Override
-    public Material.Type getMaterialType() {
-        return Material.Type.SURFACE;
-    }
 }