Top Inners Fields Constructors Methods
org.jabref.logic.openoffice.style

pack-priv Class OOBibStyleGetCitationMarker

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .List, .Optional, org.jabref.logic.formatter.bibtexfields.RemoveEnclosingBracesFormatter, org.jabref.model.database.BibDatabase, org.jabref.model.entry.Author, .AuthorList, .BibEntry, org.jabref.model.entry.field.Field, .OrFields, org.jabref.model.openoffice.ootext.OOText, org.jabref.model.openoffice.style.CitationLookupResult, .CitationMarkerEntry, .CitationMarkerNormEntry, .NonUniqueCitationMarker, .PageInfo, org.jabref.model.strings.StringUtil, org.jspecify.annotations.NonNull

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
private static class
OOBibStyleGetCitationMarker.CitationMarkerNormEntryWrap

Add / override methods for the purpose of creating a normalized citation marker.

private static class
OOBibStyleGetCitationMarker.FieldAndContent

On success, getRawCitationMarkerField returns content, but we also need to know which field matched, because for some fields (actually: for author names) we need to reproduce the surrounding braces to inform AuthorList.parse not to split up the content.

Field Summary

Modifier and TypeField and Description
private static final RemoveEnclosingBracesFormatter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static int
calculateNAuthorsToEmit(OOBibStyle style, CitationMarkerEntry entry)

How many authors would be emitted for entry, considering style and entry.getIsFirstAppearanceOfSource() If entry is unresolved, return 0.

public static OOText
createCitationMarker(OOBibStyle style, List<CitationMarkerEntry>
A group of citations to process.
citationMarkerEntries
,
boolean
If true, put parenthesis around the whole group, otherwise around each (year,uniqueLetter,pageInfo) part.
inParenthesis
,
NonUniqueCitationMarker
What should happen if we stumble upon citations with identical normalized citation markers which cite different sources and are not distinguished by uniqueLetters.

Note

only consecutive citations are checked.

nonUniqueCitationMarkerHandling
)

Produce citation marker for a citation group.

private static String

Returns:

"Au[AS]Bu[AS]Cu[OXFORD_COMMA][andString]Du[yearSep]" or "Au[etAlString][yearSep]" where AS = AUTHOR_SEPARATOR Au, Bu, Cu, Du are last names of authors.

Note

- The "Au[AS]Bu[AS]Cu" (or the "Au") part may be empty (maxAuthors==0 or nAuthors==0). - OXFORD_COMMA is only emitted if nAuthors is at least 3. - andString is only emitted if nAuthors is at least 2.

formatAuthorList
(OOBibStyle style, @NonNull AuthorList
Parsed list of authors.
authorList
,
int
The maximum number of authors to write out. If there are more authors, then ET_AL_STRING is emitted to mark their omission. Set to -1 to write out all authors. maxAuthors=0 is pointless, now throws IllegalArgumentException (Earlier it behaved as maxAuthors=1) maxAuthors less than -1 : throw IllegalArgumentException
maxAuthors
,
String
For "A, B[ and ]C"
andString
)

private static String

Returns:

The author name, or an empty String if inapplicable.
getAuthorLastName
(AuthorList
The author list.
authorList
,
int
The number of the author to return.
number
)

Look up the nth author and return the "proper" last name for citation markers.

private static AuthorList
private static OOText

Returns:

The formatted citation.
getAuthorYearParenthesisMarker2
(OOBibStyle style, OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose
IN_PARENTHESIS and NORMALIZED puts parentheses around the whole, IN_TEXT around each (year,uniqueLetter,pageInfo) part. NORMALIZED omits uniqueLetter and pageInfo, ignores isFirstAppearanceOfSource (always style.getMaxAuthors, not getMaxAuthorsFirst)
purpose
,
List<CitationMarkerEntry>
The list of CitationMarkerEntry values to process. Here we do not check for duplicate entries: those are handled by getCitationMarker by omitting them from the list. Unresolved citations recognized by entry.getBibEntry() and/or entry.getDatabase() returning empty, and emitted as "Unresolved${citationKey}". Neither uniqueLetter nor pageInfo are emitted for unresolved citations.
entries
,
boolean[]
Should have the same length as entries, and contain true for entries starting a new group, false for those that only add a uniqueLetter to the grouped presentation.
startsNewGroup
,
Optional<Integer>
If not empty, always show this number of authors. Added to allow NORMALIZED to use maxAuthors value that differs from style.getMaxAuthors()
maxAuthorsOverride
)

