-package org.simantics.export.core.manager;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.util.TreeMap;\r
-\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.mutable.Variant;\r
-import org.simantics.databoard.container.DataContainer;\r
-import org.simantics.databoard.container.DataContainers;\r
-import org.simantics.db.RequestProcessor;\r
-import org.simantics.export.core.error.ExportException;\r
-import org.simantics.graph.db.TransferableGraphSource;\r
-import org.simantics.graph.db.TransferableGraphs;\r
-\r
-public class TransferableGraphWriter {\r
-\r
- public final File file; \r
- public final String format;\r
- public final int version;\r
- \r
- public TransferableGraphWriter(File file, String format, int version) {\r
- this.file = file;\r
- this.format = format;\r
- this.version = version;\r
- }\r
- \r
- /**\r
- * Write TG to the file that is associated with this writer.\r
- * \r
- * @param tgBinding\r
- * @param tg\r
- * @throws ExportException\r
- */\r
- public void writeFile(Binding tgBinding, Object tg) throws ExportException {\r
- try {\r
- Variant variant = new Variant(tgBinding, tg);\r
- DataContainer dataContainer = new DataContainer(format, version, variant);\r
- DataContainers.writeFile(file, dataContainer);\r
- } catch (IOException e) {\r
- throw new ExportException( "I/O Error occured: "+e.getMessage() );\r
- } \r
- }\r
- \r
- /**\r
- * Write from TG Source to the file that is associated with this writer.\r
- * \r
- * @param session request processor to be used for reading the source\r
- * @param source TG source\r
- * @throws ExportException\r
- */\r
- public void writeFile(RequestProcessor session, TransferableGraphSource source) throws ExportException\r
- {\r
- writeFile(session, source, new TreeMap<String, Variant>());\r
- }\r
-\r
- /**\r
- * Write from TG Source to the file that is associated with this writer.\r
- * \r
- * @param session request processor to be used for reading the source\r
- * @param source TG source\r
- * @throws ExportException\r
- */\r
- public void writeFile(RequestProcessor session, TransferableGraphSource source, TreeMap<String,Variant> metadata) throws ExportException\r
- {\r
- try {\r
- TransferableGraphs.writeTransferableGraph(\r
- session, \r
- format, \r
- version, \r
- metadata, \r
- source, \r
- file);\r
- } catch (Exception e) {\r
- throw new ExportException(e);\r
- }\r
- }\r
-\r
-}\r
+package org.simantics.export.core.manager;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.TreeMap;
+
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.mutable.Variant;
+import org.simantics.databoard.container.DataContainer;
+import org.simantics.databoard.container.DataContainers;
+import org.simantics.db.RequestProcessor;
+import org.simantics.export.core.error.ExportException;
+import org.simantics.graph.db.TransferableGraphSource;
+import org.simantics.graph.db.TransferableGraphs;
+
+public class TransferableGraphWriter {
+
+ public final File file;
+ public final String format;
+ public final int version;
+
+ public TransferableGraphWriter(File file, String format, int version) {
+ this.file = file;
+ this.format = format;
+ this.version = version;
+ }
+
+ /**
+ * Write TG to the file that is associated with this writer.
+ *
+ * @param tgBinding
+ * @param tg
+ * @throws ExportException
+ */
+ public void writeFile(Binding tgBinding, Object tg) throws ExportException {
+ try {
+ Variant variant = new Variant(tgBinding, tg);
+ DataContainer dataContainer = new DataContainer(format, version, variant);
+ DataContainers.writeFile(file, dataContainer);
+ } catch (IOException e) {
+ throw new ExportException( "I/O Error occured: "+e.getMessage() );
+ }
+ }
+
+ /**
+ * Write from TG Source to the file that is associated with this writer.
+ *
+ * @param session request processor to be used for reading the source
+ * @param source TG source
+ * @throws ExportException
+ */
+ public void writeFile(RequestProcessor session, TransferableGraphSource source) throws ExportException
+ {
+ writeFile(session, source, new TreeMap<String, Variant>());
+ }
+
+ /**
+ * Write from TG Source to the file that is associated with this writer.
+ *
+ * @param session request processor to be used for reading the source
+ * @param source TG source
+ * @throws ExportException
+ */
+ public void writeFile(RequestProcessor session, TransferableGraphSource source, TreeMap<String,Variant> metadata) throws ExportException
+ {
+ try {
+ TransferableGraphs.writeTransferableGraph(
+ session,
+ format,
+ version,
+ metadata,
+ source,
+ file);
+ } catch (Exception e) {
+ throw new ExportException(e);
+ }
+ }
+
+}