diff --git a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java index a1c5f835a..766176fe1 100644 --- a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java +++ b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java @@ -59,12 +59,13 @@ public class OpenRocketComponentSaver { * * @param theMaterialList the list of materials to be included * @param thePresetList the list of presets to be included + * @param isLegacy true if the legacy format should be used * * @return ORC-compliant XML * * @throws JAXBException */ - public String marshalToOpenRocketComponent(List theMaterialList, List thePresetList) throws + public String marshalToOpenRocketComponent(List theMaterialList, List thePresetList, boolean isLegacy) throws JAXBException { /** The context is thread-safe, but marshallers are not. Create a local one. */ Marshaller marshaller = context.createMarshaller(); @@ -97,9 +98,23 @@ public class OpenRocketComponentSaver { }); - marshaller.marshal(toOpenRocketComponentDTO(theMaterialList, thePresetList), sw); + marshaller.marshal(toOpenRocketComponentDTO(theMaterialList, thePresetList, isLegacy), sw); return sw.toString(); + } + /** + * This method marshals a list of materials and ComponentPresets into an .orc formatted XML string. + * + * @param theMaterialList the list of materials to be included + * @param thePresetList the list of presets to be included + * + * @return ORC-compliant XML + * + * @throws JAXBException + */ + public String marshalToOpenRocketComponent(List theMaterialList, List thePresetList) throws + JAXBException { + return marshalToOpenRocketComponent(theMaterialList, thePresetList, false); } /** @@ -156,8 +171,9 @@ public class OpenRocketComponentSaver { * * @return a corresponding ORC representation */ - private OpenRocketComponentDTO toOpenRocketComponentDTO(List theMaterialList, List thePresetList) { + private OpenRocketComponentDTO toOpenRocketComponentDTO(List theMaterialList, List thePresetList, boolean isLegacy) { OpenRocketComponentDTO rsd = new OpenRocketComponentDTO(); + rsd.setLegacy(isLegacy); if (theMaterialList != null) { for (Material material : theMaterialList) { diff --git a/swing/src/net/sf/openrocket/utils/RocksimComponentFileTranslator.java b/swing/src/net/sf/openrocket/utils/RocksimComponentFileTranslator.java index bbd12f143..cf9bca4be 100644 --- a/swing/src/net/sf/openrocket/utils/RocksimComponentFileTranslator.java +++ b/swing/src/net/sf/openrocket/utils/RocksimComponentFileTranslator.java @@ -51,7 +51,7 @@ public class RocksimComponentFileTranslator { MaterialHolder materialMap = loadAll(allPresets, new File(args[0])); LOGGER.println("\tMarshalling to XML"); - String xml = new OpenRocketComponentSaver().marshalToOpenRocketComponent(new ArrayList(materialMap.values()), allPresets); + String xml = new OpenRocketComponentSaver().marshalToOpenRocketComponent(new ArrayList(materialMap.values()), allPresets, true); // Try parsing the file LOGGER.println("\tValidating XML");