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

public Class BibliographyFromPdfImporter

extends Importer
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .StringWriter, java.nio.file.Path, java.util.ArrayList, .Iterator, .List, .Objects, .Optional, java.util.regex.Matcher, .Pattern, org.jabref.logic.citationkeypattern.CitationKeyGenerator, .CitationKeyPatternPreferences, org.jabref.logic.importer.Importer, .ParserResult, org.jabref.logic.l10n.Localization, org.jabref.logic.util.FileType, .StandardFileType, org.jabref.logic.xmp.EncryptedPdfsNotSupportedException, .XmpUtilReader, org.jabref.model.entry.AuthorList, .BibEntry, .Date, org.jabref.model.entry.field.Field, .StandardField, org.jabref.model.entry.types.StandardEntryType, com.google.common.annotations.VisibleForTesting, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.text.PDFTextStripper, org.slf4j.Logger, .LoggerFactory

Parses the references from the "References" section from a PDF

Currently, IEEE two column format is supported.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private static final Pattern
private final CitationKeyPatternPreferences
private static final Logger
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getDescription()

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

Returns the description of the import format.

private List<BibEntry>
getEntriesFromPDFContent(String contents)

In: "[1] ...\n...\n...[2]...\n...\n...\n[3]..." Out: List<String> = ["[1] ...", "[2]...", "[3]..."]

public FileType
getFileType()

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

Returns the type of files that this importer can read

private String
getLastPageContents(org.apache.pdfbox.pdmodel.PDDocument document)

public String
getName()

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

Returns the name of this import format.

public ParserResult
importDatabase(BufferedReader
the input to read from
reader
)

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

Parse the database in the source.

public ParserResult
importDatabase(Path
the path to the file which should be imported
filePath
)

Overrides org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the specified file.

public boolean
isRecognizedFormat(BufferedReader input)

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

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

pack-priv BibEntry
parseReference(String
The number of the reference - used for logging only
number
,
String reference)

Example: J.

private static String
updateEntryAndReferenceIfMatches(String reference, Pattern
A pattern matching two groups: The first one to take, the second one to leave at the end of the string
pattern
,
BibEntry result, Field field)

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

Field Detail

AUTHORS_AND_TITLE_AT_BEGINNINGback to summary
private static final Pattern AUTHORS_AND_TITLE_AT_BEGINNING
citationKeyPatternPreferencesback to summary
private final CitationKeyPatternPreferences citationKeyPatternPreferences
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.logic.importer.Importer.LOGGER.

MONTH_AND_YEARback to summary
private static final Pattern MONTH_AND_YEAR
MONTH_RANGE_AND_YEARback to summary
private static final Pattern MONTH_RANGE_AND_YEAR
NOback to summary
private static final Pattern NO
PAGEback to summary
private static final Pattern PAGE
PAGESback to summary
private static final Pattern PAGES
REFERENCE_PATTERNback to summary
private static final Pattern REFERENCE_PATTERN
TITLEback to summary
private static final Pattern TITLE
VOLUMEback to summary
private static final Pattern VOLUME
YEAR_AT_ENDback to summary
private static final Pattern YEAR_AT_END

Constructor Detail

BibliographyFromPdfImporterback to summary
public BibliographyFromPdfImporter(CitationKeyPatternPreferences citationKeyPatternPreferences)

Method Detail

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 recognizes an import format
Returns:String

description of the import format

Annotations
@Override
getEntriesFromPDFContentback to summary
private List<BibEntry> getEntriesFromPDFContent(String contents)

In: "[1] ...\n...\n...[2]...\n...\n...\n[3]..."
Out: List<String> = ["[1] ...", "[2]...", "[3]..."]

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

Returns:FileType

FileType corresponding to the importer

Annotations
@Override
getLastPageContentsback to summary
private String getLastPageContents(org.apache.pdfbox.pdmodel.PDDocument document) throws IOException
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.

The name must be unique.

Returns:String

format name, must be unique and not null

Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(BufferedReader reader) 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.

This method should never return null.

Parameters
reader:BufferedReader

the input to read from

Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(Path filePath)

Overrides org.jabref.logic.importer.Importer.importDatabase.

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

Parse the database in the specified file.

Parameters
filePath:Path

the path to the file which should be imported

Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(BufferedReader input) throws IOException

Implements abstract 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.

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 behaviour 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
parseReferenceback to summary
pack-priv BibEntry parseReference(String number, String reference)

Example: J. Knaster et al., “Overview of the IFMIF/EVEDA project”, Nucl. Fusion, vol. 57, p. 102016, 2017. doi:10.1088/ 1741-4326/aa6a6a

Parameters
number:String

The number of the reference - used for logging only

Annotations
@VisibleForTesting
updateEntryAndReferenceIfMatchesback to summary
private static String updateEntryAndReferenceIfMatches(String reference, Pattern pattern, BibEntry result, Field field)
Parameters
pattern:Pattern

A pattern matching two groups: The first one to take, the second one to leave at the end of the string

org.jabref.logic.importer.fileformat back to summary

private final Record BibliographyFromPdfImporter.IntermediateData

extends Record
Class Inheritance
Record Components
number:String 
reference:String 

Field Summary

Modifier and TypeField and Description
private final String
number

Record Component accessed by number().

private final String
reference

Record Component accessed by reference().

Constructor Summary

AccessConstructor and Description
private
IntermediateData(String number, String reference)

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 final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
number()

Record Component getter of number.

public String
reference()

Record Component getter of reference.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

numberback to summary
private final String number

Record Component accessed by number().

referenceback to summary
private final String reference

Record Component accessed by reference().

Constructor Detail

IntermediateDataback to summary
private IntermediateData(String number, String reference)

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.

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.

numberback to summary
public String number()

Record Component getter of number.

referenceback to summary
public String reference()

Record Component getter of reference.

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.