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

public Class LineAppendableImpl

extends Object
implements LineAppendable
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.util.sequence.LineAppendable, java.lang.Iterable, java.lang.Appendable
Imports
com.vladsch.flexmark.util.collection.iteration.Indexed, .IndexedItemIterable, .IndexedItemIterator, com.vladsch.flexmark.util.misc.BitFieldSet, .CharPredicate, .Pair, com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder, .StringSequenceBuilder, org.jetbrains.annotations.NotNull, .Nullable, java.io.IOException, java.util.ArrayList, .Iterator, .Stack

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private boolean
private ISequenceBuilder<?, ?>
private static final char
private int
private CharSequence
private final Stack<Boolean>
private final ArrayList<Runnable>
private boolean
pack-priv final ArrayList<LineInfo>
pack-priv int
private final BitFieldSet<LineAppendable.Options>
private final Stack<Integer>
private final boolean
private CharSequence
private CharSequence
private final Stack<CharSequence>
private int
private int
private int
private int
private int

Constructor Summary

AccessConstructor and Description
public
LineAppendableImpl(int formatOptions)

public
LineAppendableImpl(@Nullable Appendable builder, int formatOptions)

public

Method Summary

Modifier and TypeMethod and Description
public @NotNull LineAppendable
private void
addLineRange(int start, int end, CharSequence prefix)

public @NotNull LineAppendable
addPrefix(@NotNull CharSequence prefix, boolean afterEol)

private boolean
any(int flags)

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
)

Implements 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
)

Implements 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
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.append.

Appends the specified character to this Appendable.

public @NotNull LineAppendable
public @NotNull LineAppendable
append(@NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes)

private void
private void
appendEol(int count)

private void
appendImpl(CharSequence s, int index)

private void
appendImpl(CharSequence csq, int start, int end)

public <T extends Appendable> T
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
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.appendTo.

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

NOTE:

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

public @NotNull LineAppendable
blankLine()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.blankLine.

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

public @NotNull LineAppendable
blankLine(int
number of blank lines to append
count
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.blankLine.

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

public @NotNull LineAppendable
blankLineIf(boolean
when true append blank line
predicate
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.blankLineIf.

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

public @NotNull LineAppendable
public @NotNull LineAppendable
closePreFormatted()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.closePreFormatted.

Close preformatted section and suspend content modification

public int
column()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.column.

Get column offset after last append

private LineInfo
createLineInfo(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content)

private void
public boolean
public int
public @NotNull BasedSequence
public @NotNull ISequenceBuilder<?, ?>
getBuilder()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getBuilder.

Get builder used for accumulation

public @NotNull LineAppendable
public @NotNull BasedSequence
getIndentPrefix()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getIndentPrefix.

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

pack-priv @NotNull LineAppendableImpl.IndexedLineInfoProxy
getIndexedLineInfoProxy(int maxTrailingBlankLines, int startLine, int endLine)

pack-priv @NotNull LineAppendableImpl.IndexedLineProxy
getIndexedLineProxy(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes)

pack-priv @NotNull LineInfo
public @NotNull BasedSequence
getLine(int
line index
lineIndex
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getLine.

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 int
getLineCount()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getLineCount.

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

public int
getLineCountWithPending()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.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
getLineInfo(int
line index for the info to get
lineIndex
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getLineInfo.

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

private LineInfo
getLineRange(int start, int end, CharSequence prefix)

public @NotNull Iterable<BasedSequence>
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
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getLines.

Full line iterator over some lines

Note

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

public @NotNull Iterable<LineInfo>
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
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getLinesInfo.

Full line iterator with line info

Note

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

public @NotNull BitFieldSet<LineAppendable.Options>
getOptionSet()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getOptionSet.

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

public int
getPendingEOL()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getPendingEOL.

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

public int
getPendingSpace()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getPendingSpace.

Get number of spaces at end of pending text

public @NotNull BasedSequence
getPrefix()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getPrefix.

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

private Pair<Range, CharSequence>

Returns:

pair of line text range if EOL was added and prefix
getRangePrefixAfterEol
()

Returns text range if EOL was appended

Note

if range == Range.NULL then no line would be added

public int
getTrailingBlankLines(int
end line
endLine
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.getTrailingBlankLines.

Get trailing blank line count ending on given line

public @NotNull LineAppendable
indent()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.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 lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content)

private boolean
private boolean
public boolean
isPendingSpace()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.isPendingSpace.

Test if trailing text ends in space or tab

private boolean
isPrefixed(int currentLine)

public boolean
private boolean
private boolean
private boolean
public @NotNull Iterator<LineInfo>
iterator()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.iterator.

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

pack-priv int
lastNonBlankLine(int endLine)

public @NotNull LineAppendable
line()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.line.

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

public @NotNull LineAppendable
lineIf(boolean
call line() if value is true.
predicate
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.lineIf.

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

public @NotNull LineAppendable
public @NotNull LineAppendable
lineWithTrailingSpaces(int
number of trailing spaces to add
count
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.lineWithTrailingSpaces.

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 int
offset()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.offset.

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

private int

Returns:

would be offset after adding EOL - 1
offsetAfterEol
()

Returns text offset before EOL if EOL was issued

public int
offsetWithPending()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.offsetWithPending.

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

public @NotNull LineAppendable
openPreFormatted(boolean
if true will add the current prefix to first line
addPrefixToFirstLine
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.openPreFormatted.

Open preformatted section and suspend content modification

public @NotNull LineAppendable
public @NotNull LineAppendable
popPrefix(boolean
if true prefix will take effect after EOL
afterEol
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.popPrefix.

Pop a prefix from the stack and set the current prefix

public @NotNull LineAppendable
public @NotNull LineAppendable
pushPrefix()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.pushPrefix.

Save the current prefix on the stack

private void
private void
private void
pack-priv void
recomputeLineInfo(int startLine)

public LineAppendable
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
)

Implements com.vladsch.flexmark.util.sequence.LineAppendable.removeExtraBlankLines.

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

public @NotNull LineAppendable
public @NotNull LineAppendable
private int

Returns:

index from which line info must be recomputed
removeLinesRaw
(int
start line index to remove
startLine
,
int
end line index to remove
endLine
)

Remove lines and return index from which line info must be recomputed

public @NotNull LineAppendable
repeat(@NotNull CharSequence csq, int count)

public @NotNull LineAppendable
repeat(@NotNull CharSequence csq, int start, int end, int count)

private void
public @NotNull LineAppendable
public void
setLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content)

public @NotNull LineAppendable
setOptions(int
option flags
flags
)

Overrides default com.vladsch.flexmark.util.sequence.LineAppendable.setOptions.

Set options on processing text

public @NotNull LineAppendable
setPrefix(@Nullable CharSequence prefix, boolean afterEol)

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

Implements com.vladsch.flexmark.util.sequence.LineAppendable.setPrefixLength.

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

pack-priv int
tailBlankLinesToRemove(int endLine, int maxTrailingBlankLines)

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

Implements com.vladsch.flexmark.util.sequence.LineAppendable.toSequence.

get the resulting text for all lines

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

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

Implements com.vladsch.flexmark.util.sequence.LineAppendable.toString.

get the resulting text for all lines

public @NotNull LineAppendable
unIndent()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.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
unIndentNoEol()

Implements com.vladsch.flexmark.util.sequence.LineAppendable.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.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait