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

public final Class CSLStyleUtils

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .Reader, java.nio.file.Files, .InvalidPathException, .Path, java.util.Optional, javax.xml.stream.XMLInputFactory, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, org.jabref.logic.util.StandardFileType, org.slf4j.Logger, .LoggerFactory

Utility class for handling Citation Style Language (CSL) files. Contains shared functionality used by both runtime CSLStyleLoader and build-time components in build-support/src/main/java/CitationStyleCatalogGenerator.java.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static record
CSLStyleUtils.StyleInfo

Style information record (style id, style class, title, numeric nature, bibliography presence, bibliography sort order, bibliography hanging indent) for a citation style.

Field Summary

Modifier and TypeField and Description
private static final Logger
private static final String
private static final XMLInputFactory

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Optional<CitationStyle>

Returns:

Optional containing the CitationStyle if valid, empty otherwise
createCitationStyleFromFile
(String
Path to the CSL file
styleFile
)

Creates a CitationStyle from a file path.

private static Optional<CitationStyle>

Returns:

Optional containing the CitationStyle if valid, empty otherwise
createCitationStyleFromSource
(InputStream source, String filename, boolean isInternal)

Creates a CitationStyle from the input stream.

public static boolean
isCitationStyleFile(String styleFile)

Checks if the given style file is a CitationStyle based on its extension

public static Optional<CSLStyleUtils.StyleInfo>

Returns:

Optional containing the StyleInfo if valid, empty otherwise
parseStyleInfo
(String
The filename of the style (for logging)
filename
,
String
The XML content of the style
content
)

Parses the style information from a style content using StAX.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER
STYLES_ROOTback to summary
private static final String STYLES_ROOT
XML_INPUT_FACTORYback to summary
private static final XMLInputFactory XML_INPUT_FACTORY

Constructor Detail

CSLStyleUtilsback to summary
private CSLStyleUtils()

Method Detail

createCitationStyleFromFileback to summary
public static Optional<CitationStyle> createCitationStyleFromFile(String styleFile)

Creates a CitationStyle from a file path.

Parameters
styleFile:String

Path to the CSL file

Returns:Optional<CitationStyle>

Optional containing the CitationStyle if valid, empty otherwise

createCitationStyleFromSourceback to summary
private static Optional<CitationStyle> createCitationStyleFromSource(InputStream source, String filename, boolean isInternal)

Creates a CitationStyle from the input stream.

Returns:Optional<CitationStyle>

Optional containing the CitationStyle if valid, empty otherwise

isCitationStyleFileback to summary
public static boolean isCitationStyleFile(String styleFile)

Checks if the given style file is a CitationStyle based on its extension

parseStyleInfoback to summary
public static Optional<CSLStyleUtils.StyleInfo> parseStyleInfo(String filename, String content)

Parses the style information from a style content using StAX.

Parameters
filename:String

The filename of the style (for logging)

content:String

The XML content of the style

Returns:Optional<CSLStyleUtils.StyleInfo>

Optional containing the StyleInfo if valid, empty otherwise

org.jabref.logic.citationstyle back to summary

public final Record CSLStyleUtils.StyleInfo

extends Record
Class Inheritance
Record Components
styleId:String 
styleClass:String 
title:String 
shortTitle:String 
isNumericStyle:boolean 
hasBibliography:boolean 
hasBibliographySortOrder:boolean 
usesHangingIndent:boolean 

Style information record (style id, style class, title, numeric nature, bibliography presence, bibliography sort order, bibliography hanging indent) for a citation style.

Field Summary

Modifier and TypeField and Description
private final boolean
hasBibliography

Record Component accessed by hasBibliography().

private final boolean
private final boolean
isNumericStyle

Record Component accessed by isNumericStyle().

private final String
shortTitle

Record Component accessed by shortTitle().

private final String
styleClass

Record Component accessed by styleClass().

private final String
styleId

Record Component accessed by styleId().

private final String
title

Record Component accessed by title().

private final boolean
usesHangingIndent

Record Component accessed by usesHangingIndent().

Constructor Summary

AccessConstructor and Description
public
StyleInfo(String styleId, String styleClass, String title, String shortTitle, boolean isNumericStyle, boolean hasBibliography, boolean hasBibliographySortOrder, boolean usesHangingIndent)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public boolean
hasBibliography()

Record Component getter of hasBibliography.

public boolean
public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
isNumericStyle()

Record Component getter of isNumericStyle.

public String
shortTitle()

Record Component getter of shortTitle.

public String
styleClass()

Record Component getter of styleClass.

public String
styleId()

Record Component getter of styleId.

public String
title()

Record Component getter of title.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public boolean
usesHangingIndent()

Record Component getter of usesHangingIndent.

Field Detail

hasBibliographyback to summary
private final boolean hasBibliography

Record Component accessed by hasBibliography().

hasBibliographySortOrderback to summary
private final boolean hasBibliographySortOrder

Record Component accessed by hasBibliographySortOrder().

isNumericStyleback to summary
private final boolean isNumericStyle

Record Component accessed by isNumericStyle().

shortTitleback to summary
private final String shortTitle

Record Component accessed by shortTitle().

styleClassback to summary
private final String styleClass

Record Component accessed by styleClass().

styleIdback to summary
private final String styleId

Record Component accessed by styleId().

titleback to summary
private final String title

Record Component accessed by title().

usesHangingIndentback to summary
private final boolean usesHangingIndent

Record Component accessed by usesHangingIndent().

Constructor Detail

StyleInfoback to summary
public StyleInfo(String styleId, String styleClass, String title, String shortTitle, boolean isNumericStyle, boolean hasBibliography, boolean hasBibliographySortOrder, boolean usesHangingIndent)

Method Detail

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).
hasBibliographyback to summary
public boolean hasBibliography()

Record Component getter of hasBibliography.

hasBibliographySortOrderback to summary
public boolean hasBibliographySortOrder()

Record Component getter of hasBibliographySortOrder.

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.

isNumericStyleback to summary
public boolean isNumericStyle()

Record Component getter of isNumericStyle.

shortTitleback to summary
public String shortTitle()

Record Component getter of shortTitle.

styleClassback to summary
public String styleClass()

Record Component getter of styleClass.

styleIdback to summary
public String styleId()

Record Component getter of styleId.

titleback to summary
public String title()

Record Component getter of title.

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.

usesHangingIndentback to summary
public boolean usesHangingIndent()

Record Component getter of usesHangingIndent.