Produce (Author, year) or "Author (year)" style citation strings.

private static String

Returns:

The resolved field content, or an empty string if the field(s) were empty.
getCitationMarkerField
(OOBibStyle style, @NonNull CitationLookupResult db, OrFields
A list of fields, to look up, using first nonempty hit. If backup fields are needed, separate field names by /. E.g. to use "author" with "editor" as backup, specify FieldFactory.serializeOrFields(StandardField.AUTHOR, StandardField.EDITOR)
fields
)

This method looks up a field for an entry in a database.

pack-priv static OOText

Returns:

A normalized citation marker for deciding which citations need uniqueLetters. For details of what "normalized" means: See getAuthorYearParenthesisMarker2

Note

now includes some markup.

getNormalizedCitationMarker
(OOBibStyle style, CitationMarkerNormEntry
A citation to process.
normEntry
,
Optional<Integer> maxAuthorsOverride)

private static List<OOText>
getNormalizedCitationMarkers(OOBibStyle style, List<CitationMarkerEntry> citationMarkerEntries, Optional<Integer> maxAuthorsOverride)

private static Optional<OOBibStyleGetCitationMarker.FieldAndContent>

Returns:

the field and the content of the first nonempty (after trimming) field (or alias) from fields found in entry. Return Optional.empty() if found nothing.
getRawCitationMarkerField
(@NonNull BibEntry entry, @NonNull BibDatabase database, @NonNull OrFields fields)

private static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

REMOVE_BRACES_FORMATTERback to summary
private static final RemoveEnclosingBracesFormatter REMOVE_BRACES_FORMATTER

Constructor Detail

OOBibStyleGetCitationMarkerback to summary
private OOBibStyleGetCitationMarker()

Method Detail

calculateNAuthorsToEmitback to summary
private static int calculateNAuthorsToEmit(OOBibStyle style, CitationMarkerEntry entry)

How many authors would be emitted for entry, considering style and entry.getIsFirstAppearanceOfSource() If entry is unresolved, return 0.

createCitationMarkerback to summary
public static OOText createCitationMarker(OOBibStyle style, List<CitationMarkerEntry> citationMarkerEntries, boolean inParenthesis, NonUniqueCitationMarker nonUniqueCitationMarkerHandling)

Produce citation marker for a citation group. Attempts to join consecutive citations: if normalized citations markers match and no pageInfo is present, the second entry can be presented by appending its uniqueLetter to the previous. If either entry has pageInfo, join is inhibited. If the previous entry has more names than we need we check with extended normalizedMarkers if they match. For consecutive identical entries, the second one is omitted. Identical requires same pageInfo here, we do not try to merge them.

Note

notifying the user about them would be nice.

Parameters
citationMarkerEntries:List<CitationMarkerEntry>

A group of citations to process.

inParenthesis:boolean

If true, put parenthesis around the whole group, otherwise around each (year,uniqueLetter,pageInfo) part.

nonUniqueCitationMarkerHandling:NonUniqueCitationMarker

What should happen if we stumble upon citations with identical normalized citation markers which cite different sources and are not distinguished by uniqueLetters.

Note

only consecutive citations are checked.

formatAuthorListback to summary
private static String formatAuthorList(OOBibStyle style, @NonNull AuthorList authorList, int maxAuthors, String andString)
Parameters
authorList:@NonNull AuthorList

Parsed list of authors.

maxAuthors:int

The maximum number of authors to write out. If there are more authors, then ET_AL_STRING is emitted to mark their omission. Set to -1 to write out all authors. maxAuthors=0 is pointless, now throws IllegalArgumentException (Earlier it behaved as maxAuthors=1) maxAuthors less than -1 : throw IllegalArgumentException

andString:String

For "A, B[ and ]C"

Returns:String

"Au[AS]Bu[AS]Cu[OXFORD_COMMA][andString]Du[yearSep]" or "Au[etAlString][yearSep]" where AS = AUTHOR_SEPARATOR Au, Bu, Cu, Du are last names of authors.

Note

- The "Au[AS]Bu[AS]Cu" (or the "Au") part may be empty (maxAuthors==0 or nAuthors==0). - OXFORD_COMMA is only emitted if nAuthors is at least 3. - andString is only emitted if nAuthors is at least 2.

