Top Inners Fields Constructors Methods
org.jabref.logic.importer

public Class ImportFormatReader

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.file.Path, java.util.ArrayList, .List, .Objects, .Optional, .SortedSet, .TreeSet, org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences, org.jabref.logic.importer.fileformat.BiblioscapeImporter, .BibtexImporter, .CffImporter, .CitaviXmlImporter, .CopacImporter, .EndnoteImporter, .EndnoteXmlImporter, .InspecImporter, .IsiImporter, .MedlineImporter, .MedlinePlainImporter, .ModsImporter, .MsBibImporter, .OvidImporter, .PdfContentImporter, .PdfEmbeddedBibFileImporter, .PdfGrobidImporter, .PdfMergeMetadataImporter, .PdfVerbatimBibTextImporter, .PdfXmpImporter, .RepecNepImporter, .RisImporter, .SilverPlatterImporter, org.jabref.logic.l10n.Localization, org.jabref.model.database.BibDatabases, org.jabref.model.entry.BibEntry, org.jabref.model.util.FileUpdateMonitor

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static record

Field Summary

Modifier and TypeField and Description
public static final String
private final CitationKeyPatternPreferences
private final FileUpdateMonitor
private final List<Importer>
formats

All import formats.

private final ImporterPreferences
private final ImportFormatPreferences

Constructor Summary

AccessConstructor and Description
public
ImportFormatReader(ImporterPreferences importerPreferences, ImportFormatPreferences importFormatPreferences, CitationKeyPatternPreferences citationKeyPatternPreferences, FileUpdateMonitor fileUpdateMonitor)

Method Summary

Modifier and TypeMethod and Description
private Optional<Importer>

Returns:

Import Format or null if none matches
getByCliId
(String
CLI-Id
cliId
)

Format for a given CLI-ID.

Will return the first format according to the default-order of format that matches the given ID.

public SortedSet<Importer>

Returns:

all custom importers, elements are of type InputFormat
getImportFormats
()

All importers.

public ParserResult
importFromFile(String format, Path file)

public ImportFormatReader.UnknownFormatImport
importUnknownFormat(Path filePath, FileUpdateMonitor fileMonitor)

Tries to import a file by iterating through the available import filters, and keeping the import that seems most promising.

private ImportFormatReader.UnknownFormatImport

Returns:

an UnknownFormatImport with the imported entries and metadata
importUnknownFormat
(ImportFormatReader.CheckedFunction<Importer, ParserResult>
the function to import the entries with a formatter
importDatabase
,
ImportFormatReader.CheckedFunction<Importer, Boolean>
the function to check whether the source is in the correct format for an importer
isRecognizedFormat
)

Tries to import entries by iterating through the available import filters, and keeping the import that seems the most promising

public ImportFormatReader.UnknownFormatImport

Returns:

an UnknownFormatImport with the imported entries and metadata
importUnknownFormat
(String
the string to import
data
)

Tries to import a String by iterating through the available import filters, and keeping the import that seems the most promising

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BIBTEX_FORMATback to summary
public static final String BIBTEX_FORMAT
citationKeyPatternPreferencesback to summary
private final CitationKeyPatternPreferences citationKeyPatternPreferences
fileUpdateMonitorback to summary
private final FileUpdateMonitor fileUpdateMonitor
formatsback to summary
private final List<Importer> formats

All import formats. Sorted accordingly to Importer#compareTo, which defaults to alphabetically by the name

importerPreferencesback to summary
private final ImporterPreferences importerPreferences
importFormatPreferencesback to summary
private final ImportFormatPreferences importFormatPreferences

Constructor Detail

ImportFormatReaderback to summary
public ImportFormatReader(ImporterPreferences importerPreferences, ImportFormatPreferences importFormatPreferences, CitationKeyPatternPreferences citationKeyPatternPreferences, FileUpdateMonitor fileUpdateMonitor)

Method Detail

getByCliIdback to summary
private Optional<Importer> getByCliId(String cliId)

Format for a given CLI-ID.

Will return the first format according to the default-order of format that matches the given ID.

Parameters
cliId:String

CLI-Id

Returns:Optional<Importer>

Import Format or null if none matches

getImportFormatsback to summary
public SortedSet<Importer> getImportFormats()

All importers. Elements are sorted by name.

Returns:SortedSet<Importer>

all custom importers, elements are of type InputFormat

importFromFileback to summary
public ParserResult importFromFile(String format, Path file) throws ImportException
importUnknownFormatback to summary
public ImportFormatReader.UnknownFormatImport importUnknownFormat(Path filePath, FileUpdateMonitor fileMonitor) throws ImportException

Tries to import a file by iterating through the available import filters, and keeping the import that seems most promising.

This method first attempts to read this file as bibtex.

Exceptions
ImportException:
if the import fails (for example, if no suitable importer is found)
importUnknownFormatback to summary
private ImportFormatReader.UnknownFormatImport importUnknownFormat(ImportFormatReader.CheckedFunction<Importer, ParserResult> importDatabase, ImportFormatReader.CheckedFunction<Importer, Boolean> isRecognizedFormat) throws ImportException

Tries to import entries by iterating through the available import filters, and keeping the import that seems the most promising

Parameters
importDatabase:ImportFormatReader.CheckedFunction<Importer, ParserResult>

the function to import the entries with a formatter

isRecognizedFormat:ImportFormatReader.CheckedFunction<Importer, Boolean>

the function to check whether the source is in the correct format for an importer

Returns:ImportFormatReader.UnknownFormatImport

an UnknownFormatImport with the imported entries and metadata

Exceptions
ImportException:
if the import fails (for example, if no suitable importer is found)
importUnknownFormatback to summary
public ImportFormatReader.UnknownFormatImport importUnknownFormat(String data) throws ImportException

Tries to import a String by iterating through the available import filters, and keeping the import that seems the most promising

Parameters
data:String

the string to import

Returns:ImportFormatReader.UnknownFormatImport

an UnknownFormatImport with the imported entries and metadata

Exceptions
ImportException:
if the import fails (for example, if no suitable importer is found)
resetback to summary
public void reset()
org.jabref.logic.importer back to summary

public Interface ImportFormatReader.CheckedFunction<T, R>

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public R
apply(T t)

Method Detail

applyback to summary
public R apply(T t) throws IOException
org.jabref.logic.importer back to summary

public final Record ImportFormatReader.UnknownFormatImport

extends Record
Class Inheritance
Record Components
format:String 
parserResult:ParserResult 

Field Summary

Modifier and TypeField and Description
private final String
format

Record Component accessed by format().

private final ParserResult
parserResult

Record Component accessed by parserResult().

Constructor Summary

AccessConstructor and Description
public
UnknownFormatImport(String format, ParserResult parserResult)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public String
format()

Record Component getter of format.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public ParserResult
parserResult()

Record Component getter of parserResult.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

formatback to summary
private final String format

Record Component accessed by format().

parserResultback to summary
private final ParserResult parserResult

Record Component accessed by parserResult().

Constructor Detail

UnknownFormatImportback to summary
public UnknownFormatImport(String format, ParserResult parserResult)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

formatback to summary
public String format()

Record Component getter of format.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

parserResultback to summary
public ParserResult parserResult()

Record Component getter of parserResult.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.