class FileDocumentFactory {

    public static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf) throws IOException, DocumentException {

        final String fileName = leaf.getName();
        final String suffix = getSuffix(fileName);
        if (log.isDebugEnabled()) {
            log.debug("suffix=" + suffix);
        }

        if (PDF_SUFFIX.indexOf(suffix) >= 0) {
            return PdfDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
        }
        if (HTML_SUFFIX.indexOf(suffix) >= 0) {
            return HtmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
        }
        if (XML_SUFFIX.indexOf(suffix) >= 0) {
            if (IMS_MANIFEST_FILE.equals(fileName)) {
                return IMSMetadataDocument.createDocument(leafResourceContext, leaf);
            }
            return XmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
        }
        if (TEXT_SUFFIX.indexOf(suffix) >= 0) {
            return TextDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
        }

        // microsoft openxml
        if (suffix.indexOf(WORD_X_SUFFIX) >= 0) {
            return WordOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
        }
        if (suffix.indexOf(EXCEL_X_SUFFIX) >= 0) {
            if (excelFileEnabled) {
                return ExcelOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
            }
            throw new DocumentNotEnabledException("Indexing of Excel files (xlsx) is not enabled.");
        }
        if (suffix.indexOf(POWERPOINT_X_SUFFIX) >= 0) {
            if (pptFileEnabled) {
                return PowerPointOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
            }
            throw new DocumentNotEnabledException("Indexing of PowerPoint files (pptx) is not enabled.");
        }

        // microsoft
        if (WORD_SUFFIX.indexOf(suffix) >= 0) {
            return WordDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
        }
        if (POWERPOINT_SUFFIX.indexOf(suffix) >= 0) {
            if (pptFileEnabled) {
                return PowerPointDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
            }
            throw new DocumentNotEnabledException("Indexing of PowerPoint files (ppt) is not enabled.");
        }
        if (EXCEL_SUFFIX.indexOf(suffix) >= 0) {
            if (excelFileEnabled) {
                return ExcelDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
            }
            throw new DocumentNotEnabledException("Indexing of Excel files (xls) is not enabled.");
        }

        // open document
        if (OD_TEXT_SUFFIX.indexOf(suffix) >= 0 || OD_SPREADSHEET_SUFFIX.indexOf(suffix) >= 0 || OD_PRESENTATION_SUFFIX.indexOf(suffix) >= 0
                || OD_FORMULA_SUFFIX.indexOf(suffix) >= 0 || OD_GRAPHIC_SUFFIX.indexOf(suffix) >= 0) {
            return OpenDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
        }

        return UnkownDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix));
    }

      FileDocumentFactory(final SearchModule searchModule, MimeTypeProvider mimeTypeProvider);
    public  FileDocumentFactory(final SearchModule searchModule);

}