1 package org.simantics.export.core.intf;
6 import org.osgi.service.prefs.Preferences;
7 import org.simantics.databoard.binding.mutable.Variant;
8 import org.simantics.databoard.type.RecordType;
9 import org.simantics.export.core.ExportContext;
10 import org.simantics.export.core.error.ExportException;
11 import org.simantics.export.core.manager.Content;
14 * Format class contains format related code.
16 * @author toni.kalajainen@semantum.fi
18 public interface FormatClass {
21 * Create a new file. Return a format specific writer object.
23 * @param context contextual data
27 * @throws ExportException
29 Object createFile( ExportContext context, File outputFile, Variant options ) throws ExportException;
32 * Open a file for reading.
37 * @throws ExportException
39 Object openFile( ExportContext context, File inputFile, Variant options ) throws ExportException;
42 * Close a reader or writer object.
44 * ExportException is thrown if flushing of the file fails. This is a signal that
45 * the file is corrupted. The file is closed in all cases how ever.
49 * @throws ExportException
51 void closeFile( ExportContext context, Object handle ) throws ExportException;
54 * Add attachments to an open file handle. This method applies only to
60 * @throws ExportException
62 void addAttachment( ExportContext context, Object handle, List<Content> attachments ) throws ExportException;
65 * Get file format specific options.
68 * @return a record type describing options
70 RecordType options( ExportContext context ) throws ExportException;
73 * Validate that the options are usable for export.
77 * @return a list of errors
78 * @throws ExportException
80 List<String> validate( ExportContext context, Variant options ) throws ExportException;
83 * Fill options with default values.
86 * @throws ExportException
88 void fillDefaultPrefs( ExportContext context, Variant options ) throws ExportException;
91 * Save format options to preferences node(s).
93 * A preference value may or may not exist in the options object.
96 * @param contentScopeNode
97 * @param workbenchScopeNode
98 * @throws ExportException
100 void savePref( Variant options, Preferences contentScopeNode, Preferences workbenchScopeNode ) throws ExportException;
103 * Load format options from preferences node(s).
106 * @param contentScopeNode
107 * @param workbenchScopeNode
108 * @throws ExportException
110 void loadPref( Variant options, Preferences contentScopeNode, Preferences workbenchScopeNode ) throws ExportException;