]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.fileimport/src/org/simantics/fileimport/IGenericFileImport.java
cba016f42a727fa1f0387952210ad7297fb7945a
[simantics/platform.git] / bundles / org.simantics.fileimport / src / org / simantics / fileimport / IGenericFileImport.java
1 package org.simantics.fileimport;
2
3 import java.nio.file.Path;
4 import java.util.Map;
5 import java.util.Optional;
6
7 /**
8  * Base interface for performing file imports. 
9  * 
10  * Usually with Simantics products every file that will be imported will become 
11  * a resource in the Simantics database. For these cases see {@link SimanticsResourceFileImport}
12  * 
13  * @author Jani Simomaa
14  *
15  */
16 public interface IGenericFileImport {
17
18     /**
19      * Performs the import for the given file
20      * 
21      * @param file Path to file to import
22      * @return Optional string which will be the identifier of the imported file which can later be used for removing the imported entity
23      * @throws Exception
24      */
25     Optional<String> perform(Path file) throws Exception;
26
27     /**
28      * Remove the entity
29      * 
30      * @param identifier String identifier which can be used to remove the imported entity
31      */
32     void remove(String identifier) throws Exception;
33     
34     /**
35      * Returns a key-value map for file extensions this importer can handle
36      * 
37      * @return Map<String, String> allowed extensions this service can handle. Key is the extension e.g. <code>.sharedLibrary</code> and the value is the description of the extension
38      */
39     Map<String, String> allowedExtensionsWithFilters();
40
41 }