Top Description Fields Constructors Methods
org.jabref.logic.exporter

public Class TemplateExporter

extends Exporter
Class Inheritance
Imports
java.io.FileNotFoundException, .IOException, .Reader, java.net.URISyntaxException, .URL, java.nio.charset.Charset, .StandardCharsets, java.nio.file.Files, .Path, java.util.ArrayList, .Collections, .HashMap, .List, .Map, .Objects, org.jabref.logic.journals.JournalAbbreviationLoader, .JournalAbbreviationRepository, org.jabref.logic.layout.Layout, .LayoutFormatterPreferences, .LayoutHelper, org.jabref.logic.layout.format.Number, org.jabref.logic.util.FileType, .OS, .StandardFileType, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, org.jabref.model.entry.types.EntryType, org.jabref.model.metadata.SaveOrder, .SelfContainedSaveOrder, org.slf4j.Logger, .LoggerFactory

Base class for export formats based on templates.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private BlankLineBehaviour
private boolean
private final String
private static final String
private static final String
private static final String
private static final String
private final LayoutFormatterPreferences
private final String
private static final Logger
private final SelfContainedSaveOrder

Constructor Summary

AccessConstructor and Description
public
TemplateExporter(String
Name to display to the user.
displayName
,
String
Name to call this format in the console.
consoleName
,
String
Name of the main layout file.
lfFileName
,
String
Directory in which to find the layout file.
directory
,
FileType
Should contain the . (for instance .txt).
extension
)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

public
TemplateExporter(String
to display to the user and to call this format in the console.
name
,
String
Name of the main layout file.
lfFileName
,
String
May or may not contain the . (for instance .txt).
extension
,
LayoutFormatterPreferences layoutPreferences, SelfContainedSaveOrder saveOrder)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

public
TemplateExporter(String
Name to display to the user.
displayName
,
String
Name to call this format in the console.
consoleName
,
String
Name of the main layout file.
lfFileName
,
String
Directory in which to find the layout file.
directory
,
FileType
Should contain the . (for instance .txt).
extension
,
LayoutFormatterPreferences layoutPreferences, SelfContainedSaveOrder saveOrder)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

public
TemplateExporter(String
Name to display to the user.
displayName
,
String
Name to call this format in the console.
consoleName
,
String
Name of the main layout file.
lfFileName
,
String
Directory in which to find the layout file.
directory
,
FileType
Should contain the . (for instance .txt).
extension
,
LayoutFormatterPreferences
Preferences for layout
layoutPreferences
,
SelfContainedSaveOrder saveOrder, BlankLineBehaviour
how to behave regarding blank lines.
blankLineBehaviour
)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

Method Summary

Modifier and TypeMethod and Description
public void
export(BibDatabaseContext
the database to export from
databaseContext
,
Path
the file to write to
file
,
List<BibEntry>
a list containing all entries that should be exported
entries
)

Implements abstract org.jabref.logic.exporter.Exporter.export.

Performs the export.

public void
export(final BibDatabaseContext databaseContext, final Path file, List<BibEntry> entries, List<Path> fileDirForDatabase, JournalAbbreviationRepository abbreviationRepository)

Overrides org.jabref.logic.exporter.Exporter.export.

public String
public String
private Reader

Returns:

a newly created reader
getReader
(String
the filename
filename
)

This method should return a reader from which the given layout file can be read.

private void
readFormatterFile()

See if there is a name formatter file bundled with this export format.

public void
setCustomExport(boolean
true to indicate a custom export format.
custom
)

Indicate whether this is a custom export.

Inherited from org.jabref.logic.exporter.Exporter:
exportToAllFilesOfEntryexportToFileByPathgetFileTypegetIdgetNametoString

Field Detail

