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

public final Record CSLStyleLoader

extends Record
Class Inheritance
Record Components
openOfficePreferences:OpenOfficePreferences 
Imports
java.io.IOException, .InputStream, java.nio.charset.StandardCharsets, java.util.ArrayList, .List, .Map, .Optional, org.jabref.logic.openoffice.OpenOfficePreferences, org.jspecify.annotations.NonNull, .Nullable, org.slf4j.Logger, .LoggerFactory, tools.jackson.core.type.TypeReference, tools.jackson.databind.ObjectMapper

Manages the loading of CitationStyles from both internal resources and external files.

Field Summary

Modifier and TypeField and Description
private static final List<String>
CATALOG_KEYS

Keys written by CitationStyleCatalogGenerator#generateCatalog.

private static final String
public static final String
private static final CitationStyle
EMPTY_STYLE

Placeholder returned when even the default style cannot be loaded.

private static final List<CitationStyle>
private static final List<CitationStyle>
private static final Logger
private final OpenOfficePreferences
openOfficePreferences

Record Component accessed by openOfficePreferences().

private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addExternalStyle(@NonNull CitationStyle citationStyle)

Adds a new external CSL style.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

pack-priv static List<String>
public static CitationStyle
getDefaultStyle()

Returns the default citation style which is currently set to CSLStyleLoader#DEFAULT_STYLE.

public static List<CitationStyle>
public static List<CitationStyle>
getStyles()

Returns a list of all available citation styles (both internal and external).

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

private void
loadExternalStyles()

Loads external CSL styles from the preferences.

public static void
loadInternalStyles()

Loads the internal (built-in) CSL styles from the catalog generated at build-time.

private static String
public OpenOfficePreferences
openOfficePreferences()

Record Component getter of openOfficePreferences.

public boolean

Returns:

true if the style was removed, false otherwise
removeStyle
(@NonNull CitationStyle style)

Removes a style from the external styles list.

private void
storeExternalStyles()

Stores the current list of external styles to preferences.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

CATALOG_KEYSback to summary
private static final List<String> CATALOG_KEYS

Keys written by CitationStyleCatalogGenerator#generateCatalog. Keep in sync when adding style metadata.

CATALOG_PATHback to summary
private static final String CATALOG_PATH
DEFAULT_STYLEback to summary
public static final String DEFAULT_STYLE
EMPTY_STYLEback to summary
private static final CitationStyle EMPTY_STYLE

Placeholder returned when even the default style cannot be loaded. Not backed by a CSL source.

EXTERNAL_STYLESback to summary
private static final List<CitationStyle> EXTERNAL_STYLES
INTERNAL_STYLESback to summary
private static final List<CitationStyle> INTERNAL_STYLES
LOGGERback to summary
private static final Logger LOGGER
openOfficePreferencesback to summary
private final OpenOfficePreferences openOfficePreferences

Record Component accessed by openOfficePreferences().

STYLES_ROOTback to summary
private static final String STYLES_ROOT

Constructor Detail

CSLStyleLoaderback to summary
public CSLStyleLoader(@NonNull OpenOfficePreferences openOfficePreferences)

Method Detail

addExternalStyleback to summary
public void addExternalStyle(@NonNull CitationStyle citationStyle)

Adds a new external CSL style.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
findMissingCatalogKeysback to summary
pack-priv static List<String> findMissingCatalogKeys(Map<String, Object> info)
getDefaultStyleback to summary
public static CitationStyle getDefaultStyle()

Returns the default citation style which is currently set to CSLStyleLoader#DEFAULT_STYLE.

getInternalStylesback to summary
public static List<CitationStyle> getInternalStyles()
getStylesback to summary
public static List<CitationStyle> getStyles()

Returns a list of all available citation styles (both internal and external).

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

loadExternalStylesback to summary
private void loadExternalStyles()

Loads external CSL styles from the preferences.

loadInternalStylesback to summary
public static void loadInternalStyles()

Loads the internal (built-in) CSL styles from the catalog generated at build-time.

loadInternalStyleSourceback to summary
private static String loadInternalStyleSource(String path)
openOfficePreferencesback to summary
public OpenOfficePreferences openOfficePreferences()

Record Component getter of openOfficePreferences.

removeStyleback to summary
public boolean removeStyle(@NonNull CitationStyle style)

Removes a style from the external styles list.

Returns:boolean

true if the style was removed, false otherwise

storeExternalStylesback to summary
private void storeExternalStyles()

Stores the current list of external styles to preferences.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.