Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.bibtex

public Class BibEntryWriter

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

Parsing is done at org.jabref.logic.importer.fileformat.BibtexParser

Field Summary

Modifier and TypeField and Description
private final BibEntryTypesManager
private final Map<Field, Range>
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
public Map<Field, Range>
pack-priv static String

Returns:

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

Get serializable version of field name with trailing spaces and the equal sign.

pack-priv static int
public String
write(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
writeEntryType(BibEntry entry, BibWriter out, BibDatabaseMode bibDatabaseMode)

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
fieldPositionsback to summary
private final Map<Field, Range> fieldPositions
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

getFieldPositionsback to summary
public Map<Field, Range> getFieldPositions()
getFormattedFieldNameback to summary
pack-priv static String getFormattedFieldName(Field field, int indent)

Get serializable version of field name with trailing spaces and the equal sign.

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)
writeback to summary
public String write(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?

writeEntryTypeback to summary
private void writeEntryType(BibEntry entry, BibWriter out, BibDatabaseMode bibDatabaseMode) throws IOException
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