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());
|
}
|
}
|