Top Description Inners Fields Methods
com.vladsch.flexmark.util.sequence

public Interface LineAppendable

extends Appendable, Iterable<LineInfo>
Known Direct Implementers
com.vladsch.flexmark.util.sequence.LineAppendableImpl
Annotations
@SuppressWarnings:UnusedReturnValue, SameParameterValue
Imports
com.vladsch.flexmark.util.misc.BitFieldSet, com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder, org.jetbrains.annotations.NotNull, .Nullable, java.io.IOException, java.util.Iterator

Used to collect line text for further processing

control output of new lines limiting them to terminate text but not create blank lines, and control number of blank lines output, eliminate spaces before and after an \n, except in prefixes and indents controlled by this class.

allows appending unmodified text in preformatted regions created by openPreFormatted(boolean) and closePreFormatted()

consecutive \n in the data are going go be collapsed to a single \n. To get blank lines use blankLine() or blankLine(int)

tab is converted to spaces if F_CONVERT_TABS or F_COLLAPSE_WHITESPACE option is selected

spaces before and after \n are removed controlled by F_TRIM_TRAILING_WHITESPACE and F_TRIM_LEADING_WHITESPACE

use line(), lineIf(boolean), blankLine() as an alternative to appending \n. use blankLineIf(boolean) and blankLine(int) for appending blank lines.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
public static final int
ALLOW_LEADING_EOL

Deprecated ALLOW_LEADING_EOL is now inverted and named F_TRIM_LEADING_EOL
public static final int
ALLOW_LEADING_WHITESPACE

Deprecated ALLOW_LEADING_WHITESPACE is now inverted and named F_TRIM_LEADING_WHITESPACE
public static final int
public static final int
CONVERT_TABS

Deprecated
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
FORMAT_ALL

Deprecated
public static final LineAppendable.Options
public static final LineAppendable.Options
public static final BitFieldSet<LineAppendable.Options>
public static final LineAppendable.Options
public static final LineAppendable.Options
public static final LineAppendable.Options
public static final LineAppendable.Options
public static final LineAppendable.Options
public static final int
PASS_THROUGH

Deprecated
public static final int
public static final int
public static final int

Method Summary

Modifier and TypeMethod and Description
public @NotNull LineAppendable

Returns:

this
addIndentOnFirstEOL
(@NotNull Runnable
runnable to run if adding indent on first EOL
listener
)

Add an indent on first EOL appended and run runnable

public default @NotNull LineAppendable
addOptions(int flags)

public @NotNull LineAppendable

Returns:

this
addPrefix
(@NotNull CharSequence
prefix characters to add to current prefix for new lines appended after this is set
prefix
,
boolean
if true prefix will take effect after EOL
afterEol
)

Add to prefix appended after a new line character for every line and after a new line in pre-formatted sections

This appends the sequence to current prefix

public default @NotNull LineAppendable

Returns:

this
addPrefix
(@NotNull CharSequence
prefix characters to add to current prefix for new lines appended after this is set
prefix
)

Add to prefix appended after a new line character for every line and after a new line in pre-formatted sections

This appends the sequence to current prefix

public @NotNull LineAppendable
append(@NotNull CharSequence
The character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.
csq
)

Redeclares java.lang.Appendable.append.

Appends the specified character sequence to this Appendable.

public @NotNull LineAppendable
append(@NotNull CharSequence
The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
csq
,
int
The index of the first character in the subsequence
start
,
int
The index of the character following the last character in the subsequence
end
)

Redeclares java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this Appendable.

public @NotNull LineAppendable
append(char
The character to append
c
)

Redeclares java.lang.Appendable.append.

Appends the specified character to this Appendable.

public @NotNull LineAppendable
append(char c, int count)

public @NotNull LineAppendable

Returns:

this
append
(@NotNull LineAppendable
lines to append, any unterminated lines will be terminated by a line() invocation.
lineAppendable
,
int
start line to append
startLine
,
int
end line to append, endLine is excluded.
endLine
,
boolean
true if to include prefixes from the lineAppendable.
withPrefixes
)

Append lines from another line formatting appendable.

public default @NotNull LineAppendable

Returns:

this
append
(@NotNull LineAppendable
lines to append
lineAppendable
)

Append lines from another line formatting appendable.

public default @NotNull LineAppendable

Returns:

this
append
(@NotNull LineAppendable
lines to append
lineAppendable
,
boolean
true if to include prefixes from the lineAppendable.
withPrefixes
)

Append lines from another line formatting appendable.

