01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2011, 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.se.base.module.Qedeq;
25 import org.qedeq.kernel.se.common.ModuleContext;
26 import org.qedeq.kernel.se.common.SourceFileExceptionList;
27
28 /**
29 * An instance of this interface can load and save QEDEQ module files.
30 *
31 * @author Michael Meyling
32 */
33 public interface QedeqFileDao {
34
35 /**
36 * Set kernel services. Is called by the kernel to give this loader the opportunity to
37 * use kernel services within its methods. This is the first method the kernel calls.
38 *
39 * @param services Internal kernel services.
40 */
41 public void setServices(InternalKernelServices services);
42
43 /**
44 * Get kernel services.
45 *
46 * @return Internal kernel services.
47 */
48 public InternalKernelServices getServices();
49
50 /**
51 * Load a QEDEQ module from file.
52 *
53 * @param prop Module properties.
54 * @param localFile Load file from this location.
55 * @return Loaded QEDEQ.
56 * @throws SourceFileExceptionList Module could not be successfully loaded.
57 */
58 public Qedeq loadQedeq(QedeqBo prop, final File localFile)
59 throws SourceFileExceptionList;
60
61 /**
62 * Save a QEDEQ module as file.
63 *
64 * @param prop Module properties.
65 * @param localFile Save module in this file.
66 * @throws SourceFileExceptionList Module could not be successfully saved.
67 * @throws IOException File saving failed.
68 */
69 public void saveQedeq(KernelQedeqBo prop, final File localFile)
70 throws SourceFileExceptionList, IOException;
71
72 /**
73 * Get area in source file for QEDEQ module context.
74 * If the system property "qedeq.test.xmlLocationFailures" is set to "true" a runtime
75 * exception is thrown if the context is not found.
76 *
77 * @param qedeq Look at this QEDEQ module.
78 * @param context Search for this context.
79 * @return Created file area. Maybe <code>null</code>.
80 */
81 public SourceArea createSourceArea(Qedeq qedeq, ModuleContext context);
82
83 /**
84 * Get reader for local buffered QEDEQ module.
85 *
86 * @param prop QEDEQ BO.
87 * @return Reader.
88 * @throws IOException Reading failed.
89 */
90 public Reader getModuleReader(KernelQedeqBo prop) throws IOException;
91
92 }
|