Top Description Fields Constructors Methods
de.undercouch.citeproc.csl.internal.rendering

public Class SName

extends Object
implements SElement
Class Inheritance
All Implemented Interfaces
de.undercouch.citeproc.csl.internal.SElement
Imports
de.undercouch.citeproc.csl.CSLName, de.undercouch.citeproc.csl.internal.RenderContext, .SElement, .TokenBuffer, de.undercouch.citeproc.csl.internal.behavior.Affixes, .FormattingAttributes, .TextCase, de.undercouch.citeproc.helper.NodeHelper, .StringHelper, org.w3c.dom.Node, .NodeList, java.util.ArrayList, .Arrays, .List

A name element from a style file
Author
Michel Kraemer

Field Summary

Modifier and TypeField and Description
private final String
private final Affixes
private final int
private final TextCase
private final int
public static final int
FORM_COUNT

A form that only returns the number of names that would be rendered

public static final int
FORM_LONG

The long form with given and family name

public static final int
FORM_SHORT

The short form with family name and non-dropping particles only

private final int
private final Affixes
private final int
private final TextCase
private final SNameInheritableAttributes
private final String

Constructor Summary

AccessConstructor and Description
public
SName(Node
the XML node (may be null)
node
,
String
the variable that holds the name (may be null)
variable
)

Create the name element from an XML node

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

true if the delimiter was actually appended
appendDelimiter
(TokenBuffer
the token buffer to append to
buffer
,
String
the mode (i.e. "contextual", "always", "after-inverted-name", or "never")
delimiterPrecedes
,
boolean
true if the name preceding the delimiter has been inverted as a result of the name-as-sort-order attribute
nameAsSort
,
boolean
true if the delimiter should actually be appended in contextual mode
contextual
)

Append delimiter to a builder according to the given mode

public int

Returns:

the form
getForm
()

Get the form of the name to render

public String

Returns:

the name variable
getVariable
()

Get the name variable this element selects

public void
private TokenBuffer

Returns:

the rendered name
render
(CSLName
the name to render
name
,
boolean
true if given name and family name should be swapped (i.e. "Family, Given" instead of "Given Family")
nameAsSort
,
String
the string to append to initials
initializeWith
,
boolean
true if given names should be converted to initials
initialize
,
String
delimiter for name-parts that have switched positions as a result of name-as-sort-order
sortSeparator
,
RenderContext
the current render context
ctx
)

Render a single name

private static boolean

Returns:

true if given name and family name should be separated by whitespace (or if the given string is null, in which case it is undecidable, and the default is true), or false if this is normally not the case for the string's language.
shouldBeSeparatedBySpace
(String
the string to check
s
)

Check if a string only contains characters from a language where the given name and the family name are typically separated by whitespace.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delimiterback to summary
private final String delimiter
familyAffixesback to summary
private final Affixes familyAffixes
familyFormattingAttributesback to summary
private final int familyFormattingAttributes
familyTextCaseback to summary
private final TextCase familyTextCase
formback to summary
private final int form
FORM_COUNTback to summary
public static final int FORM_COUNT

A form that only returns the number of names that would be rendered

FORM_LONGback to summary
public static final int FORM_LONG

The long form with given and family name

FORM_SHORTback to summary
public static final int FORM_SHORT

The short form with family name and non-dropping particles only

formattingAttributesback to summary
private final int formattingAttributes
givenAffixesback to summary
private final Affixes givenAffixes
givenFormattingAttributesback to summary
private final int givenFormattingAttributes
givenTextCaseback to summary
private final TextCase givenTextCase
inheritableAttributesback to summary
private final SNameInheritableAttributes inheritableAttributes
variableback to summary
private final String variable

Constructor Detail

SNameback to summary
public SName(Node node, String variable)

Create the name element from an XML node

Parameters
node:Node

the XML node (may be null)

variable:String

the variable that holds the name (may be null)

Method Detail

appendDelimiterback to summary
private boolean appendDelimiter(TokenBuffer buffer, String delimiterPrecedes, boolean nameAsSort, boolean contextual)

Append delimiter to a builder according to the given mode

Parameters
buffer:TokenBuffer

the token buffer to append to

delimiterPrecedes:String

the mode (i.e. "contextual", "always", "after-inverted-name", or "never")

nameAsSort:boolean

true if the name preceding the delimiter has been inverted as a result of the name-as-sort-order attribute

contextual:boolean

true if the delimiter should actually be appended in contextual mode

Returns:boolean

true if the delimiter was actually appended

getFormback to summary
public int getForm()

Get the form of the name to render

Returns:int

the form

See Also
FORM_LONG, FORM_SHORT, FORM_COUNT
getVariableback to summary
public String getVariable()

Get the name variable this element selects

Returns:String

the name variable

renderback to summary
public void render(RenderContext ctx)

Implements de.undercouch.citeproc.csl.internal.SElement.render.

Doc from de.undercouch.citeproc.csl.internal.SElement.render.

Renders the element

Annotations
@Override
renderback to summary
private TokenBuffer render(CSLName name, boolean nameAsSort, String initializeWith, boolean initialize, String sortSeparator, RenderContext ctx)

Render a single name

Parameters
name:CSLName

the name to render

nameAsSort:boolean

true if given name and family name should be swapped (i.e. "Family, Given" instead of "Given Family")

initializeWith:String

the string to append to initials

initialize:boolean

true if given names should be converted to initials

sortSeparator:String

delimiter for name-parts that have switched positions as a result of name-as-sort-order

ctx:RenderContext

the current render context

Returns:TokenBuffer

the rendered name

shouldBeSeparatedBySpaceback to summary
private static boolean shouldBeSeparatedBySpace(String s)

Check if a string only contains characters from a language where the given name and the family name are typically separated by whitespace. As soon as a character is found from a language where names typically don't include spaces, the method returns false.

The list of languages that don't include spaces in names comes from Claude AI and ChatGPT. There is also a nice discussion in the CSL discussion forum.

Parameters
s:String

the string to check

Returns:boolean

true if given name and family name should be separated by whitespace (or if the given string is null, in which case it is undecidable, and the default is true), or false if this is normally not the case for the string's language.