Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.layout.format

public Class NameFormatter

extends Object
implements LayoutFormatter
Class Inheritance
All Implemented Interfaces
org.jabref.logic.layout.LayoutFormatter
Imports
java.util.HashMap, .List, .Map, org.jabref.logic.bst.util.BstNameFormatter, org.jabref.logic.layout.LayoutFormatter, org.jabref.model.entry.AuthorList, org.jspecify.annotations.NonNull

This layout formatter uses the BibTeX name.format$ method and provides ultimate flexibility.

The formatter needs a parameter with the following format:

<case1>@<range11>@"<format>"@<range12>@"<format>"@<range13>...@@ <case2>@<range21>@...
<case1>@<range11>@"<format>"@<range12>@"<format>"@<range13>...@@
<case2>@<range21>@...

Individual cases are separated by @@ and items in a case by @.

Cases are just integers or the character * and tell the formatter to apply the following formats if there are less or equal authors given. The cases must be in strictly increasing order with * in the last position.

Example:

Ranges are either <integer>..<integer>, <integer> or * (using a 1-based index). Negative integers start from the end (-1 = last author).

Example with Joe Doe and Mary Jane and Bruce Bar and Arthur Kay:

The <format> uses the BibTeX formatter syntax:

Example:

Complete example:

Input:

Joe Doe and Mary Jane and Bruce Bar and Arthur Kay
Joe Doe and Mary Jane and Bruce Bar and Arthur Kay

Output:

Doe, J., Jane, M., Bar, B. and Kay, A.
Doe, J., Jane, M., Bar, B. and Kay, A.

Formatter parameter:

1@*@{ll},{f}.@@2@1@{ll},{f}.@2@ and {ll},{f}.@@*@1..-3@{ll},{f}., @-2@{ll},{f}.@-1@ and {ll},{f}.
1@*@{ll},{f}.@@2@1@{ll},{f}.@2@ and {ll},{f}.@@*@1..-3@{ll},{f}., @-2@{ll},{f}.@-1@ and {ll},{f}.

This is troublesome to write, but it works. For more examples see the test cases.

Field Summary

Modifier and TypeField and Description
public static final String
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
format(String toFormat, AuthorList al, String[] formats)

public String
format(String toFormat, String inParameters)

public String
format(String fieldText)

Implements org.jabref.logic.layout.LayoutFormatter.format.

Failure Mode:

Formatters should be robust in the sense that they always return some relevant string.

public static Map<String, String>
public void
setParameter(String parameter)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FORMATback to summary
public static final String DEFAULT_FORMAT
parameterback to summary
private String parameter

Constructor Detail

NameFormatterback to summary
public NameFormatter()

Method Detail

formatback to summary
private static String format(String toFormat, AuthorList al, String[] formats)
formatback to summary
public String format(String toFormat, String inParameters)
formatback to summary
public String format(String fieldText)

Implements org.jabref.logic.layout.LayoutFormatter.format.

Doc from org.jabref.logic.layout.LayoutFormatter.format.

Failure Mode:

Formatters should be robust in the sense that they always return some relevant string.

If the formatter can detect an invalid input it should return the original string otherwise it may simply return a wrong output.

Annotations
@Override
getNameFormattersback to summary
public static Map<String, String> getNameFormatters(@NonNull NameFormatterPreferences preferences)
setParameterback to summary
public void setParameter(String parameter)