Top Fields Constructors Methods
org.jabref.logic.bibtex

public Class BibEntryWriter

extends Object
Class Inheritance
Imports
java.io.IOException, .StringWriter, java.util.Collection, .Comparator, .HashSet, .List, .Locale, .Optional, .Set, .SortedSet, .TreeSet, java.util.function.Predicate, java.util.stream.Collectors, org.jabref.logic.exporter.BibWriter, org.jabref.logic.util.OS, org.jabref.model.database.BibDatabaseMode, org.jabref.model.entry.BibEntry, .BibEntryType, .BibEntryTypesManager, org.jabref.model.entry.field.BibField, .Field, .InternalField, .OrFields, org.jabref.model.strings.StringUtil, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private final BibEntryTypesManager
private final FieldWriter
private static final Logger

Constructor Summary

AccessConstructor and Description
public
BibEntryWriter(FieldWriter fieldWriter, BibEntryTypesManager entryTypesManager)

Method Summary

Modifier and TypeMethod and Description
pack-priv static String

Returns:

The display version of the field name.
getFormattedFieldName
(Field
The name of the field.
field
,
int indent)

Get display version of an entry field.

pack-priv static int
public String
serializeAll(List<BibEntry> entries, BibDatabaseMode databaseMode)

public void
write(BibEntry entry, BibWriter out, BibDatabaseMode bibDatabaseMode)

public void
write(BibEntry
The entry to write
entry
,
BibWriter
The writer to use
out
,
BibDatabaseMode
The database mode (bibtex or biblatex)
bibDatabaseMode
,
Boolean
Should the entry be in any case, even if no change occurred?
reformat
)

Writes the given BibEntry using the given writer

private void
writeField(BibEntry
the entry to write
entry
,
BibWriter
the target of the write
out
,
Field
the field
field
,
int indent)

Write a single field, if it has any content.

private void
private void
writeRequiredFieldsFirstRemainingFieldsSecond(BibEntry entry, BibWriter out, BibDatabaseMode bibDatabaseMode)

Writes fields in the order of requiredFields, optionalFields and other fields, but does not sort the fields.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entryTypesManagerback to summary
private final BibEntryTypesManager entryTypesManager
fieldWriterback to summary
private final FieldWriter fieldWriter
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

BibEntryWriterback to summary
public BibEntryWriter(FieldWriter fieldWriter, BibEntryTypesManager entryTypesManager)

Method Detail

getFormattedFieldNameback to summary
pack-priv static String getFormattedFieldName(Field field, int indent)

Get display version of an entry field.

BibTeX is case-insensitive therefore there is no difference between: howpublished, HOWPUBLISHED, HowPublished, etc.

There was a long discussion about how JabRef should write the fields. See https://github.com/JabRef/jabref/issues/116

The team decided to do the biblatex way and use lower case for the field names.

Parameters
field:Field

The name of the field.

Returns:String

The display version of the field name.

getLengthOfLongestFieldNameback to summary
pack-priv static int getLengthOfLongestFieldName(BibEntry entry)
serializeAllback to summary
public String serializeAll(List<BibEntry> entries, BibDatabaseMode databaseMode) throws IOException
writeback to summary
public void write(BibEntry entry, BibWriter out, BibDatabaseMode bibDatabaseMode) throws IOException
writeback to summary
public void write(BibEntry entry, BibWriter out, BibDatabaseMode bibDatabaseMode, Boolean reformat) throws IOException

Writes the given BibEntry using the given writer

Parameters
entry:BibEntry

The entry to write

out:BibWriter

The writer to use

bibDatabaseMode:BibDatabaseMode

The database mode (bibtex or biblatex)

reformat:Boolean

Should the entry be in any case, even if no change occurred?

writeFieldback to summary
private void writeField(BibEntry entry, BibWriter out, Field field, int indent) throws IOException

Write a single field, if it has any content.

Parameters
entry:BibEntry

the entry to write

out:BibWriter

the target of the write

field:Field

the field

Exceptions
IOException:
In case of an IO error
writeKeyFieldback to summary
private void writeKeyField(BibEntry entry, BibWriter out) throws IOException
writeRequiredFieldsFirstRemainingFieldsSecondback to summary
private void writeRequiredFieldsFirstRemainingFieldsSecond(BibEntry entry, BibWriter out, BibDatabaseMode bibDatabaseMode) throws IOException

Writes fields in the order of requiredFields, optionalFields and other fields, but does not sort the fields.

writeUserCommentsback to summary
private void writeUserComments(BibEntry entry, BibWriter out) throws IOException