import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
+import net.sf.openrocket.file.simplesax.AbstractElementHandler;
import net.sf.openrocket.file.simplesax.ElementHandler;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.rocketcomponent.Rocket;
* <p/>
* Limitations: Rocksim flight simulations are not imported; tube fins are not supported; Rocksim 'pods' are not supported.
*/
-public class RocksimHandler extends ElementHandler {
+public class RocksimHandler extends AbstractElementHandler {
/**
* The main content handler.
/**
* Handles the content of the <DesignInformation> tag.
*/
-class RocksimContentHandler extends ElementHandler {
+class RocksimContentHandler extends AbstractElementHandler {
/**
* The OpenRocketDocument that is the container for the rocket.
*/
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes,
WarningSet warnings) {
- if ("DesignInformation".equals(element)) {
+ if (RocksimCommonConstants.DESIGN_INFORMATION.equals(element)) {
//The next sub-element is "RocketDesign", which is really the only thing that matters. Rather than
//create another handler just for that element, handle it here.
return this;
}
- if ("FileVersion".equals(element)) {
+ if (RocksimCommonConstants.FILE_VERSION.equals(element)) {
return PlainTextHandler.INSTANCE;
}
- if ("RocketDesign".equals(element)) {
+ if (RocksimCommonConstants.ROCKET_DESIGN.equals(element)) {
return new RocketDesignHandler(rocket);
}
return null;
* SAX handler for Rocksim file version number. The value is not used currently, but could be used in the future
* for backward/forward compatibility reasons (different lower level handlers could be called via a strategy pattern).
*/
- if ("FileVersion".equals(element)) {
+ if (RocksimCommonConstants.FILE_VERSION.equals(element)) {
version = content;
}
}
* Correct functioning of this handler is predicated on the stage count element appearing before the actual stage parts
* structures. If that invariant is not true, then behavior will be unpredictable.
*/
-class RocketDesignHandler extends ElementHandler {
+class RocketDesignHandler extends AbstractElementHandler {
/**
* The parent component.
*/
return new StageHandler(stage);
}
}
- if ("Name".equals(element)) {
+ if (RocksimCommonConstants.NAME.equals(element)) {
return PlainTextHandler.INSTANCE;
}
if ("StageCount".equals(element)) {
public void closeElement(String element, HashMap<String, String> attributes,
String content, WarningSet warnings) throws SAXException {
try {
- if ("Name".equals(element)) {
+ if (RocksimCommonConstants.NAME.equals(element)) {
component.setName(content);
}
if ("StageCount".equals(element)) {
/**
* A SAX handler for a Rocksim stage.
*/
-class StageHandler extends ElementHandler {
+class StageHandler extends AbstractElementHandler {
/**
* The parent OpenRocket component.
*/