Leonel FOFOU
2026-07-28 32450e295200b2bc7896518ff74161ff26772e2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.megatim.manuel.core.convert;
 
import java.nio.file.Path;
import java.util.Locale;
 
/** Choisit le bon convertisseur selon l'extension du fichier source. */
public final class ConverterFactory {
 
    private ConverterFactory() {}
 
    public static boolean isSupported(String fileName) {
        String n = fileName.toLowerCase(Locale.ROOT);
        return n.endsWith(".docx") || n.endsWith(".doc") || n.endsWith(".pptx") || n.endsWith(".ppt");
    }
 
    public static DocumentConverter forFile(Path source, Path outputDir) {
        String n = source.getFileName().toString().toLowerCase(Locale.ROOT);
        if (n.endsWith(".docx")) return new DocxConverter(outputDir);
        if (n.endsWith(".doc"))  return new DocConverter(outputDir);
        if (n.endsWith(".pptx")) return new PptxConverter(outputDir);
        if (n.endsWith(".ppt"))  return new PptConverter(outputDir);
        throw new IllegalArgumentException("Format non pris en charge : " + source.getFileName());
    }
}