getAuthorLastNameback to summary
private static String getAuthorLastName(AuthorList authorList, int number)

Look up the nth author and return the "proper" last name for citation markers.

Note

"proper" in the sense that it includes the "von" part of the name (followed by a space) if there is one.

Parameters
authorList:AuthorList

The author list.

number:int

The number of the author to return.

Returns:String

The author name, or an empty String if inapplicable.

getAuthorListback to summary
private static AuthorList getAuthorList(OOBibStyle style, CitationLookupResult db)
getAuthorYearParenthesisMarker2back to summary
private static OOText getAuthorYearParenthesisMarker2(OOBibStyle style, OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose purpose, List<CitationMarkerEntry> entries, boolean[] startsNewGroup, Optional<Integer> maxAuthorsOverride)

Produce (Author, year) or "Author (year)" style citation strings.

Parameters
purpose:OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose

IN_PARENTHESIS and NORMALIZED puts parentheses around the whole, IN_TEXT around each (year,uniqueLetter,pageInfo) part. NORMALIZED omits uniqueLetter and pageInfo, ignores isFirstAppearanceOfSource (always style.getMaxAuthors, not getMaxAuthorsFirst)

entries:List<CitationMarkerEntry>

The list of CitationMarkerEntry values to process. Here we do not check for duplicate entries: those are handled by getCitationMarker by omitting them from the list. Unresolved citations recognized by entry.getBibEntry() and/or entry.getDatabase() returning empty, and emitted as "Unresolved${citationKey}". Neither uniqueLetter nor pageInfo are emitted for unresolved citations.

startsNewGroup:boolean[]

Should have the same length as entries, and contain true for entries starting a new group, false for those that only add a uniqueLetter to the grouped presentation.

maxAuthorsOverride:Optional<Integer>

If not empty, always show this number of authors. Added to allow NORMALIZED to use maxAuthors value that differs from style.getMaxAuthors()

Returns:OOText

The formatted citation.

getCitationMarkerFieldback to summary
private static String getCitationMarkerField(OOBibStyle style, @NonNull CitationLookupResult db, OrFields fields)

This method looks up a field for an entry in a database. Any number of backup fields can be used if the primary field is empty.

Parameters
fields:OrFields

A list of fields, to look up, using first nonempty hit. If backup fields are needed, separate field names by /. E.g. to use "author" with "editor" as backup, specify FieldFactory.serializeOrFields(StandardField.AUTHOR, StandardField.EDITOR)

Returns:String

The resolved field content, or an empty string if the field(s) were empty.

getNormalizedCitationMarkerback to summary
pack-priv static OOText getNormalizedCitationMarker(OOBibStyle style, CitationMarkerNormEntry normEntry, Optional<Integer> maxAuthorsOverride)
Parameters
normEntry:CitationMarkerNormEntry

A citation to process.

Returns:OOText

A normalized citation marker for deciding which citations need uniqueLetters. For details of what "normalized" means: See getAuthorYearParenthesisMarker2

Note

now includes some markup.

getNormalizedCitationMarkersback to summary
private static List<OOText> getNormalizedCitationMarkers(OOBibStyle style, List<CitationMarkerEntry> citationMarkerEntries, Optional<Integer> maxAuthorsOverride)
getRawCitationMarkerFieldback to summary
private static Optional<OOBibStyleGetCitationMarker.FieldAndContent> getRawCitationMarkerField(@NonNull BibEntry entry, @NonNull BibDatabase database, @NonNull OrFields fields)
Returns:Optional<OOBibStyleGetCitationMarker.FieldAndContent>

the field and the content of the first nonempty (after trimming) field (or alias) from fields found in entry. Return Optional.empty() if found nothing.

markupAuthorNameback to summary
private static String markupAuthorName(OOBibStyle style, String name)
org.jabref.logic.openoffice.style back to summary

private final Enum OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose

extends Enum<OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose
public static final OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose
public static final OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose
public static OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

IN_PARENTHESISback to summary
public static final OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose IN_PARENTHESIS
IN_TEXTback to summary
public static final OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose IN_TEXT
NORMALIZEDback to summary
public static final OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose NORMALIZED

Constructor Detail

AuthorYearMarkerPurposeback to summary
private AuthorYearMarkerPurpose()

Method Detail

