]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 package org.simantics.export.core.intf;\r
2 \r
3 import java.io.File;\r
4 import java.util.List;\r
5 \r
6 import org.osgi.service.prefs.Preferences;\r
7 import org.simantics.databoard.binding.mutable.Variant;\r
8 import org.simantics.databoard.type.RecordType;\r
9 import org.simantics.export.core.ExportContext;\r
10 import org.simantics.export.core.error.ExportException;\r
11 import org.simantics.export.core.manager.Content;\r
12 \r
13 /**\r
14  * Format class contains format related code.\r
15  *\r
16  * @author toni.kalajainen@semantum.fi\r
17  */\r
18 public interface FormatClass {\r
19         \r
20         /**\r
21          * Create a new file. Return a format specific writer object. \r
22          * \r
23          * @param context contextual data\r
24          * @param outputFile\r
25          * @param options\r
26          * @return writer \r
27          * @throws ExportException\r
28          */\r
29         Object createFile( ExportContext context, File outputFile, Variant options ) throws ExportException;\r
30         \r
31         /**\r
32          * Open a file for reading.\r
33          * \r
34          * @param context\r
35          * @param inputFile\r
36          * @param options\r
37          * @throws ExportException\r
38          */\r
39         Object openFile( ExportContext context, File inputFile, Variant options ) throws ExportException;\r
40         \r
41         /**\r
42          * Close a reader or writer object.\r
43          * \r
44          * ExportException is thrown if flushing of the file fails. This is a signal that\r
45          * the file is corrupted. The file is closed in all cases how ever. \r
46          * \r
47          * @param context\r
48          * @param handle\r
49          * @throws ExportException \r
50          */\r
51         void closeFile( ExportContext context, Object handle ) throws ExportException;\r
52 \r
53         /**\r
54          * Add attachments to an open file handle. This method applies only to \r
55          * container files.  \r
56          * \r
57          * @param context\r
58          * @param handle\r
59          * @param attachements\r
60          * @throws ExportException\r
61          */\r
62         void addAttachment( ExportContext context, Object handle, List<Content> attachments ) throws ExportException;\r
63         \r
64         /**\r
65          * Get file format specific options.\r
66          * \r
67          * @param context\r
68          * @return a record type describing options \r
69          */\r
70         RecordType options( ExportContext context ) throws ExportException;\r
71         \r
72         /**\r
73          * Validate that the options are usable for export.\r
74          * \r
75          * @param context\r
76          * @param options\r
77          * @return a list of errors\r
78          * @throws ExportException\r
79          */\r
80         List<String> validate( ExportContext context, Variant options ) throws ExportException;\r
81 \r
82         /**\r
83          * Fill options with default values.\r
84          * \r
85          * @param options\r
86          * @throws ExportException \r
87          */\r
88         void fillDefaultPrefs( ExportContext context, Variant options ) throws ExportException;\r
89 \r
90         /**\r
91          * Save format options to preferences node(s).\r
92          * \r
93          * A preference value may or may not exist in the options object.\r
94          * \r
95          * @param options\r
96          * @param contentScopeNode\r
97          * @param workbenchScopeNode\r
98          * @throws ExportException\r
99          */\r
100         void savePref( Variant options, Preferences contentScopeNode, Preferences workbenchScopeNode ) throws ExportException;\r
101         \r
102         /**\r
103          * Load format options from preferences node(s).\r
104          * \r
105          * @param options\r
106          * @param contentScopeNode\r
107          * @param workbenchScopeNode\r
108          * @throws ExportException\r
109          */\r
110         void loadPref( Variant options, Preferences contentScopeNode, Preferences workbenchScopeNode ) throws ExportException;\r
111         \r
112 }\r