public default @NotNull LineAppendable
public default <T extends Appendable> T
appendTo(T out, int maxTrailingBlankLines)
Deprecated

public <
type of out
T extends Appendable
>
T

Returns:

out
appendTo
(T
appendable to output the resulting lines
out
,
boolean
true if to include prefixes
withPrefixes
,
int
maximum blank lines to allow in the body,
maxBlankLines
,
int
maximum trailing blank lines at the end, if <maxBlankLines then maxBlankLines will be used, if -1 then no trailing EOL will be added
maxTrailingBlankLines
,
int
line from which to start output
startLine
,
int
line at which to stop output
endLine
)

append lines to appendable with given maximum trailing blank lines and given prefix to add to all lines

NOTE:

public default <T extends Appendable> T
appendTo(T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)

public default <T extends Appendable> T
appendTo(T out, int maxBlankLines, int maxTrailingBlankLines)

public default <
type of out
T extends Appendable
>
T

Returns:

out
appendTo
(T
appendable to output the resulting lines
out
)

append lines to appendable with 0 blank lines, if these are desired at the end of the output use appendTo(Appendable, int, int).

public default <T extends Appendable> T
appendToSilently(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)

public default <T extends Appendable> T
appendToSilently(T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)

public default <T extends Appendable> T
appendToSilently(T out, int maxBlankLines, int maxTrailingBlankLines)

public default <T extends Appendable> T
public @NotNull LineAppendable

Returns:

this
blankLine
()

Add a blank line, if there is not one already appended.

public @NotNull LineAppendable

Returns:

this
blankLine
(int
number of blank lines to append
count
)

Add a blank lines, if there isn't already given number of blank lines appended.

public @NotNull LineAppendable

Returns:

this
blankLineIf
(boolean
when true append blank line
predicate
)

Add a blank line, if predicate is true and there isn't already blank lines appended.

public @NotNull LineAppendable
changeOptions(int addFlags, int removeFlags)

public default @NotNull LineAppendable
public @NotNull LineAppendable

Returns:

this
closePreFormatted
()

Close preformatted section and suspend content modification

public int

Returns:

column offset after last append
column
()

Get column offset after last append

public static CharSequence
public default @NotNull LineAppendable

Returns:

copy of appendable with requested content
copyAppendable
(int
start line
startLine
,
int
end line
endLine
,
boolean
true if to include prefixes
withPrefixes
)

Make a copy of this appendable with the given line range

public default @NotNull LineAppendable
copyAppendable(int startLine, int endLine)

public default @NotNull LineAppendable
copyAppendable(int startLine)

public default @NotNull LineAppendable
public default @NotNull LineAppendable
copyAppendable(boolean withPrefixes)

public boolean

Returns:

true if not empty and have no unterminated lines
endsWithEOL
()

public default @NotNull LineInfo

Returns:

line info
get
(int
line index
lineIndex
)

Kotlin index operator

public int

Returns:

change in prefix length after next eol
getAfterEolPrefixDelta
()

Get pending prefix after EOL

public @NotNull BasedSequence

Returns:

char sequence of the current prefix
getBeforeEolPrefix
()

Get prefix used before EOL

public @NotNull ISequenceBuilder<?, ?>

Returns:

builder used for accumulation
getBuilder
()

Get builder used for accumulation

public @NotNull LineAppendable
public @NotNull BasedSequence

Returns:

char sequence of the current indent prefix used for each indent level
getIndentPrefix
()

Get prefix appended after a new line character for every indent level

public @NotNull BasedSequence

Returns:

line char sequence
getLine
(int
line index
lineIndex
)

Get Line at given line index

Note

if there is an unterminated line it will be available as the last line, without being terminated explicitly

public default @NotNull BasedSequence

Returns:

char sequence for the line
getLineContent
(int
line index
lineIndex
)

Get Line content of given line

public int

Returns:

number of full lines appended
getLineCount
()

Get the number of lines appended, not including any unterminated ones

public int

Returns:

number of lines appended
getLineCountWithPending
()

Get the number of lines appended, including any unterminated ones

Note

if there is an unterminated line it will be available as the last line, without being terminated explicitly

public @NotNull LineInfo

Returns:

line info
getLineInfo
(int
line index for the info to get
lineIndex
)

Get Line information at given line index

Note

if there is an unterminated line it will be available as the last line, without being terminated explicitly

public default @NotNull BasedSequence

Returns:

line prefix char sequence
getLinePrefix
(int
line index
lineIndex
)

Get prefix of given line

public @NotNull Iterable<BasedSequence>

Returns:

iterator over lines
getLines
(int
maximum trailing blank lines, -1 if trailing EOL should be removed
maxTrailingBlankLines
,
int
start line index
startLine
,
int
end line index, exclusive
endLine
,
boolean
true if prefixes should be included, else only non-prefix line text
withPrefixes
)

Full line iterator over some lines

Note

will issue line() to terminate any unterminated lines before iteration

public default @NotNull Iterable<BasedSequence>
getLines(int maxTrailingBlankLines)

public default @NotNull Iterable<BasedSequence>
public default @NotNull Iterable<BasedSequence>
getLines(int maxTrailingBlankLines, boolean withPrefixes)

public default @NotNull Iterable<BasedSequence>
getLines(boolean withPrefixes)

public @NotNull Iterable<LineInfo>

Returns:

iterator over lines
getLinesInfo
(int
maximum trailing blank lines, -1 if trailing EOL should be removed
maxTrailingBlankLines
,
int
start line index
startLine
,
int
end line index, exclusive
endLine
)

Full line iterator with line info

Note

will issue line() to terminate any unterminated lines before iteration

public default @NotNull Iterable<LineInfo>
getLinesInfo(int maxTrailingBlankLines)

public default @NotNull Iterable<LineInfo>
public default int

Returns:

option flags
getOptions
()

Get current options as bit mask flags

public @NotNull BitFieldSet<LineAppendable.Options>

Returns:

mutable option set
getOptionSet
()

Get current options as set which can be used to modify options

public int

Returns:

number of eols at end of text
getPendingEOL
()

Get number of EOLs at end of appendable, this is actually number of tail blank lines

public int

Returns:

number of eols at end of text
getPendingSpace
()

Get number of spaces at end of pending text

public @NotNull BasedSequence

Returns:

char sequence of the current prefix
getPrefix
()

Get prefix being applied to all lines, even in pre-formatted sections This is the prefix that will be set after EOL

public int

Returns:

number of trailing blank lines
getTrailingBlankLines
(int
end line
endLine
)

Get trailing blank line count ending on given line

public default int
public @NotNull LineAppendable

Returns:

this
indent
()

Increase the indent level, will terminate the current line if there is unterminated text

Note

this is equivalent to pushPrefix(), addPrefix(getIndentPrefix()) but adds a flag to validate that unIndent() is called only on prefixes added by this method

public void
insertLine(int
index of the line
lineIndex
,
@NotNull CharSequence
prefix of the line
prefix
,
@NotNull CharSequence
content text of the line
text
)

Insert a line at the index with given content and prefix for a line

public default boolean

Returns:

true if have no terminated lines
isEmpty
()

Kotlin compatibility

public default boolean

Returns:

true if have terminated lines
isNotEmpty
()

Kotlin compatibility

public boolean

Returns:

true if ending in space or tab
isPendingSpace
()

Test if trailing text ends in space or tab

public boolean

Returns:

true if in pre-formatted region
isPreFormatted
()

public @NotNull Iterator<LineInfo>

Returns:

iterator over lines
iterator
()

Redeclares java.lang.Iterable.iterator.

Full line iterator NOTE: will not issue line() to terminate any unterminated lines before iteration and will not include unterminated lines in iteration

public @NotNull LineAppendable

Returns:

this
line
()

Add a new line if there was any unterminated text appended or if this is a preformatted region

public @NotNull LineAppendable

Returns:

this
lineIf
(boolean
call line() if value is true.
predicate
)

Add a new line, if predicate is true and line() would add an EOL.

public @NotNull LineAppendable
lineOnFirstText(boolean value)

public @NotNull LineAppendable

Returns:

this
lineWithTrailingSpaces
(int
number of trailing spaces to add
count
)

Add a new line, keep trailing spaces if there was any unterminated text appended

Note

only applies in preformatted region or if the line is not empty

public default @NotNull LineAppendable
public default @NotNull LineAppendable
public int

Returns:

offset of text as would be returned for all
offset
()

Get text offset of all output lines, excluding any text for the last line being accumulated

public int

Returns:

offset as would be returned by offset() after line() call less 1 for EOL
offsetWithPending
()

Get offset after last append as if EOL was added but without the EOL itself

public @NotNull LineAppendable

Returns:

this
openPreFormatted
(boolean
if true will add the current prefix to first line
addPrefixToFirstLine
)

Open preformatted section and suspend content modification

public @NotNull LineAppendable
public @NotNull LineAppendable

Returns:

this
popPrefix
(boolean
if true prefix will take effect after EOL
afterEol
)

