QedeqFileDao.java
01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02  *
03  * Copyright 2000-2013,  Michael Meyling <mime@qedeq.org>.
04  *
05  * "Hilbert II" is free software; you can redistribute
06  * it and/or modify it under the terms of the GNU General Public
07  * License as published by the Free Software Foundation; either
08  * version 2 of the License, or (at your option) any later version.
09  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  */
15 
16 package org.qedeq.kernel.bo.module;
17 
18 import java.io.File;
19 import java.io.IOException;
20 import java.io.Reader;
21 
22 import org.qedeq.base.io.SourceArea;
23 import org.qedeq.kernel.bo.common.QedeqBo;
24 import org.qedeq.kernel.bo.common.ServiceProcess;
25 import org.qedeq.kernel.se.base.module.Qedeq;
26 import org.qedeq.kernel.se.common.ModuleContext;
27 import org.qedeq.kernel.se.common.SourceFileExceptionList;
28 
29 /**
30  * An instance of this interface can load and save QEDEQ module files.
31  *
32  @author  Michael Meyling
33  */
34 public interface QedeqFileDao {
35 
36     /**
37      * Set kernel services. Is called by the kernel to give this loader the opportunity to
38      * use kernel services within its methods. This is the first method the kernel calls.
39      *
40      @param   services    Internal kernel services.
41      */
42     public void setServices(InternalKernelServices services);
43 
44     /**
45      * Get kernel services.
46      *
47      @return  Internal kernel services.
48      */
49     public InternalKernelServices getServices();
50 
51     /**
52      * Load a QEDEQ module from file.
53      *
54      @param   process     We work in this process.
55      @param   prop        Module properties.
56      @param   localFile   Load file from this location.
57      @return  Loaded QEDEQ.
58      @throws  SourceFileExceptionList     Module could not be successfully loaded.
59      */
60     public Qedeq loadQedeq(ServiceProcess process, QedeqBo prop, File localFile)
61             throws SourceFileExceptionList;
62 
63     /**
64      * Save a QEDEQ module as file.
65      *
66      @param   process     We work in this process.
67      @param   prop        Module properties.
68      @param   localFile   Save module in this file.
69      @throws  SourceFileExceptionList     Module could not be successfully saved.
70      @throws  IOException                 File saving failed.
71      */
72     public void saveQedeq(ServiceProcess process, KernelQedeqBo prop, File localFile)
73             throws SourceFileExceptionList, IOException;
74 
75     /**
76      * Get area in source file for QEDEQ module context.
77      * If the system property "qedeq.test.xmlLocationFailures" is set to "true" a runtime
78      * exception is thrown if the context is not found.
79      *
80      @param   qedeq       Look at this QEDEQ module.
81      @param   context     Search for this context.
82      @return  Created file area. Maybe <code>null</code>.
83      */
84     public SourceArea createSourceArea(Qedeq qedeq, ModuleContext context);
85 
86     /**
87      * Get reader for local buffered QEDEQ module.
88      *
89      @param   prop    QEDEQ BO.
90      @return  Reader.
91      @throws  IOException     Reading failed.
92      */
93     public Reader getModuleReader(KernelQedeqBo propthrows IOException;
94 
95 }