Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IFileManager |
|
| 1.0;1 | ||||
IFileManager$JTDVersion |
|
| 1.0;1 | ||||
IFileManager$XmlBackupVersion |
|
| 1.0;1 |
1 | package org.jtheque.core.managers.file; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque 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 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import org.jtheque.core.managers.ActivableManager; | |
20 | import org.jtheque.core.managers.file.able.BackupReader; | |
21 | import org.jtheque.core.managers.file.able.BackupWriter; | |
22 | import org.jtheque.core.managers.file.able.FileType; | |
23 | import org.jtheque.utils.io.FileException; | |
24 | ||
25 | import java.io.File; | |
26 | import java.util.Collection; | |
27 | ||
28 | /** | |
29 | * A FileManager specification. | |
30 | * | |
31 | * @author Baptiste Wicht | |
32 | */ | |
33 | public interface IFileManager extends ActivableManager { | |
34 | long JT_CATEGORY_SEPARATOR = -89569876428459544L; | |
35 | long JT_INTERN_SEPARATOR = -95684111123647897L; | |
36 | ||
37 | int CONTENT = 5; | |
38 | int NO_CONTENT = 10; | |
39 | ||
40 | String UTF_NULL = "NULL"; | |
41 | ||
42 | String JT_KEY = "1W@JTHEQUE@W1"; | |
43 | ||
44 | /** | |
45 | * XML Backup versions. | |
46 | * | |
47 | * @author Baptiste Wicht | |
48 | */ | |
49 | 0 | enum XmlBackupVersion { |
50 | 0 | FIRST, |
51 | 0 | SECOND //JTheque Core 2.0 |
52 | } | |
53 | ||
54 | /** | |
55 | * JTD File versions. | |
56 | * | |
57 | * @author Baptiste Wicht | |
58 | */ | |
59 | 0 | enum JTDVersion { |
60 | 0 | FIRST |
61 | } | |
62 | ||
63 | /** | |
64 | * Format an UTF string before insert it in a file to be sure that it isn't empty. | |
65 | * | |
66 | * @param utf The UTF string. | |
67 | * @return The UTF String if it isn't empty or NULL. | |
68 | */ | |
69 | String formatUTFToWrite(String utf); | |
70 | ||
71 | /** | |
72 | * Format an UTF string after read it in a file to get the good value. | |
73 | * | |
74 | * @param utf The UTF string. | |
75 | * @return The UTF String if it isn't empty or NULL. | |
76 | */ | |
77 | String formatUTFToRead(String utf); | |
78 | ||
79 | /** | |
80 | * Backup to a File with a specific format. | |
81 | * | |
82 | * @param format The format of the backup. | |
83 | * @param file The file to backup to. | |
84 | * @throws FileException Thrown when an error occurs during the backup process. | |
85 | */ | |
86 | void backup(FileType format, File file) throws FileException; | |
87 | ||
88 | /** | |
89 | * Restore the data from a File with a specific format. | |
90 | * | |
91 | * @param format The format of the backup. | |
92 | * @param file The file to restore from. | |
93 | * @throws FileException Thrown when an error occurs during the restore process. | |
94 | */ | |
95 | void restore(FileType format, File file) throws FileException; | |
96 | ||
97 | /** | |
98 | * Register a new BackupWriter. | |
99 | * | |
100 | * @param format The format the BackupWriter manage. | |
101 | * @param writer The writer to register. | |
102 | */ | |
103 | void registerBackupWriter(FileType format, BackupWriter writer); | |
104 | ||
105 | /** | |
106 | * Register a new BackupReader. | |
107 | * | |
108 | * @param format The format the BackupReader manage. | |
109 | * @param reader The reader to register. | |
110 | */ | |
111 | void registerBackupReader(FileType format, BackupReader reader); | |
112 | ||
113 | /** | |
114 | * Unregister a BackupWriter. | |
115 | * | |
116 | * @param format The format the BackupWriter manage. | |
117 | * @param writer The writer to unregister. | |
118 | */ | |
119 | void unregisterBackupWriter(FileType format, BackupWriter writer); | |
120 | ||
121 | /** | |
122 | * Unregister a BackupReader. | |
123 | * | |
124 | * @param format The format the BackupReader manage. | |
125 | * @param reader The reader to unregister. | |
126 | */ | |
127 | void unregisterBackupReader(FileType format, BackupReader reader); | |
128 | ||
129 | /** | |
130 | * Return all the backupers of a specific format. | |
131 | * | |
132 | * @param format The format. | |
133 | * @return All the BackupReader. | |
134 | */ | |
135 | Collection<BackupReader> getBackupReaders(FileType format); | |
136 | ||
137 | /** | |
138 | * Indicate if the backup is possible for the specified file type. | |
139 | * | |
140 | * @param type The file type to test. | |
141 | * @return true if the backup is possible with this file type else false. | |
142 | */ | |
143 | boolean isBackupPossible(FileType type); | |
144 | ||
145 | /** | |
146 | * Indicate if the restore is possible for the specified file type. | |
147 | * | |
148 | * @param type The file type to test. | |
149 | * @return true if the restore is possible with this file type else false. | |
150 | */ | |
151 | boolean isRestorePossible(FileType type); | |
152 | } |