-
Notifications
You must be signed in to change notification settings - Fork 25
Import Export
In this tutorial we learn how existing import/export mechanisms work and how the import/export mechanism can bey customized for other formats (e.g. databases).
We illustrate the mechanism given the following design space and example design. The example is solely of illustrative purpose.
<SParam id="Steak"> <NParam id="Temperature" type="decimal" inclMin="25" inclMax="80" /> <NParam type="double" id="ProportionBurned" /> <SChoice id="Raw"> <NParam id="HealthRisk" type="boolean" /> </SChoice> <SChoice id="Medium"> <SParam id="Rather"> <SChoice id="Raw" /> <SChoice id="WellDone" /> </SParam> </SChoice> <SChoice id="WellDone" /> </SParam>
Thus, a steak has a certain temperature (say, between 25 and 80 degrees Celsius), and can be of one of three types: Raw, Medium, and WellDone. If it is raw, there is a potential health risk. The medium steak can lean towards two ends.
<SValue id="Steak" value="Medium"> <NValue id="Temperature" value="39.19306187269093744163228620891459286212921142578125" /> <NValue id="ProportionBurned" value="0.2187556079980736" /> <SValue id="Rather" value="WellDone" /> </SValue>
This steak has been randomly created by the execution of the example code in here (and the precision of the temperature assessment can be questioned). The steak is well done, quite burned, and not hot; not a real highlight.
Given that we have created a random steak with
IDesignSpace space = new DesignSpace("structuredSpaceAdvanced.xml"); IDesign steak = space.next("MySteak");
we can export it to XML by
steak.export(new XMLFileExporter("mySteak.xml"));
and import it from the XML again by
IDesign sameSteak = space.impOrt(new XMLFileImporter("mySteak.xml"));
The import/export hook can be used for other formats. InPUT comes by default with export support to LaTeX tables and Java Properties files. The LaTeX exporter is called like this
steak.export(new LaTeXExporter("steakTable.tex")); // design space.export(new LaTeXExporter("steakSpaceTable.tex")); // design space
and results in the following LaTeX processed output:
The following results in a properties file with the InPUT parameters.
Properties streakProperties = steak.export(new PropertiesExporter());
The mechanism can be used to create customized importer/exporter by implementing the Exporter or Importer interfaces.