Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.importer.fileformat

public Class CustomImporter

extends Importer
Class Inheritance
Imports
java.io.BufferedReader, .IOException, java.net.URL, .URLClassLoader, java.nio.file.Path, java.util.Arrays, .List, .Objects, org.jabref.logic.importer.ImportException, .Importer, .ParserResult, org.jabref.logic.util.FileType, org.jspecify.annotations.NonNull

Object with data for a custom importer.

Is also responsible for instantiating the class loader.

Field Summary

Modifier and TypeField and Description
private final Path
private final String
private final Importer

Constructor Summary

AccessConstructor and Description
public
CustomImporter(String basePath, String className)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object other)

Overrides org.jabref.logic.importer.Importer.equals.

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

public List<String>
public Path
public String
public String
getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

public FileType
getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

public String
getId()

Implements abstract org.jabref.logic.importer.Importer.getId.

Returns a slug, which identifies this importer.

public String
getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

Returns the name of this import format.

public int
hashCode()

Overrides org.jabref.logic.importer.Importer.hashCode.

Returns a hash code value for this object.

public ParserResult
importDatabase(@NonNull BufferedReader input)

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

public boolean
isRecognizedFormat(@NonNull BufferedReader input)

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

private static Importer
load(URL basePathURL, String className)

public String
toString()

Overrides org.jabref.logic.importer.Importer.toString.

Returns a string representation of the object.

Inherited from org.jabref.logic.importer.Importer:
compareTogetCharsetgetReadergetReaderimportDatabaseimportDatabaseisRecognizedFormatisRecognizedFormatisRecognizedFormatsupportsFileExtension

Field Detail

basePathback to summary
private final Path basePath
classNameback to summary
private final String className
importerback to summary
private final Importer importer

Constructor Detail

CustomImporterback to summary
public CustomImporter(String basePath, String className) throws ImportException

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides org.jabref.logic.importer.Importer.equals.

Doc from java.lang.Object.equals.

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

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getAsStringListback to summary
public List<String> getAsStringList()
getBasePathback to summary
public Path getBasePath()
getClassNameback to summary
public String getClassName()
getDescriptionback to summary
public String getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Doc from org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

The description should specify
what kind of entries from what sources and based on what specification it is able to import

by what criteria it isRecognizedFormat(BufferedReader) recognizes an import format

Annotations
@Override
getFileTypeback to summary
public FileType getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Doc from org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

Annotations
@Override
getIdback to summary
public String getId()

Implements abstract org.jabref.logic.importer.Importer.getId.

Doc from org.jabref.logic.importer.Importer.getId.

Returns a slug, which identifies this importer. Used, for example, to identify the importer in CLI.

Typically, this name should be short, in English, and should not contain special characters like #, %, etc.

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

Doc from org.jabref.logic.importer.Importer.getName.

Returns the name of this import format. Typically, this is a string that denotes file type or format. It can also be localized, like "XMP-annotated PDF".

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides org.jabref.logic.importer.Importer.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(@NonNull BufferedReader input) throws IOException

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

This method can be called in two different contexts - either when importing in a specified format, or when importing in unknown format. In the latter case, JabRef cycles through all available import formats. No error messages or feedback is displayed from individual import formats in this case.

If importing in a specified format and an empty library is returned, JabRef reports that no entries were found.

If your format is binary-based (PDF, ZIP-based, or others), then you should not solely override this method. For binary formats do this:

  1. Throw UnsupportedOperationException in this method.
  2. Override the method Importer#importDatabase(Path). Example of this workaround is in: org.jabref.logic.importer.fileformat.pdf.PdfImporter.
Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(@NonNull BufferedReader input) throws IOException

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

All implementations need to reset the input stream to the beginning again - to enable importing at subsequent calls.

The effect of this method is primarily to avoid unnecessary processing of files when searching for a suitable import format. If this method returns false, the import routine will move on to the next import format.

Thus, the correct behavior is to return false if it is certain that the file is not of the suitable type, and true otherwise. Returning true is the safe choice if not certain.

Annotations
@Override
loadback to summary
private static Importer load(URL basePathURL, String className) throws IOException, ReflectiveOperationException
toStringback to summary
public String toString()

Overrides org.jabref.logic.importer.Importer.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override