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

public Class TokenBuffer

extends Object
Class Inheritance
Imports
de.undercouch.citeproc.csl.internal.token.TextToken, .Token, java.util.ArrayList, .List, java.util.stream.Collectors

A buffer of rendered tokens
Author
Michel Kraemer

Field Summary

Modifier and TypeField and Description
private final List<Token>

Constructor Summary

AccessConstructor and Description
public
TokenBuffer()

Create an empty token buffer

private
TokenBuffer(List<Token>
the token list
tokens
)

Create a token buffer with the given list of tokens

Method Summary

Modifier and TypeMethod and Description
public TokenBuffer

Returns:

this token buffer
append
(Token
the token
token
)

Append a token to the buffer

public TokenBuffer

Returns:

this token buffer
append
(String
the token's text
text
,
TextToken.Type
the token's type
type
)

Append a text token with a given type to the buffer

public TokenBuffer

Returns:

this token buffer
append
(String
the token's text
text
,
TextToken.Type
the token's type
type
,
int
the token's formatting attributes
formattingAttributes
)

Append a text token with a given type and formatting attributes to the buffer

public TokenBuffer

Returns:

this token buffer
append
(TokenBuffer
the other token buffer
other
)

Append the contents of another token buffer to this one

public TokenBuffer

Returns:

the new token buffer
copy
(int
the index of the first element (inclusive)
fromIndex
,
int
the index of the last element (exclusive)
toIndex
)

Create a new token buffer that contains a portion of this one between the specified fromIndex and toIndex (exclusive).

public List<Token>

Returns:

the list
getTokens
()

Get the list of tokens managed by this buffer

public boolean

Returns:

true if the buffer does not contain tokens
isEmpty
()

Test if the buffer is empty

public TokenBuffer

Returns:

this token buffer
prepend
(Token
the token
token
)

Prepend a token to the buffer

public TokenBuffer

Returns:

this token buffer
prepend
(String
the token's text
text
,
TextToken.Type
the token's type
type
)

Prepend a text token with a given type to the buffer

public TokenBuffer

Returns:

this token buffer
prepend
(String
the token's text
text
,
TextToken.Type
the token's type
type
,
int
the token's formatting attributes
formattingAttributes
)

Prepend a text token with a given type and formatting attributes to the buffer

public TokenBuffer

Returns:

this token buffer
prepend
(TokenBuffer
the other token buffer
other
)

Prepend the contents of another token buffer to this one

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

tokensback to summary
private final List<Token> tokens

Constructor Detail

TokenBufferback to summary
public TokenBuffer()

Create an empty token buffer

TokenBufferback to summary
private TokenBuffer(List<Token> tokens)

Create a token buffer with the given list of tokens

Parameters
tokens:List<Token>

the token list

Method Detail

appendback to summary
public TokenBuffer append(Token token)

Append a token to the buffer

Parameters
token:Token

the token

Returns:TokenBuffer

this token buffer

appendback to summary
public TokenBuffer append(String text, TextToken.Type type)

Append a text token with a given type to the buffer

Parameters
text:String

the token's text

type:TextToken.Type

the token's type

Returns:TokenBuffer

this token buffer

appendback to summary
public TokenBuffer append(String text, TextToken.Type type, int formattingAttributes)

Append a text token with a given type and formatting attributes to the buffer

Parameters
text:String

the token's text

type:TextToken.Type

the token's type

formattingAttributes:int

the token's formatting attributes

Returns:TokenBuffer

this token buffer

appendback to summary
public TokenBuffer append(TokenBuffer other)

Append the contents of another token buffer to this one

Parameters
other:TokenBuffer

the other token buffer

Returns:TokenBuffer

this token buffer

copyback to summary
public TokenBuffer copy(int fromIndex, int toIndex)

Create a new token buffer that contains a portion of this one between the specified fromIndex and toIndex (exclusive).

Parameters
fromIndex:int

the index of the first element (inclusive)

toIndex:int

the index of the last element (exclusive)

Returns:TokenBuffer

the new token buffer

getTokensback to summary
public List<Token> getTokens()

Get the list of tokens managed by this buffer

Returns:List<Token>

the list

isEmptyback to summary
public boolean isEmpty()

Test if the buffer is empty

Returns:boolean

true if the buffer does not contain tokens

prependback to summary
public TokenBuffer prepend(Token token)

Prepend a token to the buffer

Parameters
token:Token

the token

Returns:TokenBuffer

this token buffer

prependback to summary
public TokenBuffer prepend(String text, TextToken.Type type)

Prepend a text token with a given type to the buffer

Parameters
text:String

the token's text

type:TextToken.Type

the token's type

Returns:TokenBuffer

this token buffer

prependback to summary
public TokenBuffer prepend(String text, TextToken.Type type, int formattingAttributes)

Prepend a text token with a given type and formatting attributes to the buffer

Parameters
text:String

the token's text

type:TextToken.Type

the token's type

formattingAttributes:int

the token's formatting attributes

Returns:TokenBuffer

this token buffer

prependback to summary
public TokenBuffer prepend(TokenBuffer other)

Prepend the contents of another token buffer to this one

Parameters
other:TokenBuffer

the other token buffer

Returns:TokenBuffer

this token buffer

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override