Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.formatter.bibtexfields

public Class NormalizeWhitespaceFormatter

extends Object
Class Inheritance
Imports
java.util.regex.Pattern, org.jabref.logic.bibtex.FieldPreferences, org.jabref.model.entry.field.Field, .FieldFactory, org.jspecify.annotations.NonNull

Replaces two subsequent whitespaces (and tabs) to one space in case of single-line fields. In case of multine fields, the field content is kept as is.

Due to the distinction between single line and multiline fields, this formatter does not implement the interface org.jabref.logic.formatter.Formatter.

Field Summary

Modifier and TypeField and Description
private final FieldPreferences
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the formatted field content.
format
(String
the content to format.
fieldContent
,
Field
the name of the bibtex field
field
)

Performs the reformatting of a field content.

public String

Returns:

the formatted field content.
format
(StringBuilder
the content to format.
fieldContent
,
Field
the name of the bibtex field
field
)

Performs the reformatting of a field content.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

preferencesback to summary
private final FieldPreferences preferences
WHITESPACEback to summary
private static final Pattern WHITESPACE

Constructor Detail

NormalizeWhitespaceFormatterback to summary
public NormalizeWhitespaceFormatter(@NonNull FieldPreferences preferences)

Method Detail

formatback to summary
public String format(String fieldContent, Field field)

Performs the reformatting of a field content. Note that "field content" is either with enclosing {}. When outputting something which is using strings, the parts of the plain string are passed (without enclosing {}). For instance, for #kopp# and #breit#", and is passed. Also depends on the caller whether strings have been resolved.

Parameters
fieldContent:String

the content to format.

field:Field

the name of the bibtex field

Returns:String

the formatted field content.

formatback to summary
public String format(StringBuilder fieldContent, Field field)

Performs the reformatting of a field content. Note that "field content" is understood as the value in BibTeX's key/value pairs of content. For instance, {author} is passed as content. This allows for things like jan { - } feb to be passed.

Parameters
fieldContent:StringBuilder

the content to format.

field:Field

the name of the bibtex field

Returns:String

the formatted field content.