Top Description Inners Fields Constructors Methods
de.undercouch.citeproc.csl.internal.format

public abstract Class BaseFormat

extends Object
implements Format
Class Inheritance
All Implemented Interfaces
de.undercouch.citeproc.csl.internal.format.Format
Known Direct Subclasses
de.undercouch.citeproc.csl.internal.format.FoFormat, de.undercouch.citeproc.csl.internal.format.HtmlFormat, de.undercouch.citeproc.csl.internal.format.MarkdownPureFormat, de.undercouch.citeproc.csl.internal.format.TextFormat, de.undercouch.citeproc.csl.internal.format.AsciiDocFormat
Imports
de.undercouch.citeproc.csl.internal.RenderContext, .TokenBuffer, de.undercouch.citeproc.csl.internal.behavior.FormattingAttributes, de.undercouch.citeproc.csl.internal.token.DisplayGroupToken, .TextToken, .Token, de.undercouch.citeproc.helper.FrenchPunctuationSpacing, .SmartQuotes, .StringHelper, org.apache.commons.lang3.tuple.Pair, java.util.ArrayList, .EnumMap, .EnumSet, .Iterator, .List, .Locale, .Map

A base class for output formats
Author
Michel Kraemer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
BaseFormat.Format

A list of all formatting attributes managed by format(TokenBuffer)

Field Summary

Modifier and TypeField and Description
protected boolean
private static final Map<String, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String

Returns:

the string with the prefix
addDOIPrefix
(String
the string
str
)

Prepends https://doi.org/ to the given string if it is not an absolute URL yet.

protected String

Returns:

the generated text or null
closeDisplayGroup
(DisplayGroupToken.Type
the type of the display group to close
type
)

Generate text that closes a display group

protected String

Returns:

the generated text or null
closeFontStyle
(int
the font style to disable
fontStyle
)

Generate text that disables the given font style in the output format

protected String

Returns:

the generated text or null
closeFontVariant
(int
the font variant to disable
fontVariant
)

Generate text that disables the given font variant in the output format

protected String

Returns:

the generated text or null
closeFontWeight
(int
the font weight to disable
fontWeight
)

Generate text that disables the given font weight in the output format

private void
closeFormattingAttribute(BaseFormat.Format
the formatting attribute to close
f
,
int
the attribute's old value
value
,
StringBuilder
the string builder to append the result to
result
)

Close the given formatting attribute by calling the respective closeXXX() method

protected String

Returns:

the generated text or null
closeTextDecoration
(int
the text decoration to disable
textDecoration
)

Generate text that disables the given text decoration in the output format

protected String

Returns:

the generated text or null
closeVerticalAlign
(int
the vertical alignment to disable
verticalAlign
)

Generate text that disables the given vertical alignment in the output format

protected abstract String

Returns:

the formatted bibliography entry
doFormatBibliographyEntry
(TokenBuffer
the post-processed buffer to format
buffer
,
RenderContext
the render context holding the original, non-post-processed buffer and parameters
ctx
,
int
the index of the entry
index
)

Convert a bibliography entry from a post-processed buffer to a string

protected abstract String

Returns:

the formatted citation
doFormatCitation
(TokenBuffer
the post-processed buffer to format
buffer
,
RenderContext
the render context holding the original, non-post-processed buffer and parameters
ctx
)

Convert a citation from a post-processed buffer to a string

protected String

Returns:

the escaped string
escape
(String
the string to escape (may be null)
str
)

Escape any formatting instructions specific to the output format

private static int

Returns:

the index of the first text token after i, or -1 if there is no such token
findNextText
(List<Token>
the list of tokens
tokens
,
int
the index of the token after which the search should start
i
)

Search the list of tokens from i + 1 up to tokens.size() and find the first text token

private static int

Returns:

the index of the first text token before i that is not a closing quotation mark, or -1 if there is no such token
findPreviousNonQuote
(List<Token>
the list of tokens
tokens
,
int
the index of the token before which the search should start
i
)

Search the list of tokens from i - 1 down to 0 and find the first text token that is not a closing quotation mark

private static int

Returns:

the index of the first text token before i, or -1 if there is no such token
findPreviousText
(List<Token>
the list of tokens
tokens
,
int
the index of the token before which the search should start
i
)

Search the list of tokens from i - 1 down to 0 and find the first text token

protected String

Returns:

the formatted string
format
(TokenBuffer
the buffer to format
buffer
)

Format a given token buffer

public String
public String
protected String

Returns:

the link
formatDOI
(String
the DOI
str
)

Convert a DOI to a link

protected String

Returns:

the link
formatURL
(String
the URL
str
)

Convert a URL to a link

protected String

Returns:

the generated text or null
openDisplayGroup
(DisplayGroupToken.Type
the type of the display group to open
type
)

Generate text that opens a display group

protected String

Returns:

the generated text or null
openFontStyle
(int
the font style to enable
fontStyle
)

Generate text that enables the given font style in the output format

protected String

Returns:

the generated text or null
openFontVariant
(int
the font variant to enable
fontVariant
)

Generate text that enables the given font variant in the output format

protected String

Returns:

the generated text or null
openFontWeight
(int
the font weight to enable
fontWeight
)

Generate text that enables the given font weight in the output format

private void
openFormattingAttribute(BaseFormat.Format
the formatting attribute to open
f
,
int
the attribute's value
value
,
StringBuilder
the string builder to append the result to
result
)

Open the given formatting attribute by calling the respective openXXX() method

protected String

Returns:

the generated text or null
openTextDecoration
(int
the text decoration to enable
textDecoration
)

Generate text that enables the given text decoration in the output format

protected String

Returns:

the generated text or null
openVerticalAlign
(int
the vertical alignment to enable
verticalAlign
)

Generate text that enables the given vertical alignment in the output format

protected void
postProcess(TokenBuffer
the buffer to process
buffer
,
RenderContext
the render context in which the buffer was created
ctx
)

Performs post-processing on the given buffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MERGE_PUNCTUATION_MAPback to summary
private static final Map<String, String> MERGE_PUNCTUATION_MAP

Constructor Detail

BaseFormatback to summary
public BaseFormat()

Method Detail

addDOIPrefixback to summary
protected String addDOIPrefix(String str)

Prepends https://doi.org/ to the given string if it is not an absolute URL yet.

Parameters
str:String

the string

Returns:String

the string with the prefix

closeDisplayGroupback to summary
protected String closeDisplayGroup(DisplayGroupToken.Type type)

Generate text that closes a display group

Parameters
type:DisplayGroupToken.Type

the type of the display group to close

Returns:String

the generated text or null

closeFontStyleback to summary
protected String closeFontStyle(int fontStyle)

Generate text that disables the given font style in the output format

Parameters
fontStyle:int

the font style to disable

Returns:String

the generated text or null

closeFontVariantback to summary
protected String closeFontVariant(int fontVariant)

Generate text that disables the given font variant in the output format

Parameters
fontVariant:int

the font variant to disable

Returns:String

the generated text or null

closeFontWeightback to summary
protected String closeFontWeight(int fontWeight)

Generate text that disables the given font weight in the output format

Parameters
fontWeight:int

the font weight to disable

Returns:String

the generated text or null

closeFormattingAttributeback to summary
private void closeFormattingAttribute(BaseFormat.Format f, int value, StringBuilder result)

Close the given formatting attribute by calling the respective closeXXX() method

Parameters
f:BaseFormat.Format

the formatting attribute to close

value:int

the attribute's old value

result:StringBuilder

the string builder to append the result to

closeTextDecorationback to summary
protected String closeTextDecoration(int textDecoration)

Generate text that disables the given text decoration in the output format

Parameters
textDecoration:int

the text decoration to disable

Returns:String

the generated text or null

closeVerticalAlignback to summary
protected String closeVerticalAlign(int verticalAlign)

Generate text that disables the given vertical alignment in the output format

Parameters
verticalAlign:int

the vertical alignment to disable

Returns:String

the generated text or null

doFormatBibliographyEntryback to summary
protected abstract String doFormatBibliographyEntry(TokenBuffer buffer, RenderContext ctx, int index)

Convert a bibliography entry from a post-processed buffer to a string

Parameters
buffer:TokenBuffer

the post-processed buffer to format

ctx:RenderContext

the render context holding the original, non-post-processed buffer and parameters

index:int

the index of the entry

Returns:String

the formatted bibliography entry

doFormatCitationback to summary
protected abstract String doFormatCitation(TokenBuffer buffer, RenderContext ctx)

Convert a citation from a post-processed buffer to a string

Parameters
buffer:TokenBuffer

the post-processed buffer to format

ctx:RenderContext

the render context holding the original, non-post-processed buffer and parameters

Returns:String

the formatted citation

escapeback to summary
protected String escape(String str)

Escape any formatting instructions specific to the output format

Parameters
str:String

the string to escape (may be null)

Returns:String

the escaped string

findNextTextback to summary
private static int findNextText(List<Token> tokens, int i)

Search the list of tokens from i + 1 up to tokens.size() and find the first text token

Parameters
tokens:List<Token>

the list of tokens

i:int

the index of the token after which the search should start

Returns:int

the index of the first text token after i, or -1 if there is no such token