BEGIN_INFIXback to summary
private static final String BEGIN_INFIX
BLANK_LINE_PATTERNback to summary
private static final String BLANK_LINE_PATTERN
blankLineBehaviourback to summary
private BlankLineBehaviour blankLineBehaviour
customExportback to summary
private boolean customExport
directoryback to summary
private final String directory
END_INFIXback to summary
private static final String END_INFIX
FORMATTERS_EXTENSIONback to summary
private static final String FORMATTERS_EXTENSION
LAYOUT_EXTENSIONback to summary
private static final String LAYOUT_EXTENSION
LAYOUT_PREFIXback to summary
private static final String LAYOUT_PREFIX
layoutPreferencesback to summary
private final LayoutFormatterPreferences layoutPreferences
lfFileNameback to summary
private final String lfFileName
LOGGERback to summary
private static final Logger LOGGER
saveOrderback to summary
private final SelfContainedSaveOrder saveOrder

Constructor Detail

TemplateExporterback to summary
public TemplateExporter(String displayName, String consoleName, String lfFileName, String directory, FileType extension)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

Parameters
displayName:String

Name to display to the user.

consoleName:String

Name to call this format in the console.

lfFileName:String

Name of the main layout file.

directory:String

Directory in which to find the layout file.

extension:FileType

Should contain the . (for instance .txt).

TemplateExporterback to summary
public TemplateExporter(String name, String lfFileName, String extension, LayoutFormatterPreferences layoutPreferences, SelfContainedSaveOrder saveOrder)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

Parameters
name:String

to display to the user and to call this format in the console.

lfFileName:String

Name of the main layout file.

extension:String

May or may not contain the . (for instance .txt).

TemplateExporterback to summary
public TemplateExporter(String displayName, String consoleName, String lfFileName, String directory, FileType extension, LayoutFormatterPreferences layoutPreferences, SelfContainedSaveOrder saveOrder)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

Parameters
displayName:String

Name to display to the user.

consoleName:String

Name to call this format in the console.

lfFileName:String

Name of the main layout file.

directory:String

Directory in which to find the layout file.

extension:FileType

Should contain the . (for instance .txt).

TemplateExporterback to summary
public TemplateExporter(String displayName, String consoleName, String lfFileName, String directory, FileType extension, LayoutFormatterPreferences layoutPreferences, SelfContainedSaveOrder saveOrder, BlankLineBehaviour blankLineBehaviour)

Initialize another export format based on templates stored in dir with layoutFile lfFilename.

Parameters
displayName:String

Name to display to the user.

consoleName:String

Name to call this format in the console.

lfFileName:String

Name of the main layout file.

directory:String

Directory in which to find the layout file.

extension:FileType

Should contain the . (for instance .txt).

layoutPreferences:LayoutFormatterPreferences

Preferences for layout

blankLineBehaviour:BlankLineBehaviour

how to behave regarding blank lines.

Method Detail

exportback to summary
public void export(BibDatabaseContext databaseContext, Path file, List<BibEntry> entries) throws Exception

Implements abstract org.jabref.logic.exporter.Exporter.export.

Doc from org.jabref.logic.exporter.Exporter.export.

Performs the export.

Parameters
databaseContext:BibDatabaseContext

the database to export from

file:Path

the file to write to

entries:List<BibEntry>

a list containing all entries that should be exported

Annotations
@Override
exportback to summary
public void export(final BibDatabaseContext databaseContext, final Path file, List<BibEntry> entries, List<Path> fileDirForDatabase, JournalAbbreviationRepository abbreviationRepository) throws Exception

Overrides org.jabref.logic.exporter.Exporter.export.

Annotations
@Override
getLayoutFileNameback to summary
public String getLayoutFileName()
getLayoutFileNameWithExtensionback to summary
public String getLayoutFileNameWithExtension()
getReaderback to summary
private Reader getReader(String filename) throws IOException

This method should return a reader from which the given layout file can be read.

Subclasses of TemplateExporter are free to override and provide their own implementation.

Parameters
filename:String

the filename

Returns:Reader

a newly created reader

Exceptions
IOException:
if the reader could not be created
readFormatterFileback to summary
private void readFormatterFile()

See if there is a name formatter file bundled with this export format. If so, read all the name formatters so they can be used by the filter layouts.

setCustomExportback to summary
public void setCustomExport(boolean custom)

Indicate whether this is a custom export. A custom export looks for its layout files using a normal file path, while a built-in export looks in the classpath.

Parameters
custom:boolean

true to indicate a custom export format.