Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ImporterFactory |
|
| 2.0;2 |
1 | package org.jtheque.films.services.impl.utils.file.imports; | |
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.films.utils.Constants.Files.FileType; | |
20 | ||
21 | /** | |
22 | * A factory for importers. | |
23 | * | |
24 | * @author Baptiste Wicht | |
25 | */ | |
26 | final class ImporterFactory { | |
27 | 0 | private static final Importer[] IMPORTERS = { |
28 | new XMLImporter(), | |
29 | new JTFImporter(), | |
30 | new JTFEImporter() | |
31 | }; | |
32 | ||
33 | /** | |
34 | * Create a new ImporterFactory. This class isn't instanciable. | |
35 | */ | |
36 | private ImporterFactory() { | |
37 | 0 | super(); |
38 | 0 | } |
39 | ||
40 | /** | |
41 | * Get the importer for the specified file type. | |
42 | * | |
43 | * @param fileType The file type. | |
44 | * @return The importer for the specified file type. | |
45 | */ | |
46 | public static Importer getImporter(FileType fileType) { | |
47 | 0 | Importer importer = null; |
48 | ||
49 | 0 | for (Importer i : IMPORTERS) { |
50 | 0 | if (i.canImportFrom(fileType)) { |
51 | 0 | importer = i; |
52 | 0 | break; |
53 | } | |
54 | } | |
55 | ||
56 | 0 | return importer; |
57 | } | |
58 | } |