Pop a prefix from the stack and set the current prefix

public default @NotNull LineAppendable

Returns:

this
popPrefix
()

Pop a prefix from the stack and set the current prefix

public default @NotNull LineAppendable
public @NotNull LineAppendable
public @NotNull LineAppendable

Returns:

this
pushPrefix
()

Save the current prefix on the stack

public LineAppendable

Returns:

this
removeExtraBlankLines
(int
maximum blank lines to allow in the body
maxBlankLines
,
int
maximum trailing blank lines ending on endLine, if <maxBlankLines then maxBlankLines will be used
maxTrailingBlankLines
,
int
line from which to start output
startLine
,
int
line at which to stop output
endLine
)

Normalize the appendable by removing extra blank lines in the body or at the end of given line range

public default LineAppendable
removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines)

public @NotNull LineAppendable

Returns:

this
removeIndentOnFirstEOL
(@NotNull Runnable
runnable added with addIndentOnFirstEOL
listener
)

Remove runnable, has no effect if EOL was already appended and runnable was run

public @NotNull LineAppendable
removeLines(int startLine, int endLine)

public default @NotNull LineAppendable
removeOptions(int flags)

public @NotNull LineAppendable

Returns:

this
setIndentPrefix
(@Nullable CharSequence
prefix characters for new lines appended after this is set
prefix
)

Set prefix to append after a new line character for every indent level

public void
setLine(int
index of the line
lineIndex
,
@NotNull CharSequence
prefix of the line
prefix
,
@NotNull CharSequence
content text of the line
text
)

Set content and prefix for a line

public default @NotNull LineAppendable
public default @NotNull LineAppendable

Returns:

this
setOptions
(int
option flags
flags
)

Set options on processing text

public default @NotNull LineAppendable
public default @NotNull LineAppendable

Returns:

this
setOptions
(BitFieldSet<LineAppendable.Options>
option set
options
)

Set options on processing text

public @NotNull LineAppendable

Returns:

this
setPrefix
(@Nullable CharSequence
prefix characters to add to current prefix for new lines appended after this is set
prefix
,
boolean
if true prefix will take effect after EOL
afterEol
)

Set prefix appended after a new line character for every line and after a new line in pre-formatted sections

This appends the sequence to current prefix

public default @NotNull LineAppendable

Returns:

this
setPrefix
(@NotNull CharSequence
prefix characters to add to current prefix for new lines appended after this is set
prefix
)

Set prefix appended after a new line character for every line and after a new line in pre-formatted sections

This appends the sequence to current prefix

public void
setPrefixLength(int
index of the line
lineIndex
,
int
new prefix length
prefixLength
)

Change prefix length for a given line without changing the line content

public static BitFieldSet<LineAppendable.Options>
toOptionSet(int options)

public static BitFieldSet<LineAppendable.Options>
public @NotNull CharSequence

Returns:

resulting text
toSequence
(int
maximum blank lines to allow in the text
maxBlankLines
,
int
maximum trailing blank lines
maxTrailingBlankLines
,
boolean
true if to include prefixes
withPrefixes
)

get the resulting text for all lines

public default @NotNull CharSequence
toSequence(int maxBlankLines, int maxTrailingBlankLines)

public default @NotNull CharSequence
toSequence(int maxBlankLines, boolean withPrefixes)

public default @NotNull CharSequence
toSequence(boolean withPrefixes)

public default @NotNull CharSequence
public @NotNull String

Returns:

resulting text
toString
(int
maximum blank lines to allow in the text
maxBlankLines
,
int
maximum trailing blank lines
maxTrailingBlankLines
,
boolean
true if to include prefixes
withPrefixes
)

get the resulting text for all lines

public default @NotNull String
toString(int maxBlankLines, int maxTrailingBlankLines)

public default @NotNull String
toString(int maxBlankLines, boolean withPrefixes)

public default @NotNull String
toString(boolean withPrefixes)

public default @NotNull String

Returns:

resulting text
toString
(int
maximum blank lines to allow, if -1 then no trailing EOL will be generated
maxBlankLines
)

get the resulting text for all lines

public default @NotNull LineAppendable
public @NotNull LineAppendable

Returns:

this
unIndent
()

Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text

Note

this is equivalent to popPrefix() but with validation that it is called only on prefixes added by indent()

public @NotNull LineAppendable

Returns:

this
unIndentNoEol
()

Decrease the indent level, if there is unterminated text then unindented prefix is to be applied after the next EOL.

Inherited from java.lang.Iterable:
forEachspliterator