findPreviousNonQuoteback to summary
private static int findPreviousNonQuote(List<Token> tokens, int i)

Search the list of tokens from i - 1 down to 0 and find the first text token that is not a closing quotation mark

Parameters
tokens:List<Token>

the list of tokens

i:int

the index of the token before which the search should start

Returns:int

the index of the first text token before i that is not a closing quotation mark, or -1 if there is no such token

findPreviousTextback to summary
private static int findPreviousText(List<Token> tokens, int i)

Search the list of tokens from i - 1 down to 0 and find the first text token

Parameters
tokens:List<Token>

the list of tokens

i:int

the index of the token before which the search should start

Returns:int

the index of the first text token before i, or -1 if there is no such token

formatback to summary
protected String format(TokenBuffer buffer)

Format a given token buffer

Parameters
buffer:TokenBuffer

the buffer to format

Returns:String

the formatted string

formatBibliographyEntryback to summary
public String formatBibliographyEntry(RenderContext ctx, int index)

Implements de.undercouch.citeproc.csl.internal.format.Format.formatBibliographyEntry.

Doc from de.undercouch.citeproc.csl.internal.format.Format.formatBibliographyEntry.

Format a bibliography entry

Annotations
@Override
formatCitationback to summary
public String formatCitation(RenderContext ctx)

Implements de.undercouch.citeproc.csl.internal.format.Format.formatCitation.

Doc from de.undercouch.citeproc.csl.internal.format.Format.formatCitation.

Format a citation

Annotations
@Override
formatDOIback to summary
protected String formatDOI(String str)

Convert a DOI to a link

Parameters
str:String

the DOI

Returns:String

the link

formatURLback to summary
protected String formatURL(String str)

Convert a URL to a link

Parameters
str:String

the URL

Returns:String

the link

openDisplayGroupback to summary
protected String openDisplayGroup(DisplayGroupToken.Type type)

Generate text that opens a display group

Parameters
type:DisplayGroupToken.Type

the type of the display group to open

Returns:String

the generated text or null

openFontStyleback to summary
protected String openFontStyle(int fontStyle)

Generate text that enables the given font style in the output format

Parameters
fontStyle:int

the font style to enable

Returns:String

the generated text or null

openFontVariantback to summary
protected String openFontVariant(int fontVariant)

Generate text that enables the given font variant in the output format

Parameters
fontVariant:int

the font variant to enable

Returns:String

the generated text or null

openFontWeightback to summary
protected String openFontWeight(int fontWeight)

Generate text that enables the given font weight in the output format

Parameters
fontWeight:int

the font weight to enable

Returns:String

the generated text or null

openFormattingAttributeback to summary
private void openFormattingAttribute(BaseFormat.Format f, int value, StringBuilder result)

Open the given formatting attribute by calling the respective openXXX() method

Parameters
f:BaseFormat.Format

the formatting attribute to open

value:int

the attribute's value

result:StringBuilder

the string builder to append the result to

openTextDecorationback to summary
protected String openTextDecoration(int textDecoration)

Generate text that enables the given text decoration in the output format

Parameters
textDecoration:int

the text decoration to enable

Returns:String

the generated text or null

openVerticalAlignback to summary
protected String openVerticalAlign(int verticalAlign)

Generate text that enables the given vertical alignment in the output format

Parameters
verticalAlign:int

the vertical alignment to enable

Returns:String

the generated text or null

postProcessback to summary
protected void postProcess(TokenBuffer buffer, RenderContext ctx)

Performs post-processing on the given buffer. Alters the buffer's contents. Be sure to make a copy of the buffer before calling this method.

Parameters
buffer:TokenBuffer

the buffer to process

ctx:RenderContext

the render context in which the buffer was created

de.undercouch.citeproc.csl.internal.format back to summary

private final Enum BaseFormat.Format

extends Enum<BaseFormat.Format>
Class Inheritance

A list of all formatting attributes managed by format(TokenBuffer)

Field Summary

Modifier and TypeField and Description
public static final BaseFormat.Format
public static final BaseFormat.Format
public static final BaseFormat.Format
public static final BaseFormat.Format
public static final BaseFormat.Format

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Field Detail

FontStyleback to summary
public static final BaseFormat.Format FontStyle
FontVariantback to summary
public static final BaseFormat.Format FontVariant
FontWeightback to summary
public static final BaseFormat.Format FontWeight
TextDecorationback to summary
public static final BaseFormat.Format TextDecoration
VerticalAlignback to summary
public static final BaseFormat.Format VerticalAlign

Constructor Detail

Formatback to summary
private Format()

Method Detail

valueOfback to summary
public static BaseFormat.Format valueOf(String name)
valuesback to summary
public static BaseFormat.Format[] values()