Top Description Fields Constructors Methods
org.jabref.logic.pdf.search

public final Class DocumentReader

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.file.Files, .Path, java.nio.file.attribute.BasicFileAttributes, java.util.ArrayList, .List, .Optional, java.util.concurrent.TimeUnit, java.util.regex.Pattern, java.util.stream.Collectors, org.jabref.gui.LibraryTab, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, .LinkedFile, org.jabref.model.strings.StringUtil, org.jabref.preferences.FilePreferences, org.apache.lucene.document.Document, org.apache.lucene.document.Field, org.apache.lucene.document.StringField, org.apache.lucene.document.TextField, org.apache.pdfbox.Loader, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.PDPage, org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation, org.apache.pdfbox.text.PDFTextStripper, org.slf4j.Logger, .LoggerFactory

Utility class for reading the data from LinkedFiles of a BibEntry for Lucene.

Field Summary

Modifier and TypeField and Description
private final BibEntry
private final FilePreferences
private static final Pattern
private static final Pattern
private static final Logger

Constructor Summary

AccessConstructor and Description
public
DocumentReader(BibEntry
Must not be null and must have at least one LinkedFile.
bibEntry
,
FilePreferences filePreferences)

Creates a new DocumentReader using a BibEntry.

Method Summary

Modifier and TypeMethod and Description
private void
addContentIfNotEmpty(org.apache.pdfbox.pdmodel.PDDocument pdfDocument, org.apache.lucene.document.Document newDocument, int pageNumber)

private void
addIdentifiers(org.apache.lucene.document.Document newDocument, String path)

private void
addMetaData(org.apache.lucene.document.Document newDocument, Path resolvedPdfPath, int pageNumber)

private void
addStringField(org.apache.lucene.document.Document newDocument, String field, String value)

private boolean
public static String
public Optional<List<org.apache.lucene.document.Document>>

Returns:

An Optional of a Lucene Document with the (meta)data. Can be empty if there is a problem reading the LinkedFile.
readLinkedPdf
(BibDatabaseContext databaseContext, LinkedFile pdf)

Reads a LinkedFile of a BibEntry and converts it into a Lucene Document which is then returned.

public List<org.apache.lucene.document.Document>

Returns:

A List of Documents with the (meta)data. Can be empty if there is a problem reading the LinkedFile.
readLinkedPdfs
(BibDatabaseContext databaseContext)

Reads each LinkedFile of a BibEntry and converts them into Lucene Documents which are then returned.

private List<org.apache.lucene.document.Document>
readPdfContents(LinkedFile pdf, Path resolvedPdfPath)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entryback to summary
private final BibEntry entry
filePreferencesback to summary
private final FilePreferences filePreferences
HYPHEN_LINEBREAK_PATTERNback to summary
private static final Pattern HYPHEN_LINEBREAK_PATTERN
LINEBREAK_WITHOUT_PERIOD_PATTERNback to summary
private static final Pattern LINEBREAK_WITHOUT_PERIOD_PATTERN
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

DocumentReaderback to summary
public DocumentReader(BibEntry bibEntry, FilePreferences filePreferences)

Creates a new DocumentReader using a BibEntry.

Parameters
bibEntry:BibEntry

Must not be null and must have at least one LinkedFile.

Method Detail

addContentIfNotEmptyback to summary
private void addContentIfNotEmpty(org.apache.pdfbox.pdmodel.PDDocument pdfDocument, org.apache.lucene.document.Document newDocument, int pageNumber) throws IOException
addIdentifiersback to summary
private void addIdentifiers(org.apache.lucene.document.Document newDocument, String path)
addMetaDataback to summary
private void addMetaData(org.apache.lucene.document.Document newDocument, Path resolvedPdfPath, int pageNumber)
addStringFieldback to summary
private void addStringField(org.apache.lucene.document.Document newDocument, String field, String value)
isValidFieldback to summary
private boolean isValidField(String value)
mergeLinesback to summary
public static String mergeLines(String text)
readLinkedPdfback to summary
public Optional<List<org.apache.lucene.document.Document>> readLinkedPdf(BibDatabaseContext databaseContext, LinkedFile pdf)

Reads a LinkedFile of a BibEntry and converts it into a Lucene Document which is then returned.

Returns:Optional<List<org.apache.lucene.document.Document>>

An Optional of a Lucene Document with the (meta)data. Can be empty if there is a problem reading the LinkedFile.

readLinkedPdfsback to summary
public List<org.apache.lucene.document.Document> readLinkedPdfs(BibDatabaseContext databaseContext)

Reads each LinkedFile of a BibEntry and converts them into Lucene Documents which are then returned.

Returns:List<org.apache.lucene.document.Document>

A List of Documents with the (meta)data. Can be empty if there is a problem reading the LinkedFile.

readPdfContentsback to summary
private List<org.apache.lucene.document.Document> readPdfContents(LinkedFile pdf, Path resolvedPdfPath)