valueOfback to summary
public static OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose valueOf(String name)
valuesback to summary
public static OOBibStyleGetCitationMarker.AuthorYearMarkerPurpose[] values()
org.jabref.logic.openoffice.style back to summary

private Class OOBibStyleGetCitationMarker.CitationMarkerNormEntryWrap

extends Object
implements CitationMarkerEntry
Class Inheritance
  • java.lang.Object
  • org.jabref.logic.openoffice.style.OOBibStyleGetCitationMarker.CitationMarkerNormEntryWrap
All Implemented Interfaces
org.jabref.model.openoffice.style.CitationMarkerEntry, org.jabref.model.openoffice.style.CitationMarkerNormEntry

Add / override methods for the purpose of creating a normalized citation marker.

Field Summary

Modifier and TypeField and Description
pack-priv CitationMarkerNormEntry

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
public boolean
public Optional<CitationLookupResult>
getLookupResult()

Implements org.jabref.model.openoffice.style.CitationMarkerNormEntry.getLookupResult.

Result of looking up citation key in databases.

public Optional<OOText>
getPageInfo()

Implements org.jabref.model.openoffice.style.CitationMarkerEntry.getPageInfo.

pageInfo for this citation, provided by the user.

public Optional<String>
getUniqueLetter()

Implements org.jabref.model.openoffice.style.CitationMarkerEntry.getUniqueLetter.

uniqueLetter or Optional.empty() if not needed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

innerback to summary
pack-priv CitationMarkerNormEntry inner

Constructor Detail

CitationMarkerNormEntryWrapback to summary
pack-priv CitationMarkerNormEntryWrap(CitationMarkerNormEntry inner)

Method Detail

getCitationKeyback to summary
public String getCitationKey()

Implements org.jabref.model.openoffice.style.CitationMarkerNormEntry.getCitationKey.

Doc from org.jabref.model.openoffice.style.CitationMarkerNormEntry.getCitationKey.

Citation key. This is what we usually get from the document.

Used if getLookupResult() returns empty, which indicates failure to lookup in the databases.

Annotations
@Override
getIsFirstAppearanceOfSourceback to summary
public boolean getIsFirstAppearanceOfSource()

Implements org.jabref.model.openoffice.style.CitationMarkerEntry.getIsFirstAppearanceOfSource.

Returns:boolean

Doc from org.jabref.model.openoffice.style.CitationMarkerEntry.getIsFirstAppearanceOfSource.

true if this citation is the first appearance of the source cited. Some styles use different limit on the number of authors shown in this case.

Annotations
@Override
getLookupResultback to summary
public Optional<CitationLookupResult> getLookupResult()

Implements org.jabref.model.openoffice.style.CitationMarkerNormEntry.getLookupResult.

Doc from org.jabref.model.openoffice.style.CitationMarkerNormEntry.getLookupResult.

Result of looking up citation key in databases.

Optional.empty() indicates unresolved citation.

Annotations
@Override
getPageInfoback to summary
public Optional<OOText> getPageInfo()

Implements org.jabref.model.openoffice.style.CitationMarkerEntry.getPageInfo.

Doc from org.jabref.model.openoffice.style.CitationMarkerEntry.getPageInfo.

pageInfo for this citation, provided by the user. May be empty, for none.

Annotations
@Override
getUniqueLetterback to summary
public Optional<String> getUniqueLetter()

Implements org.jabref.model.openoffice.style.CitationMarkerEntry.getUniqueLetter.

Doc from org.jabref.model.openoffice.style.CitationMarkerEntry.getUniqueLetter.

uniqueLetter or Optional.empty() if not needed.

Annotations
@Override
org.jabref.logic.openoffice.style back to summary

private Class OOBibStyleGetCitationMarker.FieldAndContent

extends Object
Class Inheritance
  • java.lang.Object
  • org.jabref.logic.openoffice.style.OOBibStyleGetCitationMarker.FieldAndContent

On success, getRawCitationMarkerField returns content, but we also need to know which field matched, because for some fields (actually: for author names) we need to reproduce the surrounding braces to inform AuthorList.parse not to split up the content.

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv Field

Constructor Summary

AccessConstructor and Description
pack-priv
FieldAndContent(Field field, String content)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
pack-priv String content
fieldback to summary
pack-priv Field field

Constructor Detail

FieldAndContentback to summary
pack-priv FieldAndContent(Field field, String content)