]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.export.core/src/org/simantics/export/core/intf/FormatClass.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.export.core / src / org / simantics / export / core / intf / FormatClass.java
diff --git a/bundles/org.simantics.export.core/src/org/simantics/export/core/intf/FormatClass.java b/bundles/org.simantics.export.core/src/org/simantics/export/core/intf/FormatClass.java
new file mode 100644 (file)
index 0000000..f0376cf
--- /dev/null
@@ -0,0 +1,112 @@
+package org.simantics.export.core.intf;\r
+\r
+import java.io.File;\r
+import java.util.List;\r
+\r
+import org.osgi.service.prefs.Preferences;\r
+import org.simantics.databoard.binding.mutable.Variant;\r
+import org.simantics.databoard.type.RecordType;\r
+import org.simantics.export.core.ExportContext;\r
+import org.simantics.export.core.error.ExportException;\r
+import org.simantics.export.core.manager.Content;\r
+\r
+/**\r
+ * Format class contains format related code.\r
+ *\r
+ * @author toni.kalajainen@semantum.fi\r
+ */\r
+public interface FormatClass {\r
+       \r
+       /**\r
+        * Create a new file. Return a format specific writer object. \r
+        * \r
+        * @param context contextual data\r
+        * @param outputFile\r
+        * @param options\r
+        * @return writer \r
+        * @throws ExportException\r
+        */\r
+       Object createFile( ExportContext context, File outputFile, Variant options ) throws ExportException;\r
+       \r
+       /**\r
+        * Open a file for reading.\r
+        * \r
+        * @param context\r
+        * @param inputFile\r
+        * @param options\r
+        * @throws ExportException\r
+        */\r
+       Object openFile( ExportContext context, File inputFile, Variant options ) throws ExportException;\r
+       \r
+       /**\r
+        * Close a reader or writer object.\r
+        * \r
+        * ExportException is thrown if flushing of the file fails. This is a signal that\r
+        * the file is corrupted. The file is closed in all cases how ever. \r
+        * \r
+        * @param context\r
+        * @param handle\r
+        * @throws ExportException \r
+        */\r
+       void closeFile( ExportContext context, Object handle ) throws ExportException;\r
+\r
+       /**\r
+        * Add attachments to an open file handle. This method applies only to \r
+        * container files.  \r
+        * \r
+        * @param context\r
+        * @param handle\r
+        * @param attachements\r
+        * @throws ExportException\r
+        */\r
+       void addAttachment( ExportContext context, Object handle, List<Content> attachments ) throws ExportException;\r
+       \r
+       /**\r
+        * Get file format specific options.\r
+        * \r
+        * @param context\r
+        * @return a record type describing options \r
+        */\r
+       RecordType options( ExportContext context ) throws ExportException;\r
+       \r
+       /**\r
+        * Validate that the options are usable for export.\r
+        * \r
+        * @param context\r
+        * @param options\r
+        * @return a list of errors\r
+        * @throws ExportException\r
+        */\r
+       List<String> validate( ExportContext context, Variant options ) throws ExportException;\r
+\r
+       /**\r
+        * Fill options with default values.\r
+        * \r
+        * @param options\r
+        * @throws ExportException \r
+        */\r
+       void fillDefaultPrefs( ExportContext context, Variant options ) throws ExportException;\r
+\r
+       /**\r
+        * Save format options to preferences node(s).\r
+        * \r
+        * A preference value may or may not exist in the options object.\r
+        * \r
+        * @param options\r
+        * @param contentScopeNode\r
+        * @param workbenchScopeNode\r
+        * @throws ExportException\r
+        */\r
+       void savePref( Variant options, Preferences contentScopeNode, Preferences workbenchScopeNode ) throws ExportException;\r
+       \r
+       /**\r
+        * Load format options from preferences node(s).\r
+        * \r
+        * @param options\r
+        * @param contentScopeNode\r
+        * @param workbenchScopeNode\r
+        * @throws ExportException\r
+        */\r
+       void loadPref( Variant options, Preferences contentScopeNode, Preferences workbenchScopeNode ) throws ExportException;\r
+       \r
+}\r