Search in sources :

Example 1 with ImportException

use of org.jabref.logic.importer.ImportException in project jabref by JabRef.

the class ArgumentProcessor method importFile.

private static Optional<ParserResult> importFile(Path file, String importFormat) {
    try {
        if (!"*".equals(importFormat)) {
            System.out.println(Localization.lang("Importing") + ": " + file);
            ParserResult result = Globals.IMPORT_FORMAT_READER.importFromFile(importFormat, file);
            return Optional.of(result);
        } else {
            // * means "guess the format":
            System.out.println(Localization.lang("Importing in unknown format") + ": " + file);
            ImportFormatReader.UnknownFormatImport importResult = Globals.IMPORT_FORMAT_READER.importUnknownFormat(file);
            System.out.println(Localization.lang("Format used") + ": " + importResult.format);
            return Optional.of(importResult.parserResult);
        }
    } catch (ImportException ex) {
        System.err.println(Localization.lang("Error opening file") + " '" + file + "': " + ex.getLocalizedMessage());
        return Optional.empty();
    }
}
Also used : ImportException(org.jabref.logic.importer.ImportException) ParserResult(org.jabref.logic.importer.ParserResult) ImportFormatReader(org.jabref.logic.importer.ImportFormatReader)

Aggregations

ImportException (org.jabref.logic.importer.ImportException)1 ImportFormatReader (org.jabref.logic.importer.ImportFormatReader)1 ParserResult (org.jabref.logic.importer.ParserResult)1