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

public Class CSLAdapter

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.Arrays, .List, .Objects, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, .BibEntryTypesManager, de.undercouch.citeproc.CSL, de.undercouch.citeproc.DefaultAbbreviationProvider, de.undercouch.citeproc.output.Bibliography

Provides an adapter class to CSL. It holds a CSL instance under the hood that is only recreated when the style changes. Note on the API: The first call to makeBibliography is expensive since the CSL instance will be created. As long as the style stays the same, we can reuse this instance. On style-change, the engine is re-instantiated. Therefore, the use-case of this class is many calls to makeBibliography with the same style. Changing the output format is cheap. Note on the implementation: The main function makeBibliography will enforce synchronized calling. The main CSL engine under the hood is not thread-safe. Since this class is usually called from a BackgroundTask, the only other option would be to create several CSL instances which is wasting a lot of resources and very slow. In the current scheme, makeBibliography can be called as usual background task and to the best of my knowledge, concurrent calls will pile up and processed sequentially.

Field Summary

Modifier and TypeField and Description
private de.undercouch.citeproc.CSL
private final JabRefItemDataProvider
private CitationStyleOutputFormat
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
initialize(String
journal style of the output
newStyle
,
CitationStyleOutputFormat
usually HTML or RTF.
newFormat
)

Initialized the static CSL instance if needed.

public synchronized List<String>
makeBibliography(List<BibEntry> bibEntries, String style, CitationStyleOutputFormat outputFormat, BibDatabaseContext
BibDatabaseContext is used to be able to resolve fields and their aliases
databaseContext
,
BibEntryTypesManager entryTypesManager)

Creates the bibliography of the provided items.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cslInstanceback to summary
private de.undercouch.citeproc.CSL cslInstance
dataProviderback to summary
private final JabRefItemDataProvider dataProvider
formatback to summary
private CitationStyleOutputFormat format
styleback to summary
private String style

Constructor Detail

CSLAdapterback to summary
public CSLAdapter()

Method Detail

initializeback to summary
private void initialize(String newStyle, CitationStyleOutputFormat newFormat) throws IOException

Initialized the static CSL instance if needed.

Parameters
newStyle:String

journal style of the output

newFormat:CitationStyleOutputFormat

usually HTML or RTF.

Exceptions
IOException:
An error occurred in the underlying JavaScript framework
makeBibliographyback to summary
public synchronized List<String> makeBibliography(List<BibEntry> bibEntries, String style, CitationStyleOutputFormat outputFormat, BibDatabaseContext databaseContext, BibEntryTypesManager entryTypesManager) throws IOException, IllegalArgumentException

Creates the bibliography of the provided items. This method needs to run synchronized because the underlying CSL engine is not thread-safe.

Parameters
databaseContext:BibDatabaseContext

BibDatabaseContext is used to be able to resolve fields and their aliases